The hidden cost of context recalculation
In self-hosted large language model (LLM) inference architectures, each GPU server maintains a local key-value (KV) cache that stores the attention state of previous requests. When AI agent or multi-turn chat applications resend long or shared contexts, these isolated caches cannot retain or share the accumulated state, forcing GPUs to recalculate attention from scratch for each new request.
This redundant recalculation consumes compute capacity that could otherwise be used to generate new tokens, increasing both operational costs and perceived user latency. The new distributed KV caching capability addresses this by extending GPU-local memory with a shared layer that allows any server in the fleet to reuse KV state for days, even after routing shifts or server failures.
The isolation of local caches means that even when identical context is processed by different servers, the computational effort is duplicated rather than shared. This fragmentation becomes particularly pronounced in dynamic environments where load balancers distribute requests across multiple nodes, preventing any single server from benefiting from the work performed by its peers. The distributed layer effectively decouples the storage of attention state from the physical location of the inference engine, allowing the fleet to operate as a unified resource for context management.
Technical mechanics: ElastiCache for Valkey and RDMA
The implementation is based on Amazon ElastiCache for Valkey, using cache.i8ge.48xlarge nodes running Valkey version 9.1 or later. These nodes store cache objects in dynamic random-access memory (DRAM) and local NVMe storage, leveraging the Valkey large object module to manage high-volume data.
Communication between GPU inference hosts and the cache cluster occurs via Remote Direct Memory Access (RDMA) over AWS Elastic Fabric Adapter (EFA), or over TCP. This mechanism allows GPUs to retrieve cached KV state in milliseconds, minimizing network overhead and keeping inference latency at optimal levels. The feature operates within the same Availability Zone as the GPU fleet to ensure low physical latency.
The use of RDMA over EFA is critical for maintaining the performance benefits of the distributed cache, as it bypasses the traditional network stack to transfer data directly between memory buffers. This direct access reduces the latency associated with copying data through the operating system, ensuring that the retrieval of cached KV state does not become a bottleneck in the inference pipeline. For deployments where RDMA is not available, TCP provides a compatible alternative, though it may introduce slightly higher overhead compared to the direct memory access path.
Technical requirements for distributed KV caching
Minimum specifications and components required for implementation.
| Component | Requirement or Specification |
|---|---|
| Node type | cache.i8ge.48xlarge |
| Cache engine | ElastiCache for Valkey 9.1 or later |
| Data module | valkey-large-object (BLOB.* commands) |
| Transfer network | RDMA over EFA or TCP |
| Location | Same Availability Zone as the GPU fleet |
Compatibility with inference engines and models
Integration with existing infrastructure is achieved through the LMCache connector, which requires only a configuration change in already-deployed inference engines. The feature is compatible with major industry engines, including vLLM, SGLang, and TensorRT-LLM.
Regarding models, the distributed cache works with open-weight, fine-tuned, and custom models, regardless of whether they use full, sparse, hybrid, or other attention designs. Official documentation cites compatibility with model families such as Qwen, Kimi, Hy4, GPT-OSS, DeepSeek, Inkling, Gemma, Nemotron, and GLM, provided the inference engine and LMCache support them.
The reliance on the LMCache connector simplifies the adoption process by abstracting the complexity of the distributed storage layer from the inference engine. Developers do not need to modify the core logic of their models or the underlying engine code; instead, they adjust configuration parameters to point the engine to the new cache endpoint. This approach ensures that existing optimizations and performance tuning within the inference engine remain intact while gaining the benefits of shared state management.
Quantified results and optimal use cases
AWS reports that implementing distributed KV caching can reduce inference costs by up to 40% and time to first token (TTFT) by up to 80%. These improvements are achieved by allowing the existing GPU fleet to handle more traffic without scaling raw compute capacity.
The feature offers the greatest benefits in workloads with long-running sessions, multi-turn chats, shared system prompts, and retrieval-augmented generation (RAG) tasks with long context. Conversely, the gain is minimal for short or never-repeated prompts, such as classification, translation, or moderation, as well as for diffusion models where output generation dominates processing time.
The reported reductions in cost and latency are contingent upon the frequency with which the same context is reused across the fleet. Workloads with high repetition rates, such as those involving common system prompts or recurring user queries, are most likely to approach the maximum potential savings. Conversely, applications with highly unique or one-off prompts will see limited benefits, as the cache hit rate remains low and the overhead of managing the distributed layer may outweigh the savings from avoided recalculation.
Evaluation and deployment tools
Before deploying the infrastructure, teams can use the open-source KVTrace tool to estimate the impact on costs and latency on their own application traffic. KVTrace records KV cache events from a running vLLM or SGLang fleet, simulates a shared cache with different numbers of nodes, and reports the estimated hit rate, projected savings, and the break-even price of the cache.
Initial deployment requires creating a cluster with cache.i8ge.48xlarge nodes via the AWS Command Line Interface (AWS CLI) in the same Availability Zone as the GPU fleet, followed by adding the cache endpoint to the inference engine configuration. The feature is currently available in 13 AWS Regions across North America, Europe, and Asia Pacific.
KVTrace serves as a critical validation step by providing a data-driven estimate of the return on investment before any infrastructure changes are made. By analyzing real traffic patterns, it helps teams determine the optimal number of cache nodes required to achieve a positive break-even point, preventing over-provisioning of the cache cluster. This pre-deployment analysis ensures that the additional cost of the Valkey nodes is justified by the corresponding reduction in GPU compute time.
Basic implementation workflow
Essential steps to enable distributed caching in an existing infrastructure.
- 01Identify the Availability Zone of the GPU inference fleet.
- 02Create an ElastiCache for Valkey cluster with cache.i8ge.48xlarge nodes in that Zone.
- 03Verify that the inference engine (vLLM, SGLang, etc.) uses a compatible version of LMCache.
- 04Configure the inference engine to point to the cache cluster endpoint.
- 05Use KVTrace to validate the estimated hit rate before full production rollout.
Keep exploring
Sources consulted
Corrections and transparency
If you spot incorrect or outdated information, send us a correction with the page and source we should review.
Submit a correction