KV and Index Sharing for Long-Context Speculative Decoding
This article examines how KV sharing and index sharing align draft models with sparse-attention target models in long-context speculative decoding. It explains the problem of duplicated draft-side caches, the pairing design that lets draft layers read target-layer KV and reuse target indexer selections, the engineering flow with pseudocode, the memory/prefill/concurrency/compute benefits, and the practical limits around index coverage, layer mapping, gather latency, and cache consistency. Readers will learn when the approach pays off and what to measure before adopting it.
KV and Index Sharing for Long-Context Speculative Decoding
1. Background: Two Long-Context Optimization Paths Are Converging
The cost of long-context inference comes from two directions. First, attention computation and the KV cache grow with context length. Second, autoregressive decoding is serial per token and cannot fully use available compute.
To ease the first problem, a growing number of long-context models use native sparse attention: each layer maintains an indexer that selects a fixed number of historical positions for every query, instead of running dense attention over all past tokens. To ease the second, speculative decoding has become a common approach: a smaller draft model predicts several tokens at once, and the target model verifies them in parallel, raising the number of accepted tokens per step.
The difficulty is that these two paths do not naturally align on the draft side. The target model has already compressed its own KV cache through sparse attention, yet mainstream block-parallel draft models still maintain an independent context cache following the dense-model mindset: either a full cache or a sliding window. The better the target model becomes at compressing its KV, the more disproportionate that separate draft cache becomes as a share of total cache. It consumes GPU memory and also affects prefill workload, prefix cache hit rate, and batching efficiency under high concurrency.
Put differently, the draft model should only be responsible for “guessing the next block of tokens,” but it takes on the extra cost of “maintaining a second copy of the context.” In long-context settings this cost is amplified and becomes a bottleneck for scaling speculative decoding further.
2. Core Idea: Let the Draft Layers Consume the Target Model’s Cache and Selections
A simpler and more effective response to this problem is to observe that the target model already stores per-layer KV and has already chosen which positions each query should attend to. The draft model therefore does not need to maintain its own cache, nor repeat position selection. Draft layers can be paired one-to-one with target layers, and each draft layer reads the KV positions selected by that layer’s indexer directly from the target layer’s cache. The draft model keeps no context cache of its own and runs no index scoring. This design can be summarized as two kinds of sharing: KV sharing and index sharing.
KV sharing addresses where the cache comes from. Draft layers no longer maintain a full or sliding-window cache; they gather the required positions from the corresponding target layer’s KV cache by index. A single long-context cache then exists only on the target side, while the draft side produces only transient compute tensors, substantially reducing memory usage and cache-management complexity.
Index sharing addresses which positions to look at. Draft layers neither retrain nor run an indexer; they reuse the position selections the target layer’s indexer already made for the query. This removes draft-side scoring computation and avoids the extra error introduced when draft and target indexers disagree.
The key premise behind this idea is that the draft model guesses an entire block of tokens at once, so later tokens inside the block effectively rely on a position selection made one step earlier. In other words, the selection made at the block head or the previous step must approximately cover the key positions that each subsequent token would have selected on its own. Public material reports an observation on a specific long-context model: a selection made one step ahead still covers roughly ninety percent of what each subsequent token selects for itself. This coverage rate matters more than a raw benchmark score, because the whole method rests on this approximation. As long as the early selection overlaps heavily with later selections, reusing the target cache in the draft layer is effective; if coverage drops quickly, the larger the draft block, the more visible the accumulated error.
3. Architecture and Execution Flow
From an implementation standpoint, KV sharing and index sharing can be expressed in pseudocode like the following. The point is not the specific interfaces but the data flow: draft layers read target-layer caches by mapping and gather the positions chosen by the target indexer, while acceptance decisions still come from the target model during verification.
# Pseudocode: draft block generation and target model verificationdef draft_block(last_token, block_len, target_kv_cache, target_indexer, layer_map):h = embed(last_token)for draft_layer_id in draft_layers:target_layer_id = layer_map[draft_layer_id]# Reuse the target layer indexer's selection for the current positionselected_positions = target_indexer[target_layer_id].select(last_token.position)# Gather selected positions from the target KV cache; do not copy the whole cachekv_slice = target_kv_cache[target_layer_id].gather(selected_positions)# The draft layer only runs forward compute: no separate KV cache write, no index scoringh = draft_layer[draft_layer_id](h, kv_slice)draft_tokens = sample_block(h, block_len)return draft_tokensdef verify_and_update(draft_tokens, target_model, target_kv_cache, target_indexer):# The target model verifies the draft block in parallelaccepted, new_cache = target_model.verify(draft_tokens, target_kv_cache)# On acceptance, advance the target KV cache and index; on rejection, roll back to the last accepted positiontarget_kv_cache = new_cachetarget_indexer.update(accepted.positions)return accepted
This flow has several engineering implications.
First, the mapping between draft layers and target layers has to be designed. The most direct option is same-layer pairing, but actual models may differ in layer count, hidden dimension, and attention-head configuration, so the mapping strategy needs to be determined experimentally. A poor mapping causes draft layers to read semantically mismatched KV and lowers acceptance length.
Second, the gather operation can become a new performance hotspot. Indexer-selected positions are usually not a contiguous range, so the cache layout must support efficient indexed reads. If the target KV uses paged or blocked storage, draft reads should reuse data within the same page where possible and avoid extra copies.
Third, verification and rollback must stay consistent with cache updates. Once the target model accepts a draft block, the target cache and index advance; on rejection, they roll back to the last accepted position. Index sharing requires index state and KV state to move in sync, otherwise the next draft step reads stale positions.
4. Why the Benefit Grows with Context Length
The gains from KV sharing and index sharing are not a single point improvement; they compound along the inference path.
Memory is the first gain. With no independent context cache on the draft side, a long context saves one cache footprint that grows with length. For high-concurrency serving, that saving translates directly into more batching headroom or less frequent swapping.
Prefill is the second. The draft model no longer builds a cache pass over the full context, and prefix cache hit rate is easier to improve, because only the target-side state needs to be maintained while the draft side simply reads it as a consumer. This removes hit failures caused by two caches drifting out of sync.
Concurrency is the third. In long-context serving, a larger per-request cache footprint means fewer concurrent requests. Once the draft cache disappears, more requests fit in the same GPU memory and the scheduler sustains higher throughput more easily. Public material reports relative results where, at a 64K workload and matched single-user decode speed, two high-concurrency tests showed throughput roughly 62% and 81% higher. These figures come from specific settings and should not be extrapolated into SLAs for every service, but the direction is clear: the longer the context and the higher the concurrency, the more pronounced the benefit of shared caching.
Compute is the fourth. Index sharing removes index scoring from the draft side, cutting some forward computation and scheduling overhead. The per-layer share may not look large in isolation, but with block-parallel drafting across many layers in long context, the cumulative effect is hard to ignore.
Public experiments also show that, under the same training recipe, the number of accepted tokens per step is higher than a block-parallel draft baseline with an independent cache: about 3.9% to 10.5% relative improvement on general tasks, and about 10.0% to 31.5% on long-context and agentic tasks within 128K. These results should be read as relative gains of the method on specific models and workloads; production adoption still requires reproduction and evaluation against your own model structure, index coverage, and cache layout.
5. Adoption Checklist and Applicability Boundaries
The first thing to confirm is whether the target model exposes reusable per-layer KV and index selections. If the target model still uses dense attention, or the indexer does not expose selected positions, KV sharing and index sharing have no foundation. Next, assess structural compatibility between draft and target layers, including positional encoding, hidden dimension, attention-head count, and the layer mapping strategy. Then monitor index coverage: a larger block means more deviation for later tokens relying on an early selection, while a smaller block reduces the benefit of parallel token guessing. Block size, layer mapping, and training objective need to be tuned jointly.
Cache consistency also deserves attention. The target KV a draft layer reads must not be modified by another request or asynchronous task before verification; under high concurrency, cache lifetime and rollback boundaries must be explicit. Monitoring should cover at least accepted tokens per step, index coverage, gather latency, prefix cache hit rate, memory usage, throughput, and tail latency. The shared design only beats an independent cache reliably when index coverage is high enough and gather overhead stays controlled.
The applicability boundary is equally clear. The method suits inference scenarios where the target model already uses native sparse attention, long context dominates, and concurrency is high. For short contexts, dense attention, or cases where draft and target structures differ too much, the gains may be limited. Its essence is not simply reusing one cache, but turning the draft model from a dense small model that independently maintains context into a lightweight predictor that consumes the target model’s selection results. Understanding that distinction is what allows a correct assessment of the value and risk of this approach in long-context agentic scenarios.
