COBS: Cumulant Order Block Sparse Attention

Summary (Overview)

  • Core problem: Block sparse attention is hardware-friendly for reducing KV cache read bottlenecks in LLMs, but is underused in leading open-weight models. The paper studies why via DeepSeek's Native Sparse Attention (NSA) as a representative method.
  • Key theoretical contribution: Block selection reduces to ranking blocks by their attention mass (sum of a block's softmax scores). An oracle selector (OSA) using exact masses essentially matches dense attention (0.9010 vs 0.9040 mean RULER score), proving the criterion is sound — the challenge is estimating mass from a cacheable summary.
  • Main limitation of existing selectors: Via a cumulant expansion of the block mass, the authors show existing selectors (NSA MLP, mean-pool, Quest) are confined to first-order approximations in the query, discarding the within-block key covariance that supplies the second-order curvature term 12qΣbq\frac{1}{2} q^\top \Sigma_b q.
  • Proposed method (COBS): Stores a compressed second-order statistic per block — the within-block key covariance Σb\Sigma_b in low-rank, query-subspace-projected, FP4-quantized form — raising the cumulant order of the cached summary while respecting the cacheability constraint.
  • Empirical results: COBS (subspace s85s \approx 85, r=4r=4, FP4) raises the 11-task 32k RULER mean score from 0.2999 (NSA baseline) to 0.8195, closing ~86% of the gap to dense attention (0.9040), while using only 1.21× the NSA baseline's KV cache read traffic and 15.15× less than dense.

Introduction and Theoretical Foundation

Background

Transformer inference at long context is bottlenecked by KV cache reads: at each decode step, attention reads the keys and values of every past token, making decoding memory-bandwidth-bound rather than compute-bound. Sparse attention reduces this by reading only a fraction of past tokens.

Sparse attention methods differ in what they keep and how they choose it:

  • Fixed-pattern: Longformer, BigBird (local windows + global tokens)
  • KV-eviction: StreamingLLM, H2O, SnapKV (drop low-importance tokens)
  • Low-rank: compress keys themselves
  • Query-aware block selectors: Quest, NSA — summarize contiguous blocks offline, then run fine-grained attention over the highest-scoring blocks

Block sparsity is the most hardware-friendly form (contiguous memory accesses, smaller top-k), yet it is largely absent from leading open-weight LLMs, which instead use dense GQA, latent KV compression (MLA), local windows with global layers, or fine-grained token selection (DSA).

Theoretical Foundation

The paper studies NSA, which has three branches: (i) a compression branch over pooled block representations, (ii) a selection branch that ranks blocks by a lightweight score and runs fine-grained attention over the top-k, and (iii) a sliding-window branch. The selection branch is the focus: it alone determines which blocks fine-grained attention sees, and its scoring summary must be cached.

A selector is cacheable if its per-block summary can be precomputed and stored independently of the decode query qq — e.g., any function of the block's keys alone. This constraint makes the cumulant order of the stored summary the binding limitation.

Methodology

The Selection Oracle (Section 3)

The oracle formalizes block selection as reconstructing dense per-head attention outputs from a top-k block subset. With block masses mbm_b and value centroids vbcv_b^c defined as:

sr=qkr,mb=rbesr,vbc=1mbrbesrvrs_r = q^\top k_r, \qquad m_b = \sum_{r \in b} e^{s_r}, \qquad v_b^c = \frac{1}{m_b} \sum_{r \in b} e^{s_r} v_r

The dense head output is a PbP_b-weighted mixture of centroids (Pb=mb/ZP_b = m_b/Z). The exact per-head reconstruction error from dropping blocks is:

oo^S=11τbScPb(vbco)o^\star - \hat{o}_S = \frac{1}{1-\tau} \sum_{b \in S^c} P_b \left(v_b^c - o^\star\right)

Under three assumptions (value-agnosticism, disregarding per-head constants, and linear relaxation of the per-head penalty), minimizing the GQA selection objective reduces to ranking blocks by:

scoreb(h)=g=1Gmb(g,h)Z(g,h),Z(g,h)=bmb(g,h)\boxed{\text{score}_b^{(h)} = \sum_{g=1}^{G} \frac{m_b^{(g,h)}}{Z^{(g,h)}}, \qquad Z^{(g,h)} = \sum_{b'} m_{b'}^{(g,h)}}

This is the mass criterion. OSA (Oracle Sparse Attention) applies this with exact masses (reading all keys), serving as a diagnostic that essentially matches dense attention.

The Cumulant Expansion (Section 4)

The block mass is LL times the moment generating function of the block's empirical key distribution:

mb=LEr[eqkr]=LMX(q)m_b = L \cdot \mathbb{E}_r\left[e^{q^\top k_r}\right] = L M_X(q)

so lnmb=lnL+KX(q)\ln m_b = \ln L + K_X(q) where KXK_X is the cumulant generating function. The multivariate cumulant expansion is:

KX(q)=qκ1+12qκ2q+16ijk(κ3)ijkqiqjqk+K_X(q) = q^\top \kappa_1 + \frac{1}{2} q^\top \kappa_2 q + \frac{1}{6} \sum_{ijk} (\kappa_3)_{ijk} q_i q_j q_k + \dots

with first two cumulants:

κ1=kˉb=1Lrbkr,κ2=Σb=1Lrb(krkˉb)(krkˉb)\kappa_1 = \bar{k}_b = \frac{1}{L} \sum_{r \in b} k_r, \quad \kappa_2 = \Sigma_b = \frac{1}{L} \sum_{r \in b} (k_r - \bar{k}_b)(k_r - \bar{k}_b)^\top

COBS Method (Section 5)

Second-order truncation gives the core estimator:

lnmblnL+qkˉb+12qΣbq\ln m_b \approx \ln L + q^\top \bar{k}_b + \frac{1}{2} q^\top \Sigma_b q

The first-order term qkˉbq^\top \bar{k}_b is mean-pooling over block keys; the second-order term 12qΣbq\frac{1}{2} q^\top \Sigma_b q is the curvature that mean-pooling omits.

Covariance compression (for D>LD > L): low-rank spectral decomposition keeping the top rr eigendirections:

Σbi=1rλiuiui=i=1rξifs(ξifs),ξifs=λiui\Sigma_b \approx \sum_{i=1}^{r} \lambda_i u_i u_i^\top = \sum_{i=1}^{r} \xi_i^{\text{fs}}(\xi_i^{\text{fs}})^\top, \qquad \xi_i^{\text{fs}} = \sqrt{\lambda_i} u_i

Subspace method: project covariance into the ss-dimensional query subspace (UQU_Q holds top ss eigenvectors of E[qq]\mathbb{E}[qq^\top]):

Bb=UQΣbUQRs×sB_b = U_Q^\top \Sigma_b U_Q \in \mathbb{R}^{s \times s}

with the projected quadratic form qΣbqq~Bbq~q^\top \Sigma_b q \approx \tilde{q}^\top B_b \tilde{q} where q~=UQq\tilde{q} = U_Q^\top q.

Quantization: FP4 (E2M1) with one fp32 scale per eigenvector; block mean kept at bf16.

Per-decode-step scoring cost: O(rs)O(rs) per block (plus one O(sD)O(sD) query projection shared across all blocks) vs. O(D)O(D) for mean-pool.

Gram trick for eigenvector computation: avoids materializing the full D×DD \times D covariance by using the L×LL \times L Gram matrix 1LK~K~\frac{1}{L}\tilde{K}\tilde{K}^\top.

Empirical Validation / Results

Setup

  • ≈1.2B parameter decoder-only transformer, 16 layers, model dim 2048, 16 query heads, 4 KV heads (GQA), head dim D=128D = 128, RoPE with base θ=106\theta = 10^6
  • Pretraining: LongCrawl64 for ≈20B tokens at 4k sequence length, then YaRN extension to 32k with RULER-style SFT
  • NSA branches: L=32L = 32-token blocks, top-k = 16, 256-token sliding window

Headline Results (32k RULER)

Table 1: 11-task 32k RULER breakdown (gap closed measured from NSA MLP RoPE 0.2999 to dense 0.9040):

MethodMeanGap closedS1S2S3MK1MK2MK3MQMVCWEFWEVT
Dense (full attention)0.9040100.0%1.001.001.000.980.950.920.920.930.440.900.92
OSA (mass oracle)0.901099.5%1.001.001.000.990.940.910.960.960.220.950.98
NSA MLP (RoPE)0.29990.0%1.000.110.050.090.000.000.090.100.100.930.83
NSA mean-pool (NoPE)0.555442.3%1.000.780.820.530.010.000.470.470.150.910.97
NSA Quest0.576545.8%1.000.860.870.390.030.000.550.550.190.930.97
COBS full-space r=40.823886.7%1.001.001.000.980.780.340.890.920.240.940.97
COBS full-space r=60.849390.9%1.001.001.001.000.910.480.940.940.150.940.99
COBS (subspace s≈85, r=4, FP4)0.819586.0%1.001.001.000.970.790.310.890.910.230.940.97

Key findings:

  • Removing RoPE from selection summaries (NoPE) is an additive improvement (mean-pool 0.4186 → 0.5554)
  • NSA Quest improves only modestly over mean-pool (0.5765)
  • COBS's covariance summary accounts for the large remaining gain

KV Cache Read Traffic

Table 3: Per-decode-step, per-layer KV cache read traffic at 32k (KiB):

MethodSummary keysSummary valuesWindowFine-grainedPer layervs. dense (×less)vs. NSA MLP (×more)
Dense---65,53665,536-18.29×
OSA33,7921024512102436,3521.80×10.14×
NSA MLP102410245121024358418.29×-
NSA mean-pool102410245121024358418.29×1.00×
NSA Quest307210245121024563211.64×1.57×
COBS full-space r=4 (FP4)211210245121024467214.03×1.30×
COBS (subspace s≈85, r=4, FP4)176710245121024432715.15×1.21×

Short-Context Parity and Language Modeling

  • Short-context common-sense reasoning: All sparse variants preserve dense-like performance (38.0–38.6 avg vs. dense 38.2), as expected when the selection budget covers the input.
  • Position-wise NLL: COBS has the lowest average NLL (1.633), below dense (1.727), NSA MLP (1.683), and mean-pool (1.745). COBS's NLL slope stays flat at long positions (no upturn), indicating it conditions on distant tokens rather than leaning on the local window.

Ablations

Rank sweep (Figure 5): Selection peaks at r=8r = 8 (0.8539), regresses at r=16r = 16 (0.8006), and stays below peak at max rank r=31r = 31 (0.8135). The collapse concentrates in multi-key needle subtasks (MK3 falls from 0.470 at r=8r=8 to 0.054 at r=16r=16), attributed to the unsigned variance term boosting blocks with many distractors.

Subspace (Table 4): Adaptive per-layer subspaces outperform a single global budget at comparable dimension. At average s85s \approx 85, score is within ≈0.005 of the full low-rank form (s=128s = 128).

Quantization (Table 5): FP4 (E2M1) is essentially lossless — full-space r=4r=4 changes by only +0.0013 (0.8238 → 0.8251) while shrinking the descriptor ≈3.8× (1024 → 272 bytes per block).

Negative results:

  • Query-centered expansion: Expanding the CGF around a calibrated origin q0q_0 instead of q=0q = 0 regresses selection (0.8238 → 0.8100), concentrated on multi-key/multi-value needles.
  • Cheap diagonal skew: Adding signed third-cumulant scalars gig_i per eigenvector hurts at low rank (r=4r=4: 0.8238 → 0.7754) but partially repairs the high-rank regression (r=16r=16: 0.8006 → 0.8252).

Theoretical and Practical Implications

Theoretical Implications

  1. Cumulant order as a diagnostic lens: The paper establishes that existing cacheable block selectors are all confined to first-order approximations in the query. Any affine score of the form scorebaff(q)=ab+qϕb\text{score}_b^{\text{aff}}(q) = a_b + q^\top \phi_b (mean-pool, NSA's MLP pooling, CSA's gated pooling) cannot capture the quadratic term 12qΣbq\frac{1}{2} q^\top \Sigma_b q, which is not affine in qq.

  2. The GQA cross-head nonlinearity cannot lift the ceiling: An informal argument (Equation 20) shows that sharing a block set across heads is a constraint relative to independent per-head selection, so the first-order family's quality is bounded by a curvature-blind ceiling.

  3. The mass criterion is the right target: OSA's near-dense performance (99.5% gap closed) proves that ranking by exact attention mass is sufficient; the bottleneck is estimation, not the criterion.

Practical Implications

  1. Block sparse attention can approach dense quality: COBS closes ~86% of the gap between first-order selection and dense attention at a fraction of the KV cache read traffic (15.15× less than dense).

  2. Hardware-friendly design: The compressed covariance descriptor (low-rank + subspace + FP4) keeps the per-block summary small (272 bytes for full-space r=4r=4), making the approach practical for deployment.

  3. Cumulant order is a design axis: Raising the cumulant order of cached summaries is a principled way to improve cacheable selectors, applicable beyond NSA to the broader family of block sparse methods.

Conclusion

The paper traces the challenges of block sparse attention to the selection branch and shows that selection reduces to ranking blocks by attention mass. A cumulant expansion reveals that existing selectors are first-order in the query, discarding the within-block key covariance. COBS keeps the cacheability constraint while raising the cumulant order, storing a compressed second-order statistic per block.

Empirically, COBS lifts 32k RULER from 0.2999 (NSA baseline) to 0.8195, closing ~86% of the gap to dense attention (0.9040), while using only 1.21× the NSA baseline's KV cache read traffic and 15.15× less than dense. The same model preserves short-context performance and attains the lowest position-wise NLL (1.633 vs. dense's 1.727).

Future directions: The paper is a mechanism study at ≈1.2B scale; deployment-scale validation is needed. The RULER-style SFT protocol is nonstandard, and the NoPE confound means long-context comparisons partly reflect position encoding differences. The authors see cumulant order as a step toward making block sparse attention more prevalent in leading open-weight LLMs.

Limitations: Scale (≈1.2B backbone), controlled NSA comparison (different hyperparameters, non-overlapping blocks), NoPE confound, RULER-style SFT protocol, and the fact that KV read accounting numbers don't by themselves imply end-to-end runtime gains (which depend on kernels, batching, hardware, and decoding regime).

Related papers