Position-Skipped Distillation of Sparse-Attention Indexers: Train Short, Serve Long
Summary (Overview)
- Core problem: Training sparse-attention indexers via distillation requires sequences as long as the target serving context, making each training step expensive due to dense attention at serving length.
- Key finding: When indexers are distilled on short sequences, their failure to generalize to longer contexts is driven primarily by rotary positional encoding (RoPE) rather than degraded content matching.
- Main contribution: Position-skipped distillation trains indexers on short sequences with randomly placed position-ID gaps, exposing them to all relative distances up to a target range while keeping the teacher model on short sequences.
- Secondary contribution: A compact index representation using 3–4-bit quantized keys with a fused integer scan kernel, achieving 1.6–2.2× faster scanning than half-precision without retraining.
- Key result: An indexer distilled on 8K-token sequences with position-skipped distillation matches a 32K-distilled indexer within ~0.5 perplexity up to 32K on DeepSeek-V2-Lite and Qwen3-30B-A3B, while reducing training compute by ~3–6×.
Introduction and Theoretical Foundation
Background
Modern language models deployed with contexts spanning hundreds of thousands of tokens face a dominant cost: dense attention over the full context during token generation. Top-k sparse attention addresses this by restricting attention to a small subset of cached tokens. In the design introduced by DeepSeek-AI (2025), each layer includes a lightweight learned scoring module (the indexer) that assigns scores to cached tokens; the layer then attends only to the top tokens by score.
Two Key Costs of Indexers
- Training cost: Distillation from dense attention requires sequences as long as the intended serving context. DeepSeek-AI (2025) report 1,000 steps with 16 sequences of 128K tokens each.
- Inference cost: Maintaining an index (one key vector per token per layer) and scoring it at every decoding step (a "scan").
Theoretical Foundation: The Positional Failure Mode
The indexer represents distance via rotary positional encodings (RoPE):
Since , the score depends on positions only through ID differences. When an indexer is distilled on -token sequences, it only observes rotary-relative positions for distances up to roughly . At larger distances, long-wavelength rotary components take unseen angles, yielding novel combinations and degraded selection.
The Indexer Architecture
The indexer uses multi-query attention with query heads and one shared key per token:
The indexer score is a weighted sum of rectified per-head similarities:
Distillation Objective
For each query , the target is the normalized head-summed dense attention:
The training loss is:
Methodology
1. Position-Skipped Distillation
The core idea: keep sequences short but perturb their position IDs, following positional skip-wise training (PoSE) (Zhu et al., 2024).
Position ID manipulation: For each training sequence, sample a cut point and an offset , then define:
The text remains contiguous; only the position IDs contain a gap. Cross-chunk distances increase by , exposing the indexer to all relative distances up to .
Teacher and student share position IDs: The frozen teacher model computes dense attention under the same modified IDs. This is well-defined because both dense attention and indexer scores depend on positions only through ID differences.
Position compression beyond the range: When serving with context length , compress position IDs by :
This is position interpolation (Chen et al., 2023) applied only to the indexer.
2. Compact Index Representation
Low-bit key quantization: Keys are quantized to bits per coordinate with a per-token scale:
where is the maximum code magnitude.
Fused integer scan: Due to the positive homogeneity of ReLU, quantization scales factor out:
The inner product is an exact integer dot product between an 8-bit query vector and a -bit key vector, implemented in a single GPU kernel with one thread per key.
3. Indexer Placement Across Layers
The indexer runs only in a subset of layers (including layer 0); remaining layers reuse selections from the closest preceding indexed layer. Similarity is measured via Jaccard overlap:
Two strategies: UNIFORM-n (evenly spaced) and GAPFILL-n (includes layer 0 and retrieval-critical layers identified by causal analysis).
Empirical Validation / Results
Experimental Setup
- Models: DeepSeek-V2-Lite (27 layers), Qwen3-30B-A3B (48 layers, MoE), Llama-3.1-8B (32 layers)
- Indexer config: , , ,
- Training data: FineWeb-Edu; Evaluation: PG-19 (perplexity), RULER (retrieval)
- Compared indexers: SHORT-8K, LONG-32K, LONG-64K, SKIP-R (with range )
Q1: Intrinsic Cost of Top-k Selection
With , ORACLE (perfect selection) increases perplexity by only 0.18% at 8K and 1.03% at 32K while retaining only 6% of the context.
Q2: Failure of Short-Training
SHORT-8K performs well at 8K but fails after a single length doubling: at 16K with , it reaches 1182% ∆PPL with recall 0.13. Position compression largely restores performance: at 32K with , SHORT-8K+COMPRESS achieves 1.71% ∆PPL versus 1098% for uncompressed SHORT-8K.
Q3: Position-Skipped vs. Serving-Length Distillation
Key results (Table 2, DeepSeek-V2-Lite, 400M tokens):
| Length | k | SHORT-8K | LONG-32K | SKIP-64K (ours) |
|---|---|---|---|---|
| 32K | 2048 | +1098 (.08) | +1.19 (.73) | +1.23 (.73) |
| 64K | 2048 | +2248 (.02) | +4.75 (.34) | +0.88 (.71) |
SKIP-64K matches LONG-32K within 0.37 ∆PPL points across 8K–32K. At 64K, SKIP-64K achieves recall 0.71 and ∆PPL 0.88% for , outperforming LONG-32K+COMPRESS (1.69%).
Matched 100M-token runs (Table 3):
| Model | SKIP-64K @64K | LONG-32K @64K | LONG-64K @64K |
|---|---|---|---|
| DeepSeek-V2-Lite | +1.11 (.64) | +5.80 (.26) | +1.10 (.68) |
| Qwen3-30B-A3B | +1.73 (.54) | +1.76 (.42) | — |
| Llama-3.1-8B | +2.21 (.65) | +4.26 (.32) | — |
SKIP-64K and LONG-64K are essentially indistinguishable on DeepSeek-V2-Lite (paired difference −0.01 points).
Training cost: Distillation at 32K, 64K, and 128K is 2.94×, 5.92×, and 11.69× more expensive per training token than skipped-ID training at 8K.
Q4: Recipe Components
- Position range: SKIP-32K, SKIP-64K, SKIP-128K agree within 0.44 points within their ranges; larger ranges don't harm short-context performance.
- Training tokens: Reducing from 400M to 100M tokens leaves SKIP-64K within 0.4 points.
- Position mechanism: Alternatives (ROPE-8, NOPE, DISTBIAS) all underperform SKIP-64K at 64K.
- Llama-3.1 at 128K: All indexers (and ORACLE) fail unless layers 0–1 remain dense; with layers 0–1 dense, SKIP-64K achieves 2.95% ∆PPL.
Q5: Compact Index Results
- 4-bit keys: Retain 0.995 of dense-attention mass at 32K; change ∆PPL by at most 0.05 points at (34 bytes/token vs. 128 for full precision).
- 3-bit keys: Retain 0.977 at 32K; increase ∆PPL by up to 0.46 points at 64K (26 bytes/token).
- Fused kernel: Scans 3-bit keys 1.6–2.2× faster than a 16-bit cuBLAS-based scan.
- Serving engine (vLLM): Speedups primarily for long contexts with multiple concurrent streams (e.g., 19% faster at 32K with 16 streams on Qwen3); slower for single-stream decoding.
Q6: Layer Placement
Jaccard overlap between neighboring layers ranges from 0.22 to 0.46 at 32K. With the indexer in only 8 of 27 layers, GAPFILL placement outperforms UNIFORM on perplexity (2.86% vs. 6.46% ∆PPL) but neither generalizes well to held-out RULER tasks.
Theoretical and Practical Implications
Theoretical Implications
-
Positional generalization is the bottleneck: The failure of short-trained indexers is primarily positional (RoPE rotations), not content-based. This isolates a specific failure mode in length extrapolation for learned ranking modules.
-
Distillation targets can be synthesized: By manipulating position IDs, one can create supervision signals for distances not present in the actual training text, enabling training on short sequences with long-range supervision.
-
Quantization without retraining: The positive homogeneity of ReLU allows exact factorization of quantization scales, enabling post-hoc compression without quality loss at .
Practical Implications
-
Training cost reduction: Position-skipped distillation reduces training compute per token by 3–12× compared to serving-length distillation, with minimal quality loss.
-
Memory savings: 4-bit keys reduce index storage to roughly one quarter of original (34 vs. 128 bytes per token), with no measurable perplexity increase at .
-
Deployment considerations: The indexer approach pays off primarily for multiple concurrent long-context streams; single-stream decoding may be slower. Early layers may require dense attention at very long contexts.
Conclusion
Position-skipped distillation trains sparse-attention indexers on 8K-token sequences while achieving perplexity within 0.5 points of serving-length distillation on two models and within 1.0 point on Llama-3.1, reducing training cost per token by at least 3×. At 64K, position compression of a 32K-distilled indexer matches or outperforms position-skipped variants on two of three models, suggesting the primary benefit is reduced training cost rather than improved quality. Four-bit key quantization preserves perplexity at , and decoding speedups in production primarily arise for long contexts under multi-stream concurrency.
Limitations and Future Directions
- Evaluation limited to models originally trained with dense attention
- Most configurations run only once
- First two layers still require dense attention at 128K on Llama-3.1
- LongBench v2 performance near chance on DeepSeek-V2-Lite
- Future work could explore joint training of indexers with long-context adaptation, adaptive layer placement, and further compression techniques
Related papers
- Self-WSP: Can Language Models Improve Themselves Through Weight-Space Programming?
A 0.8B model can self-improve by editing its own weights, quintupling GSM8K accuracy, but random edits match it, revealing search, not understanding, drives gains.
- Third Eye: Beyond Immediate Gains in Recursive Self-Improvement
Third Eye shows a model's immediate performance after self-update can look neutral while a further native update causes significant utility decline, varying by backbone.
- When Every Rollout Fails: Splicing Learner-Conditioned Options into Long-Horizon Agent RL
SPLICE recovers learning signal from all-fail RL groups by splicing local proposal-model options into failed trajectories, beating GRPO by up to 9.8 points with 17.5% less computation.