# Position-Skipped Distillation of Sparse-Attention Indexers: Train Short, Serve Long

> Position-skipped distillation trains sparse-attention indexers on short sequences with position-ID gaps, matching 32K-distilled quality at 3–6× lower training cost.

- **Source:** [arXiv](https://arxiv.org/abs/2611.29664)
- **Published:** 2026-11-28
- **Permalink:** https://picx.dev/p/O2YxQ4
- **Whiteboard:** https://picx.dev/p/O2YxQ4/image

## Summary

# 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 $R$ 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 $k$ tokens by score.

### Two Key Costs of Indexers

1. **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.
2. **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):

$$\Phi_p \text{ rotates the first } d_r \leq d \text{ coordinates in } d_r/2 \text{ planes; plane } i \text{ is rotated by angle } p\theta^{-2i/d_r}$$

Since $\Phi_{\pi_t}^\top \Phi_{\pi_s} = \Phi_{\pi_s - \pi_t}$, the score depends on positions only through ID differences. When an indexer is distilled on $T$-token sequences, it only observes rotary-relative positions for distances up to roughly $T$. 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 $H$ query heads and one shared key per token:

$$\kappa_{s} = \Phi_{\pi_{s}} \mathrm{LN}(W_{K} h_{s}), \qquad q_{t, j} = \Phi_{\pi_{t}} (W_{Q} h_{t})_{j}, \qquad w_{t, j} = \frac{1}{\sqrt{H}} (W_{w} h_{t})_{j}$$

The indexer score is a weighted sum of rectified per-head similarities:

$$I_{t,s} = \sum_{j=1}^{H} w_{t,j} \operatorname{ReLU}\left(\frac{1}{\sqrt{d}} q_{t,j}^{\top} \kappa_{s}\right)$$

### Distillation Objective

For each query $t$, the target is the normalized head-summed dense attention:

$$p_{t,s} = \sum_{g} a_{t,s}^{(g)} \Big/ \sum_{s'} \sum_{g} a_{t,s'}^{(g)}$$

The training loss is:

$$\mathcal{L} = \frac{1}{T} \sum_{t=1}^{T} \mathrm{KL}\Big(p_{t,\cdot} \left\| \operatorname{softmax}_{s \leq t} I_{t,s} \right.\Big)$$

## 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 $c \sim \mathrm{Unif}([T/4, 3T/4])$ and an offset $u \sim \mathrm{Unif}(\{0, \dots, R - T\})$, then define:

$$\pi_{i} = \left\{ \begin{array}{ll} i, & i < c, \\ i + u, & i \geq c. \end{array} \right.$$

The text remains contiguous; only the position IDs contain a gap. Cross-chunk distances increase by $u$, exposing the indexer to all relative distances up to $R$.

**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 $L > R$, compress position IDs by $\rho = R/L$:

$$\kappa_{s} = \Phi_{\rho\pi_{s}} \mathrm{LN}(W_{K} h_{s}), \qquad q_{t,j} = \Phi_{\rho\pi_{t}} (W_{Q} h_{t})_{j}, \qquad \rho = \min(1, R/L)$$

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 $b$ bits per coordinate with a per-token scale:

$$\alpha_{s} = \frac{\max_i |\kappa_{s,i}|}{\gamma_{b}}, \quad \tilde{\kappa}_{s,i} = \mathrm{round}(\kappa_{s,i} / \alpha_{s}) \in \{-\gamma_{b}, \ldots, \gamma_{b}\}$$

where $\gamma_b = 2^{b-1} - 1$ is the maximum code magnitude.

**Fused integer scan**: Due to the positive homogeneity of ReLU, quantization scales factor out:

$$I_{t,s} \approx \alpha_{s} \sum_{j=1}^{H} \left(w_{t,j} \beta_{t,j} / \sqrt{d}\right) \operatorname{ReLU}\bigl(\tilde{q}_{t,j}^{\top} \tilde{\kappa}_{s}\bigr)$$

The inner product is an exact integer dot product between an 8-bit query vector and a $b$-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 $\mathcal{S}$ (including layer 0); remaining layers reuse selections from the closest preceding indexed layer. Similarity is measured via Jaccard overlap:

$$J_{\ell\ell'} = \frac{|S_t^{(\ell)} \cap S_t^{(\ell')}|}{|S_t^{(\ell)} \cup S_t^{(\ell')}|}$$

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**: $H = 16$, $d = 64$, $d_r = 32$, $\theta = 10{,}000$
- **Training data**: FineWeb-Edu; **Evaluation**: PG-19 (perplexity), RULER (retrieval)
- **Compared indexers**: SHORT-8K, LONG-32K, LONG-64K, SKIP-R (with range $R \in \{32K, 64K, 128K\}$)

### Q1: Intrinsic Cost of Top-k Selection

With $k = 2048$, 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 $k = 512$, it reaches 1182% ∆PPL with recall 0.13. **Position compression largely restores performance**: at 32K with $k = 2048$, 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 $k = 2048$, 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 $k = 2048$ (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

1. **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.

2. **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.

3. **Quantization without retraining**: The positive homogeneity of ReLU allows exact factorization of quantization scales, enabling post-hoc compression without quality loss at $k = 2048$.

### Practical Implications

1. **Training cost reduction**: Position-skipped distillation reduces training compute per token by 3–12× compared to serving-length distillation, with minimal quality loss.

2. **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 $k = 2048$.

3. **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 $k = 2048$, 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

---

_Markdown view of https://picx.dev/p/O2YxQ4, served by PicX — AI-generated visual whiteboard summaries of research papers._
