Valkey Turns LLM KV Cache Into Shared Fleet Infrastructure

Valkey and LMCache can share reusable inference state across GPU servers. The architecture can cut prefill work, but only when real traffic justifies the network and memory cost.

QuantumBytz Team
November 24, 2026
Share:
Infrastructure engineer connecting liquid-cooled GPU servers through high-speed networking to a separate bank of shared cache servers.

Summary

Valkey and LMCache now offer an open path to a problem that appears once self-hosted LLM inference grows beyond one server: useful key-value cache state is often stranded on the GPU node that computed it. A shared Valkey tier can preserve that state outside individual inference workers and make it available across a fleet.[1][2]

The idea is attractive because prefill is expensive. Each request must process its input context before the model can emit a first token. Multi-turn chats, coding assistants and retrieval systems often send large prefixes that have already been processed. Local GPU and host-memory caches help, but load balancing, eviction, autoscaling and restarts can separate a returning request from its cached state.

Valkey's published benchmark reports 25% more requests served and roughly twice the output streaming rate after adding a three-shard shared cache to two eight-H100 inference nodes.[2] Those are project-run results from a synthetic workload, not a general promise. A remote cache also adds memory servers, network traffic and another service on the latency path. The practical question is whether a workload reuses enough long context to repay that cost.

Why local prefix caching eventually runs out of road

An inference engine creates attention key and value tensors while it processes a prompt. Reusing those tensors for a matching prefix can skip much of the repeated prefill work. The model still generates a new answer; the cache preserves intermediate state from text it has already processed.

That state is large. Valkey's engineering post calculates about 0.33 MB per token for the bf16 KV cache of Llama 3.1 70B. By that estimate, a 20,000-token conversation occupies roughly 6.6 GB. FP8 cuts the bytes per token, but it does not remove the capacity problem. A few long contexts can evict many shorter ones.[2]

Most serving engines already keep an L0 cache in GPU memory and may spill to an L1 tier in host RAM. That works well while requests stay on the same worker and the active reuse set fits locally. Production fleets break both assumptions. A load balancer can send the next turn to a different node. Autoscaling introduces cold workers. A restarted engine loses its local state. Even without those events, a busy node eventually evicts conversations that pause and return later.

Strict session affinity can improve the hit rate, but it trades away some of the reason to run a fleet. A hot user or unusually long prompt can pin work to an overloaded node while others sit below capacity. Draining or replacing a node also discards its cache. Cache-aware routing is more flexible, yet a router cannot recover state that exists only on a failed or removed machine.

LMCache separates KV-cache management from the inference engine. Its current documentation describes tiers spanning GPU memory, host RAM, local storage and remote backends, including Valkey. It can reuse stored state across requests, sessions and engine instances, and its standalone process can outlive a serving engine crash.[3] Valkey becomes the shared L2 tier: slower than memory attached to a GPU worker, but reachable by every worker and independently scalable.

What the Valkey design actually adds

The published reference stack puts LMCache between vLLM workers and Valkey. Two vLLM replicas connect to a standalone LMCache service, which keeps an L1 cache in its own memory and writes through to Valkey as L2. A cold request computes and stores its KV chunks. A later request can load those chunks through a different replica instead of recomputing the shared prefix.[4]

That is a narrower claim than "Valkey makes inference faster." It helps when remote retrieval costs less than recomputing a reusable prefix. It does not speed up a cold prompt, and it does not add decode capacity after the first token arrives. If each request is unrelated, cache entries consume memory and network bandwidth without producing many hits.

The October benchmark used two nodes with eight H100 GPUs each, Llama 3.1 70B, vLLM, LMCache and 100 synthetic conversations that grew from 12,000 to 28,000 tokens. Requests arrived at eight per second. The shared side used three memory-optimized Valkey shards in the same availability zone and a cache-aware router.[2]

Over a 20-minute run, the configuration with shared L2 served 4,631 requests versus 3,692 without it, a 25% increase. It produced 28% more output tokens, raised reported streaming speed from 11.9 to 24.8 tokens per second, and reduced the share of prompt tokens recomputed from about 10% to about 1%. For contexts below roughly 16,000 tokens while the fleet still had headroom, reported time to first token fell from 8.5 seconds to 0.13 seconds.[2]

Those figures need their test conditions attached. The traffic was deliberately rich in reusable, growing conversations. The cache sat in the same availability zone. The authors sized it to about 1.3 times the estimated peak working set and paired it with cache-aware routing. The three cache shards added about 15% to the GPU bill in their cost model. At longer contexts and the tested arrival rate, new-token prefill pressure still exceeded available GPU capacity, so first-token latency stopped improving even though aggregate throughput remained better.[2]

A Linux Foundation announcement published with Valkey 9.2 cites reductions of up to 40% in inference cost and up to 80% in time to first token.[1] Those are vendor and project claims across selected workloads. They should be treated as a reason to benchmark, not as capacity-planning inputs.

The network becomes part of first-token latency

A remote KV cache moves very large objects. Loading a 6.6 GB conversation before generation is nothing like fetching a small application cache entry. The Valkey test reported about 7.4 GB/s of aggregate reads from three shards, with peaks near 9.4 GB/s. Its authors recommend scaling shards for read bandwidth as well as memory.[2]

Placement matters. A cross-zone cache adds round-trip time to every retrieval and can create large transfer charges in both directions. Putting cache nodes in the same zone as GPU workers reduces that penalty, but it raises a resilience decision: whether each zone gets an independent cache, whether state is replicated, and what should happen when a zone fails.

Encryption also has a measurable price at this scale. The connector supports TLS, and KV state may encode user conversations, retrieved documents or proprietary source code. Teams should not treat it as harmless scratch data. They need transport encryption where required, access controls, expiration, memory sanitization expectations and a clear retention policy. The performance test should include TLS if production will use it.

Valkey replication is asynchronous. Its documentation notes that acknowledgements do not turn the system into a strongly consistent CP database, even when clients use WAIT or WAITAOF to reduce the probability of loss.[5] That is usually acceptable for a recomputable cache, but the failure behavior should be explicit. A miss should trigger prefill, not fail the user request or return state from the wrong model, adapter or prompt.

Cache keys therefore need more than a conversation identifier. They should incorporate everything that changes the computed tensors: model and revision, tokenizer, adapter, relevant inference settings, tensor layout and the exact token prefix. An upgrade that changes any of those must not read incompatible state left by an older worker.

Valkey 9.2 helps operations, but its features have tradeoffs

The shared-cache work arrived alongside Valkey 9.2, which also changes the operational profile of the datastore. The release adds optional forkless RDB snapshots and full synchronization. Traditional fork() snapshots use copy-on-write memory; under heavy writes, changed pages can drive a large temporary memory increase. Forkless mode performs snapshot work in a background thread and reserves four additional bytes per key.[1][6]

Forkless is not an automatic win. It is disabled by default, writes can briefly wait, and latency may rise during an operation. Valkey can fall back to fork() when a loaded module lacks support, during some slot migrations, when an older replica connects, or when replication compression is enabled for a full sync. AOF rewrites still use fork().[6] Operators must watch the reported save type and fallback counters rather than assuming a configuration flag proves the process never forked.

Version 9.2 also supports compression for continuous replication and RDB streams. In one project benchmark, LZ4 cut replication bandwidth by 52% with less than 1% throughput overhead, but the result came from three million keys of about 315 bytes each.[1] KV-cache chunks are far larger and have different compressibility, so the same ratio should not be carried into an inference design.

For a cache tier, persistence itself is a policy choice. Rebuilding state after a restart costs GPU time but may be safer and simpler than retaining conversation-derived tensors on disk. If the service is explicitly disposable, persistence can be omitted with the understanding that a cold restart will cause a recomputation wave. If snapshots or replicas are used to soften that wave, disk encryption, deletion and backup retention join the threat model.

How to decide whether shared L2 is worth running

Start with traces from the real workload. Measure prefix reuse, context lengths, time between turns, local cache eviction, prefill time, first-token latency and the fraction of requests that land on a worker without the needed state. Average prompt length alone says little. A large one-shot summarization workload may have almost no reusable prefix, while a smaller multi-turn support fleet can reuse the same instructions and history repeatedly.

Estimate the working set over the period in which users return. The basic KV footprint is the number of layers multiplied by KV heads, head dimension, bytes per element and two tensors, then multiplied by tokens. Add overhead and enough room for uneven tenant behavior. Set a TTL and an eviction policy deliberately. Valkey defaults to noeviction, while the published LMCache setup notes that TTL is off by default. A full cache that rejects writes is a poor surprise during a traffic peak.[2]

Benchmark three paths: local hit, remote hit and full recompute. Run them at ordinary and peak concurrency. A remote hit that looks fast in isolation may compete with model traffic on the same network interface under load. Track bytes retrieved per hit, cache-service CPU, shard bandwidth, hit rate by context size, first-token latency percentiles and GPU prefill utilization.

Test failure rather than only throughput. Stop a cache shard, restart LMCache, remove a GPU worker and rotate the model version. Confirm that each event degrades to recomputation and does not hang requests. The reference cookbook warns that its vLLM replicas do not reconnect automatically after the standalone LMCache server restarts; they must be restarted as well.[4] That behavior may change, but it is exactly the kind of lifecycle edge an evaluation should expose.

Finally, compare the cache bill with the GPU time it saves. Include memory nodes, network transfer, replicas, operational labor and the capacity margin needed for bursts. Shared L2 is compelling when expensive GPUs repeatedly prefill long, reusable context and local caches churn. If prompts are short, unique or already sticky enough to remain local, the plain design may still be the better one.

A cache tier, not free compute

The useful part of this release is architectural. KV state can become fleet infrastructure instead of disposable memory owned by one inference process. Open components now make that design easier to test without tying the serving layer to one proprietary cache service.[2][3][4]

It also puts a distributed memory system directly in the first-token path. That demands the same work as any production data tier: capacity models, placement, encryption, versioned keys, metrics, failure tests and cost accounting. Teams that skip those details can spend money moving tensors around only to discover that their traffic rarely reuses them.

For long-context, multi-turn serving, the economics are plausible and the early numbers are strong. They are still workload-specific numbers from the projects building the stack. The sensible next step is a replay of real request shapes with remote hits, misses and failures separated in the results. If shared L2 wins that test, it can turn stranded context into usable fleet capacity. If it does not, recomputation may be cheaper than another distributed system.

Sources

  1. Linux Foundation: Valkey 9.2 and distributed KV caching
  2. Valkey: KV caching on Valkey benchmark and design
  3. LMCache documentation: architecture and supported tiers
  4. Valkey and LMCache shared-cache reference cookbook
  5. Valkey documentation: replication behavior and consistency
  6. Valkey documentation: forkless operations

QuantumBytz Team

The QuantumBytz Editorial Team covers cutting-edge computing infrastructure, including quantum computing, AI systems, Linux performance, HPC, and enterprise tooling. Our mission is to provide accurate, in-depth technical content for infrastructure professionals.

Learn more about our editorial team