Knowledge note

Lightning Indexer

A lightweight learned selector that scores visible token or block candidates and returns the top-k indices used by core sparse attention.

Updated September 16, 2026Confidence: High

Lightning Indexer

Lightning Indexer is a lightweight learned selector that scores visible token or block candidates and returns the top-k indices used by core sparse attention.

Why It Exists

Sparse attention saves core compute only after deciding which parts of the context matter. Without a content-dependent selector, attention must either scan every token in the expensive main branch or rely on a fixed mask that can miss distant evidence. The Lightning Indexer supplies that routing decision for token-level DSA and compressed-block variants.

How It Works

For each query token, small indexer query and key projections score all visible candidates. DeepSeek-V3.2 DSA selects individual token positions; DeepSeek-V4’s compressed sparse attention scores compressed candidates and combines multiple indexer heads before top-k. Core attention then runs only over the selected positions. Because selection depends mainly on score ordering, serving frameworks can quantize the indexer cache and query to 8 bits—such as INT8 with per-token-head scales or FP8 on Ascend A5—while aiming to preserve the ranking.

Tradeoffs

The indexer is a heuristic: quantization or close score margins can reorder borderline candidates and change the top-k set. Its per-pair work is much smaller than main attention, but a full-prefix scan still has quadratic prefill complexity and linear-per-token decode cost. IndexCache reports that repeating this scan at every layer can dominate long-context prefill.

Common Confusions

  • Token-level vs. compressed-block selection: DeepSeek-V3.2 DSA selects token positions, while later compressed-attention designs select compressed entries or blocks. Both use a learned, query-dependent indexer rather than a fixed mask.
  • Indexer vs. MoE router: a router selects experts per token to reduce FFN compute; the indexer selects KV blocks per query to reduce attention compute.
  • C4 vs. C8: “C8” is the 8-bit quantization of the indexer cache and query implemented in vllm-ascend today; a 4-bit “C4” indexer quantization is not implemented yet (planned future work). Separately, “c4” is the DSV4 layer type (compress ratio 4) that owns an indexer.

Where It Appears

  • KV Cache — The attention state the indexer selects blocks from.
  • Cross-Layer Index Reuse — Reuses one indexer’s selected positions across several sparse-attention layers.
  • Mixture of Experts — A router-based sparse selection mechanism for FFN capacity, often confused with attention indexers.