Compressed Sparse Attention 2 (CSA2)
- CSA2 is an attention structure that compresses key/value sequences to fewer positions, selecting top-$k$ entries via learned indexing for sparse attention, reducing computational demand.
- To identify compressed positions, it utilizes a lightning-indexer scoring system that produces query vectors and associated weights for a top-$k$ selection
- Output combines selected top-$k$ entries with a recent local window, evaluating subsequent sparse attention operations only on the selected entries
Compressed Sparse Attention 2 (CSA2) is a compressed-attention architecture in which a learned indexer scores compressed key positions, selects the top- candidates for each query, and applies sparse attention only to the selected entries, typically together with a recent local window. The supplied research record does not provide a paper that formally defines a separately named “CSA2” specification. The closest explicit formulation is the Compressed Sparse Attention (CSA) mechanism attributed to DeepSeek-V3.2 and V4, including V4-Flash and V4-Pro, while several related works provide alternative hardware, representation, and routing strategies for compressed or sparse attention (Jaber et al., 4 May 2026).
1. Conceptual foundations
Dense self-attention computes query, key, and value projections followed by all pairwise query–key interactions:
For a sequence of length , the score computation and attention storage have quadratic dependence on sequence length. This dependence is especially problematic for long-context LLMs and video diffusion Transformers. Sparse attention addresses the problem by restricting each query to a subset of keys, but the effectiveness of such a system depends on the representation and retrieval mechanism used to identify that subset.
Compressed sparse attention introduces a compressed key/value sequence with fewer positions than the original sequence. Let denote the original sequence length, the compression ratio, and
the number of compressed positions. The compressed key tensor is
where is batch size and is the indexer-head dimension. Compressed values are consumed by the subsequent sparse-attention kernel.
The compressed representation serves two distinct purposes. First, it provides a coarse representation of the history. Second, it provides an address space over which the indexer can perform query-dependent retrieval. Selected compressed positions can then identify corresponding full-resolution or compressed key/value entries for sparse attention.
CSA2 should therefore be distinguished from methods that merely compress model parameters or attention weights. CASP, for example, compresses Query and Key projection matrices through data-aware low-rank factorization and quantization; it does not remove runtime query–key interactions or construct a sparse attention matrix (Gholami et al., 7 Mar 2025). Likewise, affine-compressed-sparse-row representations and GPU code generation target regular sparse masks and kernel efficiency rather than the learned compressed-key retrieval mechanism associated with CSA (Gupta et al., 2024).
2. Indexer and top-0 retrieval
The defining operation in the V4-shaped CSA formulation is a learned lightning-indexer score. The indexer produces query vectors
1
where 2 is the number of indexer heads, together with head weights
3
For query position 4, compressed-key position 5, and indexer head 6, the score is
7
Equivalently, with explicit batch and feature indices,
8
The resulting score matrix has approximately shape 9 after reduction over indexer heads. For every query, CSA selects a top-0 set over legal compressed-key positions:
1
The cited V4-shaped configurations use 2 for V4-Flash and 3 for V4-Pro (Jaber et al., 4 May 2026).
Causal legality limits the candidate set. For compression ratio 4, the number of legal compressed positions for query 5 is
6
and the effective selection count is
7
When fewer than 8 legal positions exist, the output is padded with 9. The causal condition is
0
The selected indices are passed to a sparse attention kernel. The downstream support commonly consists of the retrieved top-1 positions together with a recent local window:
2
The sparse attention operation then evaluates query–key scores and value aggregation only over 3.
3. Memory complexity and streaming index construction
A central implementation problem is the intermediate tensor produced by a naïve indexer. The reference path materializes the head-wise score tensor
4
For FP32 scores, its storage is
5
With 6, 7, 8, and 9, the tensor contains approximately 256 GB under binary accounting. At 0, the intermediate is approximately 1 TB, and at 1 it is approximately 4 TB. The materializing implementation runs at 2 on a single H200 but runs out of memory at 3 (Jaber et al., 4 May 2026).
StreamIndex removes this materialization by computing scores in query and compressed-key tiles and performing a partition-merge top-4 reduction. For a fixed query, the indexer score is separable over compressed-key positions. Therefore,
5
Only the local top-6 candidates from each partition can belong to the global top-7 result.
For query-tile size 8 and compressed-key-tile size 9, the score tile has shape
0
The implementation maintains running values and indices,
1
and merges every tile’s local candidates into the running top-2 state. The score-buffer complexity changes from
3
to
4
with an additional running-buffer cost of approximately
5
per query tile and a final output of shape 6.
The method must merge candidates from every key tile. Skipping tiles with 7 causes severe recall failure because a small tile may contain globally important candidates. Production execution uses FP32 score accumulation; FP16 accumulation reduces memory and can be faster but changes boundary comparisons near the top-8 threshold.
On a single NVIDIA H200, StreamIndex runs the V4-Flash-shaped indexer from sequence length 32K through 1,048,576 with 6.21 GB peak HBM at the largest tested length, whereas the materializing path runs out of memory at 65K. The reported runnable regime therefore extends by 32 times. These results concern the indexer step and do not establish complete end-to-end model equivalence or a faster sparse-attention kernel (Jaber et al., 4 May 2026).
4. Sparse execution substrates and representations
CSA2-style retrieval is an algorithmic interface rather than a single hardware implementation. The selected index list must be consumed by a sparse attention kernel capable of irregular key/value gathers, causal masking, and value aggregation.
SPLAT addresses a different but related regime: moderately sparse masks with regular geometric structure. Its affine-compressed-sparse-row format stores nonzero values and per-row affine metadata rather than one column index per nonzero. This can reduce metadata traffic for windowed, blocked, and strided masks, but it does not naturally represent arbitrary dynamic top-9 selections (Gupta et al., 2024). A CSA2 implementation with irregular query-dependent retrieval would therefore require a more general index representation than ACSR.
CPSAA demonstrates a processing-in-memory approach to dynamic unstructured sparse attention. It uses ReRAM crossbars for vector–matrix operations and ReCAM arrays as mask schedulers. Its decomposition follows the sparse-attention pipeline
0
The architecture emphasizes that sparse execution must account for index representation, scheduling, memory placement, gather/scatter behavior, and write costs rather than merely eliminating zero arithmetic (Li et al., 2022). This principle applies directly to CSA2, where top-1 indices can otherwise create irregular memory traffic.
Self-Indexing Attention proposes a different representation strategy. It applies a randomized Hadamard transform and stores transformed keys as sign–magnitude representations. The packed sign vector acts simultaneously as retrieval metadata and part of the compressed key payload. Retrieval uses thresholded sign agreement multiplied by key norm:
2
where 3 is the number of matching transformed sign coordinates. This one-bit index can support prefill selection, decode retrieval, and compatibility with external KV-cache compression (Yang et al., 16 Aug 2026).
The SIA design is compatible with a CSA2-like system when the sparse-attention kernel accepts token indices and the KV representation permits random access to selected compressed entries. Its principal architectural distinction is that the retrieval index is embedded in the compressed key representation rather than stored as separate index metadata.
5. Related compressed and adaptive attention mechanisms
CSA2 belongs to a broader design space that includes fixed sparse patterns, dynamic routing, compressed-token attention, hybrid sparse–linear attention, and compression-guided selection.
Native Sparse Attention decomposes causal attention into local sliding-window, compressed, and selective branches. The compressed branch attends to block-level summaries, while the selective branch scores compressed blocks and retrieves a top-4 set of full-resolution blocks. Alternating Sparse Attention modifies this organization by alternating local and global layers and introducing Multi-head Latent Attention in local layers and Grouped-head Latent Attention in compressed/selective layers. Its global branch is closely related to compressed sparse attention, but the paper does not identify ASA or NSA as CSA2 (Hu et al., 2 Nov 2025).
SLA, or Sparse–Linear Attention, partitions attention weights into critical, marginal, and negligible categories. Critical blocks receive exact sparse attention, marginal blocks use a linear-attention compensation path, and negligible blocks are skipped. The approach uses pooled query/key blocks, top- and bottom-ranked block selection, online softmax for critical blocks, and a fused GPU kernel. Its reported video configuration reduces attention computation by approximately 95%, but it requires fine-tuning and does not implement the same compressed-key lightning-indexer formulation (Zhang et al., 28 Sep 2025).
Compression-guided attention based on gzip uses compression ratios as a deterministic, parameter-free routing signal. Blocks with ratios above the sequence mean are classified as literal or non-redundant, and long-range attention is routed among them, while local windows provide guaranteed nearby connectivity. The method uses compression to construct a mask rather than to create compressed key/value representations. It is therefore a possible compression-based sparse-attention variant, but it does not establish formal identity with CSA2 (Kundu et al., 23 Jul 2026).
CASP exploits the observation that multimodal attention is concentrated and sparse, but it uses that observation to compress Query and Key weights through low-rank decomposition and quantization. It does not provide a runtime sparse attention indexer. Its role in a CSA2 system would be complementary: Q/K parameter compression could reduce projection cost while CSA2 reduces token-pair attention cost (Gholami et al., 7 Mar 2025).
6. Limitations, scope, and terminology
The available research does not establish a formally distinct CSA2 specification. The explicit CSA formulation described for DeepSeek-V3.2 and V4 is the closest source, while StreamIndex targets the memory bottleneck of its V4-shaped indexer. Accordingly, statements that equate CSA2 with a particular model, checkpoint, score equation, or kernel should be treated cautiously unless the external CSA2 specification defines those details.
Important implementation limitations include the following:
- Indexer-specific validation: StreamIndex validates selected-index parity and memory behavior, not complete model logits, perplexity, retrieval quality, or downstream task accuracy on a real V4 checkpoint.
- Synthetic evaluation: the main StreamIndex inputs are synthetic but designed to match the variance of the V4 post-projection pipeline. No real V4-Flash checkpoint is loaded.
- Tie behavior: formal exactness assumes a strict score–index ordering, whereas the implementation uses
torch.topk, whose tie-breaking is unspecified. The reported guarantee is therefore empirical set parity rather than guaranteed positional ordering. - Precision dependence: FP32 accumulation provides the reported parity behavior. FP16 accumulation changes candidate ordering near the top-5 boundary.
- Memory–recomputation trade-off: streaming removes the large quadratic intermediate but rereads queries, compressed keys, and indexer weights across tiles. It does not eliminate total logical score computation.
- Sparse-kernel dependence: indexer speedups do not automatically imply proportional end-to-end gains. Sparse attention still requires irregular gathers, top-6 handling, causal filtering, and value aggregation.
- Representation compatibility: compressed-key layouts, external KV compressors, indexer dimensions, compression ratios, causal conventions, and downstream sparse-attention interfaces must agree.
- Training scope: StreamIndex evaluates forward indexing and does not establish backward support or training-time behavior. SIA is training-free in its reported use, while SLA requires fine-tuning because its linear branch changes the attention operator.
- Dynamic sparsity: regular sparse formats such as ACSR are efficient when masks have affine geometry, but arbitrary content-dependent top-7 patterns require general coordinate lists or specialized index structures.
The most defensible technical characterization is therefore:
8
Within this framework, StreamIndex provides a memory-bounded streaming top-9 implementation of the indexer, SIA provides a self-indexing binary key representation, CPSAA provides a processing-in-memory execution perspective, SPLAT provides geometry-aware sparse-kernel techniques for regular masks, and NSA/ASA provide compressed and selective long-context attention branches. None of these related works, except the V3.2/V4 CSA description itself, formally defines a separately named CSA2 method.