Heavily compressed attention

Complete blocks

×

For each query, every compressed position whose block of 128 is complete.

Jtc={0,…,⌊(t+1)/128⌋−1}{\htmlData{light=selected compressed-rows}{J^{c}_{t}}}=\{0,\ldots,\lfloor(t+1)/128\rfloor-1\}
in
ZZ [B batch, T/128 compressed positions, 512 d_h]
out
JcJ^{c} [B batch, T positions, T/128 compressed positions]

No indexer: a query reads all of them. A position’s own block is read only through the window until it is complete (model.py 268–276). Only the number of entries is read, not their values: the list depends on positions alone, and the code makes it before the compressor runs (model.py 513, 525).

Sources

In codeget_compress_topk_idxs(ratio, bsz, seqlen, start_pos, offset) · 513

Open pinned code ↗

Direct evidence

Without an indexer, a query lists every compressed position whose block is complete: j < ⌊(t + 1)/m⌋, shifted by the window rows.

model.py 268–276 ↗ · deepseek-ai/DeepSeek-V4-Flash @ 60d8d70770c6

Excerpt
@lru_cache(2)
def get_compress_topk_idxs(ratio: int, bsz: int, seqlen: int, start_pos: int, offset: int):
    if start_pos > 0:
        matrix = torch.arange(0, (start_pos + 1) // ratio) + offset
    else:
        matrix = torch.arange(seqlen // ratio).repeat(seqlen, 1)
        mask = matrix >= torch.arange(1, seqlen + 1).unsqueeze(1) // ratio
        matrix = torch.where(mask, -1, matrix + offset)
    return matrix.unsqueeze(0).expand(bsz, -1, -1)