Sparse Speculative Decoding for Long-Context Inference: KV and Index Sharing
Sharing KV caches and sparse attention indices can reduce the overhead of speculative decoding in long-context inference. This article explains the limitations of independent draft-model caches, how shared context supports block prediction, and the cache management, layer alignment, and monitoring considerations needed to evaluate memory, latency, and throughput benefits.
1. Long-Context Inference Needs More Than a Larger Context Window
AI agents, code repository understanding, long-document question answering, and multi-turn conversations are pushing context lengths from a few thousand tokens to tens of thousands, and sometimes beyond 128K. The challenge is no longer simply whether a model can process that context. It is whether the inference system can still generate efficiently afterward.
With conventional dense attention, KV cache storage grows approximately linearly with context length, while attention computation over the full sequence approaches quadratic scaling. To reduce this cost, native sparse attention architectures use lightweight indexing modules at each layer. For each query, these modules select a fixed number of relevant positions or operate within a fixed selection budget, rather than attending to every historical token.
This reduces long-context attention costs, but it also creates new requirements for speculative decoding.
Speculative decoding uses a draft model to propose multiple tokens, which the target model then verifies in parallel. The goal is to reduce the number of sequential target-model decoding steps. However, conventional block-parallel draft models often follow dense-model designs and maintain their own context caches. If the target model already limits its effective attention scope through sparse indexing, a draft model that still stores a full or sliding-window cache can introduce substantial redundant overhead.
The key optimization is therefore not simply to increase draft-model capacity. It is to let the draft model reuse the target model’s context representations and sparse selections, reducing duplicate storage, indexing, and computation.
2. Why Independent Draft-Model Caches Become a Bottleneck
A block-parallel draft model proposes a block of candidate tokens for parallel verification by the target model. To keep those predictions consistent with the conversation or document, the draft model needs access to historical context. Two common approaches are:
- Full-context caching: The draft model stores the complete historical KV cache. This preserves context information but consumes substantial GPU memory, especially at long context lengths.
- Sliding-window caching: The draft model keeps only a recent portion of the context. This limits memory usage but loses distant information and can weaken long-range dependency modeling.
These approaches can be reasonable when the target model uses dense attention and also relies on broad KV access. With a native sparse attention target model, however, the mismatch becomes more pronounced. Each target layer reads only the positions selected by its indexing module, so its effective KV access scope is much smaller than the full context.
Maintaining a separate draft cache then creates three problems:
- An unfavorable memory balance. As the target model reduces its own KV-related footprint, the draft model’s independent cache can account for a disproportionately large share of memory.
- Additional prefill work. During initial processing of a long prompt, the draft model must build its own cache, increasing time to first token.
- Less effective prefix reuse. Separate caching systems complicate unified prefix caching and can weaken throughput gains under high concurrency.
Reducing—or eliminating—the draft model’s independent historical cache is therefore a central optimization for long-context speculative decoding.
3. The Core Approach: KV Sharing and Index Sharing
The target model already stores context KV representations and computes sparse attention indices. A draft layer can reuse these resources by pairing with a corresponding target layer, reading its KV cache, and attending only to its selected positions.
This approach has two components.
KV Sharing
Draft layers do not maintain separate historical KV caches. Instead, they reuse the KV cache of the corresponding target-model layer.
This removes the draft model’s additional long-context storage burden, bringing cache memory usage closer to that of the target model alone.
Index Sharing
Draft layers do not independently compute global sparse indices. They reuse the position sets produced by the target model’s layer-wise indexing modules.
Attention in the draft layers is restricted to those positions, aligning the draft model’s effective context scope with the target model’s sparse attention path.
Conceptually, the shared access pattern can be represented as follows:
for draft_step in range(block_size):hidden = draft_forward(hidden)for layer in range(num_layers):target_kv = target_kv_cache[layer]selected_idx = target_index_cache[layer]draft_hidden = draft_layer(hidden,kv=target_kv,index=selected_idx)
The draft model is no longer a fully independent, smaller context model. It behaves more like a lightweight prediction component attached to the target model’s context representations. Rather than rebuilding those representations, it uses the sparse view that the target model has already established.
4. Why Block Prediction Can Reuse Earlier Sparse Selections
A block-parallel draft model predicts multiple tokens at once. In principle, later tokens may require different attention positions from earlier tokens.
Recomputing global indices for every token would be expensive. Skipping selection entirely, however, could cause the draft model to diverge from the target model’s attention path.
The central assumption is that later tokens within a draft block can reuse sparse selections computed for an earlier token. In other words, a selection made one step ahead must still cover enough of the positions relevant to subsequent tokens in the block.
This coverage is essential:
- If coverage is poor, the draft model attends to unsuitable positions and its acceptance rate can fall.
- If coverage is high, one indexing operation can support multiple tokens, reducing indexing overhead.
The assumption is not universally valid. It depends on the training recipe, model architecture, and task distribution. Draft layers generally need to be trained or calibrated against the target model so that they maintain prediction consistency under shared indices.
Long-context and agent workloads often have relatively stable context structures, which can make earlier sparse selections more useful across a draft block. That benefit still needs to be validated for the intended workload.
5. System Benefits: From Memory Savings to Throughput
KV and index sharing can affect more than memory consumption. Their benefits can propagate across the inference pipeline.
Lower GPU Memory Pressure
Without a separate historical KV cache for the draft model, long-context memory usage stays closer to the target model’s baseline. The potential savings become particularly important for contexts on the order of 64K or 128K tokens.
Less Prefill Work
Processing a long prompt is already expensive. Building an additional draft-model cache extends that initial stage.
Shared caching allows draft layers to reuse the target model’s prefill results, reducing duplicate context processing.
More Effective Prefix Caching
A unified cache architecture is easier to integrate with prefix reuse. Multi-turn conversations, fixed system prompts, and recurring long-document templates can benefit from more effective cache hits, reducing time to first token.
Better Throughput Under High Concurrency
GPU memory capacity and cache management can limit concurrent serving. Removing the draft model’s separate cache can leave room for more simultaneous requests and make decoding schedules more flexible.
Longer Accepted Draft Sequences
Sharing sparse indices can better align draft predictions with the target model’s actual computation path. This can make more candidate tokens within a block acceptable to the target model.
That alignment may become more valuable as context length increases, but accepted-token gains should be measured rather than assumed.
6. Engineering Considerations for Deployment
Implementing this approach requires coordinated changes to the model, cache system, scheduler, and monitoring stack.
Cache Lifecycle Management
Target-model KV caches and index caches must be tied to each request’s lifecycle.
When draft layers read shared caches, the system must ensure that those caches have not been released prematurely. It must also prevent one request from reading another request’s cached data.
Draft-to-Target Layer Mapping
The relationship between draft layers and target layers must be explicit.
If the models have different layer counts, a mapping strategy is needed. Options include grouping layers by stage, aligning layers by attention type, or sharing caches only at selected layers.
Sparse Index Stability
Index sharing depends on sufficiently stable target-model selections. If the indexing module’s outputs vary sharply, the draft model may repeatedly use unsuitable positions.
A confidence check can help identify unstable selections. In those cases, the system can fall back to a local attention window or recompute the indices.
Block Size Versus Acceptance Rate
Larger blocks offer more potential speculative gain, but errors from index reuse can accumulate across the block.
Block size should therefore be adjusted to the workload. Short conversations may use smaller blocks, while long-document and agent tasks may support larger ones. The appropriate setting depends on measured acceptance behavior.
Observability
The most useful metrics include:
- Average accepted tokens per decoding step
- Draft-block acceptance rate
- Index-reuse coverage
- Time to first token
- Per-token decoding latency
- Prefix cache hit rate
- Peak GPU memory usage and supported concurrency
Together, these metrics show whether the design produces practical serving benefits rather than only theoretical savings.
7. Suitable Workloads and Limitations
This approach is most suitable when:
- Contexts are long.
- The target model already uses sparse attention.
- The draft model’s independent cache represents a substantial share of system cost.
Typical workloads include long-document summarization, code repository question answering, multi-turn agent tasks, and long-running conversations with persistent context.
There are also clear limits. If the target model uses dense attention, or if contexts are short, index sharing offers limited benefit. Tasks that are highly sensitive to distant details may suffer when a reused index set misses important positions. Such workloads may require more conservative block sizes or hybrid indexing strategies.
The method also depends on good alignment between draft and target layers. Insufficient draft-model training or a substantial shift in task distribution can lower acceptance rates.
For deployment tuning, index-reuse coverage and draft-block acceptance rate should therefore be treated as primary indicators.
8. Conclusion
Long-context inference optimization is shifting from expanding the context window to reducing the system cost per generated token. Native sparse attention reduces the target model’s attention workload, but an independently cached draft model can still become a memory and scheduling bottleneck.
KV sharing and index sharing address that mismatch by allowing draft layers to reuse the target model’s context cache and sparse selections. The potential benefits extend beyond GPU memory savings to reduced prefill work, more effective prefix reuse, and higher throughput in long-context, high-concurrency serving.
A practical evaluation should begin with index-reuse coverage, then measure block acceptance, and finally assess memory, latency, and concurrency for capacity planning. Efficient long-context inference depends on optimizing the algorithm, cache architecture, and scheduler together.
