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

In one sentence

Amazon SageMaker AI introduces KV cache-aware routing for real-time endpoints, directing LLM requests to available instances with the longest matching cached prompt.

Key points

  • KV-aware routing uses real-time cache states reported by model containers and a managed index to send requests to less-busy instances holding the longest cached match.
  • Unlike prefix-aware routing that hashes fixed-length prefixes, it matches on tokens and tracks cache evictions, making it ideal for multi-turn chats and long shared prompts.
  • Users enable it by setting an environment variable for container cache events and configuring RoutingStrategy to KV_AWARE, requiring at least two instances or copies.
  • The managed index only stores one-way truncated hash pointers rather than prompts or tensors, and falls back to load-aware routing if matched instances are busy.

In depth

An AI-written overview of the original article, not the article itself.

Amazon SageMaker AI has introduced KV cache-aware routing for its real-time endpoints. By routing requests based on actual GPU cache states reported by model containers, it overcomes the limitations of prefix-aware routing and significantly reduces latency for multi-turn conversations and long shared prompts.

How It Works and Setup

The strategy operates in three parts: model containers publish KV cache store and eviction events via the SM_VLLM_KV_EVENTS_CONFIG environment variable; SageMaker AI maintains a managed cache index storing only one-way truncated hashes mapped to instances without keeping raw prompts or tensors; and the endpoint tokenizes incoming requests, queries the index, and routes each request to the instance with the longest cached match that is not overloaded, falling back to load-aware routing if needed.

Teams can enable it by adding the environment variable and setting RoutingStrategy to KV_AWARE in the endpoint configuration, with no client API changes required. It requires at least two instances or inference component copies, an AWS vLLM Deep Learning Container, and OpenAI-compatible Completions or Chat Completions payloads.

Performance and Use Cases

In benchmarks running Llama 3.1 70B Instruct on seven ml.p5.48xlarge instances with prompts up to 64,000 tokens, KV-aware routing reduced p50 time to first token by up to 97 percent and increased throughput by up to 234 percent compared to random routing, while raising cache hit rates from 3–48 percent to 80–93 percent. The tokenization and lookup overhead of a few milliseconds is minimal compared to the prefill time saved.

Unlike prefix-aware routing, which infers cache locations from fixed-length request prefixes, KV-aware routing adapts to cache evictions under memory pressure and growing multi-turn histories. It is ideal for long conversations, RAG applications, and high-throughput workloads, whereas shorter, stable prompts under moderate load can continue using prefix-aware routing.

Read originalOpens aws.amazon.com

This summary was generated by AI from the original article and may contain errors; the original is authoritative. Copyright belongs to the original author.

Recent stories from this source