Skip to content

olmo_core_vlm: cached decoding for Kimi Delta Attention blocks - #574

Merged
jason718 merged 1 commit into
jasonr/olmo-core-vlm-olmo35from
rustins/kda-cached-decode
Nov 20, 2026
Merged

jason718 merged 1 commit into
jasonr/olmo-core-vlm-olmo35from
rustins/kda-cached-decode

Conversation

@RustinS

@RustinS RustinS commented Nov 20, 2026

Copy link
Copy Markdown

What it does

OLMo 3.5 document-layout checkpoints mix Kimi Delta Attention (KDA) blocks with a few softmax-attention blocks.
enable_kv_cache could not cover the KDA blocks, so these checkpoints decoded without a cache: every generated
token re-ran the language model over the whole sequence. With this change they decode from kept state:

  • KDA blocks keep their recurrent state and the last kernel_size - 1 inputs of the q/k/v convolutions
    (CachedKimiDeltaAttention). The prefill runs the usual chunked kernel over the left-padded prompt with the pad
    positions made inert; decode steps continue from the kept state.
  • Attention blocks with Scalable-Softmax count a query's visible tokens from the cache instead of from the
    position inside the current forward (CachedAttention), and models without RoPE get no position tables.
  • Load-time check: the cached KDA class restates OLMo-core's KimiDeltaAttention.forward, so before it is
    trusted one block is decoded from state on random input and compared with its own full forward. A build whose
    forward has changed fails the check and the model decodes without a cache, with a warning.

Nothing changes for models the cache already covered. -o provider.use_cache=false keeps the uncached decode.

Recommended setting for SA-Co Gold 4k: batch 256, passed as -o provider.batch_size=256 -o batching.chunk_size=256
after --harness (the harness chunks requests at 64 before the provider sees them). It runs in 2 h 38 min instead of
5.5 h at the same score. The other evals are fine at 64.

Results

Same checkpoint (c20b-r44hr-seed0, step 1200), 8 crops, one 8-GPU job per eval on holmes (B300, torch 2.10 image):

Eval Uncached Cached Wall-clock before Now
olmOCR-Bench 47.48 47.37 ~22 h 2 h 06 min
CC-OCR multi-scene (en) 66.72 66.48 ~9 h 1 h 10 min
SA-Co Gold 4k 82.69 82.63, 82.61 (two runs) ~16.5 h 5 h 18 min - 5 h 32 min
SA-Co Gold 4k, batch 256 82.69 82.66 ~16.5 h 2 h 38 min

A second checkpoint and a 24-crop run, cached from this branch on local B300s (torch 2.13) against the uncached
holmes jobs (torch 2.10):

Eval Uncached Cached
CC-OCR multi-scene (en), c20b-r44hrocr-seed0, 8 crops, 2,000 images 67.35 67.01
Quick eval at 24 crops, c20b-r44hr-seed0: PixMo-Count (192) 66.7 67.2
PixMo-Points (192) 48.4 49.4
SA-Co Gold subset (192) 34.0 34.0
CC-OCR (64) 67.4 66.7

Paired per image on the 2,000 CC-OCR images: 1,575 outputs are identical; word F1 per image is 60.69 cached against
60.54 uncached (difference +0.15 +- 0.22 SE; 159 images better, 164 worse).

On one real checkpoint the load-time check measures a deviation of 0.2-0.3% on each of the 14 KDA blocks (tolerance
5%), and four pages decoded for 48 tokens are identical to the uncached decode.

The cached and uncached decodes agree to rounding, not bitwise: the chunked KDA kernel groups tokens in blocks of
64 from the padded start, and a decode step's convolution runs through F.conv1d. Measured with forced tokens
(3 pages x 700 tokens), the largest logit difference per position is 0.37-0.45 on a scale of ~30, flat along the
sequence; the same uncached forward with 500 extra right pads moves the logits by 0.31-0.33. The top token flips
1-4 times in 700, always at margins <= 0.06.

Open points

  • The full-eval scores are each slightly below their uncached counterparts (0.06-0.34). The paired comparison above
    shows no systematic shift, so this reads as run-to-run noise, but only CC-OCR was paired.
  • A batch decodes until its last row stops, so a single row that runs to max_tokens holds the batch (SA-Co Gold
    4k). Larger batches help (-o provider.batch_size=256 -o batching.chunk_size=256 after --harness: 2.7 items/s
    against 1.4-1.5 at 64); dropping finished rows from the state is a possible follow-up.
  • The eval image's torch 2.10 uses the per-expert grouped_mm loop on Blackwell; a cached step costs ~0.28 s there
    and ~0.1 s on torch 2.13.
  • ty was not run locally (not installed in the environment used here).

Tests

tests/providers/test_olmo_core_provider.py::TestCachedDecodeState: the convolution tail against the full causal
convolution; cached Scalable-Softmax against a full forward with left padding; the load-time check on a toy
recurrent mixer (kept state passes, lost state and a raising forward fail, the module's class is restored); and,
with OLMo-core, flash-linear-attention and a GPU, a real KimiDeltaAttention decoded from state against its full
forward. Provider tests: 352 passed, 1 skipped (no openai package locally).

🤖 Generated with Claude Code

https://claude.ai/code/session_0159PTUsp2w3YTANVDZ4BUss

OLMo 3.5 document-layout checkpoints decoded without a cache because their
Kimi Delta Attention blocks have no KV cache: every generated token re-ran
the language model over the whole sequence.

- KDA blocks now keep their recurrent state and the last inputs of their
  q/k/v convolutions between decode steps (left-padded rows; pad positions
  are inert in the prefill).
- Attention blocks with Scalable-Softmax count a query's visible tokens from
  the cache, and models without RoPE get no position tables.
- At load, one KDA block is decoded from state on random input and compared
  with its own full forward; if they disagree the model decodes without a
  cache.

olmOCR-Bench 22 h -> 2 h 06 min, CC-OCR 9 h -> 1 h 10 min, SA-Co Gold 4k
16.5 h -> 5.5 h on one 8-GPU job each, with scores within 0.25 of the
uncached decode.
@RustinS
RustinS requested a review from a team as a code owner November 20, 2026 18:21
@jason718
jason718 merged commit 66eeb1e into jasonr/olmo-core-vlm-olmo35 Nov 20, 2026
1 check passed
@jason718
jason718 deleted the rustins/kda-cached-decode branch November 20, 2026 18:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants