AivexaNewsSearch
AI news for builders and product teamsChecked every hour

Amazon SageMaker AI real-time endpoints now support KV cache aware routing

Collected Nov 17, 2026

Amazon SageMaker AI has introduced KV cache-aware routing for real-time endpoints, a new routing strategy that uses cache state reported by the model container to decide which instance should serve each request. The company announced it on the AWS Machine Learning Blog this week as the second part of a series that began with prefix-aware routing. Teams enable it by adding an environment variable so the container publishes cache events, and by setting RoutingStrategy to KV_AWARE in the endpoint configuration. Client code calls the endpoint through the same APIs as before.

The problem it targets is prefill. Large language models keep the intermediate attention state computed for a prompt in GPU memory as a KV cache, and skip that work when the same text reaches the same instance again. Chat assistants, retrieval-augmented generation (RAG) pipelines and agents with long system prompts repeat the same leading text constantly, so cache locality directly affects latency and cost. The earlier prefix-aware strategy hashes the first part of each request, up to a configurable PrefixLength, and routes by that hash alone; it never learns whether an instance still holds the matched cache. That breaks down when GPU memory fills and an instance evicts entries, or when a multi-turn conversation is still shorter than PrefixLength so every new turn changes the hash.

KV-aware routing instead closes the loop. Containers publish a KV cache event whenever they store or evict entries; SageMaker AI maintains a managed index of that state for the endpoint and consults it per request. The index holds only one-way, truncated hashes of cached content mapped to the instance or inference component copy that holds them — no prompts, token IDs, payloads or KV tensors. On arrival, a request is tokenized and its tokens looked up, returning candidate instances and how much of the prompt each holds. The router weighs match length against current load, skipping candidates that are too busy; if nothing useful matches, it falls back to load-aware routing equivalent to LEAST_OUTSTANDING_REQUESTS. There is no concurrency threshold to tune, unlike prefix-aware routing. The index tracks scaling: entries for removed instances drop out, while newly added instances start cold, so latency can briefly rise after a scale-out or rollout.

Routing only has an effect with at least two instances, or at least two copies of an inference component; with one destination the setting is accepted but inert. Supported targets are real-time single-model endpoints and inference component endpoints, including dynamic LoRA adapters, on GPU instances, configurable through AWS CloudFormation as well. At launch the container must be the AWS vLLM Deep Learning Container with vLLM 0.33.0 or later, or the Amazon Linux build server-sagemaker-cuda-v2.8.0 or later, with prefix caching left on (the default) and KV events enabled manually via SM_VLLM_KV_EVENTS_CONFIG. Requests must be OpenAI-compatible Completions or Chat Completions payloads sent through InvokeEndpoint, InvokeEndpointWithResponseStream or the SageMaker AI OpenAI-compatible Chat Completions API; bidirectional streaming is not supported. Images built for CUDA 13 also need a matching InferenceAmiVersion such as al2023-ami-sagemaker-inference-gpu-4-1. Detailed observability for hit-rate tracking requires AWS CLI 2.35.6 or later, or Boto3 1.43.31 or later. SageMaker AI validates these requirements before serving traffic and fails the deployment or request with a descriptive message when something is missing.

Measured against random routing with Llama 3.1 70B Instruct on seven ml.p5.48xlarge instances, over 30-minute runs with 20 or 100 simulated users in multi-turn chat and document Q&A, prompts reaching roughly 64,000 tokens, AWS reports p50 time to first token cut by up to 97 percent and throughput up to 234 percent higher on long prompts under load. KV cache hit rate moved from 3–48 percent to 80–93 percent. Gains shrank with short prompts, where there is less prefill to save, and AWS notes results depend on the workload.

Behavioral differences matter for teams moving from prefix-aware routing. Matching is on tokens rather than a fixed byte or character count, so a growing conversation history can match in full. KV-aware routing ignores the prefix-aware ID header and the prompt_cache_key field from the first part of the series, and rejects any request carrying a non-null top-level cache_salt with a 400 error. A request whose model field names a model the container does not serve fails with a ModelError; if the field is set it must equal SM_VLLM_MODEL. Routing decisions are not logged to the customer account and produce no dedicated console metrics, so verification relies on the model itself: enabling SM_VLLM_ENABLE_PROMPT_TOKENS_DETAILS to surface usage.prompt_tokens_details.cached_tokens per response, or turning on detailed observability to see KV cache hit rate and TTFT in CloudWatch via PromQL and the SageMaker AI Insights dashboard.

My reading is that this is a targeted fix for a real failure mode rather than a universal upgrade. Tokenizing and indexing adds a few milliseconds per request, larger for long prompts, though standard text-only requests reuse those tokens so the prompt is not tokenized twice. The payoff is concentrated where cached context is long and GPU memory is under pressure — which describes many production RAG and agent deployments. Where prefixes are stable and load is moderate, instances rarely evict, both strategies find the same cache, and prefix-aware routing remains the cheaper choice since it requires no container changes and works on any framework with prefix caching enabled. A likely trade-off is operational: the extra environment variable, the container version floor and the observability flags are easy to get wrong, and because fallbacks to load-aware routing are silent in console metrics at launch, a misconfigured endpoint could look healthy while quietly delivering no cache benefit.

Why it matters: Teams running long-context LLM endpoints on SageMaker AI now have a routing option that reacts to actual cache state instead of guessing from request text, and the published benchmark suggests substantial latency and throughput improvements for conversational and RAG traffic at scale. The cost is a narrow compatibility window — vLLM-based containers only at launch — plus new configuration and validation steps. Product teams serving repeated long prompts under load should test KV_AWARE against their own traffic and compare time to first token, throughput and hit rate before switching.

Read at AWS Machine Learning Blog

Based on reporting from the original publisher. Visit the source for full context and later updates.

Publisher excerpt

Amazon SageMaker AI real-time endpoints now support KV cache-aware routing, a new strategy that routes each request to the instance holding the longest cached match for its prompt. Learn how it works, when to use it compared with prefix-aware routing, and how to enable, invoke, and verify it on single model and inference component endpoints.