Repository navigation
perf(cuda): the recurrent-state GET_ROWS folds into GATED_DELTA_NET's load, f32 or q8_0 cache (#220 plus -cts q8_0) - #31
Merged
Conversation
… load, f32 or q8_0 cache (PrismML-Eng#220 plus -cts q8_0)
…ts on ids' memory The kernel reads ids at the GATED_DELTA_NET, but the GET_ROWS it skips can be ids' last reader in graph order (the last recurrent layer's), after which ggml-alloc frees ids and may place a later node on it. The matcher now declines when any non-view node after the GET_ROWS, the GDN included, overlaps ids' bytes; that layer keeps its GET_ROWS.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
build_rs gathers each Gated DeltaNet layer's recurrent state out of the cache with a GET_ROWS into a temp, and only
the GATED_DELTA_NET reads that temp. With a q8_0 state cache (
-cts q8_0, the served head), that is a 786,432-elementdequantizing copy per layer, 5.2 µs at a decode step and 5.6 µs at a 3-row verify on the RTX 5070 Ti (Nsight,
research/gdn-q8-cache-fusion-2026-09-22), 48 times a step.The CUDA evaluator now skips that GET_ROWS (
ggml_cuda_try_gdn_gather_skip) and registers the gather for the GDNnode; the kernel reads the sequence's cache row
ids[seq]itself, f32 or q8_0 dequantized as it loads withget_rows' formula, so it sees the values the skipped GET_ROWS would have written. From PrismML-Eng#220 (f32),
plus the q8_0 cache.
Declined, keeping the GET_ROWS, when:
GET_ROWS read before any write and the kernel's blocks would race on);
skipped GET_ROWS can be ids' last reader in graph order (the last recurrent layer's), after which ggml-alloc frees
ids (an input copy is not an output with one GPU) and may place a later node on it. cuda: fold the recurrent-state gather into the GATED_DELTA_NET kernel, per-context registry (+3.8% TG on Ada) PrismML-Eng/llama.cpp#220 has the same exposure;
Off switch:
GGML_CUDA_GDN_STATE_GATHER_LEGACY=1.Verified
GATED_DELTA_NET_CACHE_FUSION36/36, with and without the switch;GATED_DELTA_NET63/63(RTX PRO 4000 Blackwell, sm_120). New cases: the state gathered from row 1 or 4 of an f32 or q8_0 cache, 1 or 3
tokens, and the chunked case, which declines.
without its block scale (32/36), q8_0 bytes read as f32 (32/36). Restored: 36/36.
fold takes all 48 GDN layers at every capture; the ids guard never declines there.
Measured (RTX 5070 Ti, 595.71.05, e0da2d1: this branch plus perf/gdn-conv-state-update, one binary three ways by the two switches)
Nsight Systems, llama-perplexity over 1,024 tokens with the served cache flags, legs legacy / fold / new / new / fold / legacy:
Served, the head's flags (public MTP r2 pack,
-cts q8_0, MTP n_max 2, one slot at 40,960), the 48 held-out eval requestsgreedy, legs new / fold / legacy / legacy / fold / new, per request with leg order cancelled:
Artifacts: libggml-cuda 24d7516a…, the pack 0e5524be…; rig
local/research/gdn-conv-state-update-2026-09-25/served-ab-e0da2d116.TORAD.md row added.
Where this goes next
perf/gdn-conv-state-update (stacked on this branch) folds the conv-state chain the same way.