Repository navigation
cuda : fused Gated DeltaNet decode chain at 2-8 tokens with the speculative rollback store (gfx1151) - #294
Closed
neavra wants to merge 1 commit into
Conversation
…lative rollback store (gfx1151) The fused GDN decode step (ggml_cuda_try_gdn_decode_fusion) only matched a single-token graph that stores the conv state in place. llama-server verifies MTP drafts with 2-8 tokens per step and keeps rollback snapshots, so the GDN chain was emitted with the SET_ROWS store form (ARANGE -> SCALE -> cast -> SET_ROWS over K slots) at every row count, and no layer ever fused in serving: every verify step ran the unfused conv, norm, gate and delta-net kernels, about 430 launches per 4-token pass on Qwen3.8-Flash-Next. The matcher now recognises the rollback store form at 2-8 tokens and runs the chain in one launch for all tokens, writing the K rollback slots the unfused graph would write (slot s holds the window that starts at column n_tokens - s). The softplus in the fused kernel is spelled log1pf(expf(x)) like the unfused op, so the fused path is bit-identical to the chain it replaces. The single-token rollback form is left to the existing path by default (GGML_CUDA_FUSE_GDN_DECODE_T1=1 widens the match to 1 token); GGML_CUDA_FUSE_GDN_DECODE_T=0 restores the unfused chain. tests: test-backend-ops builds the rollback chains contiguously, with a single-token sequential reference, and gives the test-mode context a per-test tensor budget. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
neavra
changed the base branch from
master
to
sync/upstream-2026-11-15-e574a17b0
November 17, 2026 08:04
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.
Overview
Based on the #293 sync tip (1ab579a) and targeting that branch so the diff shows only this commit; to be retargeted to
masteronce #293 merges.HIP / gfx1151 (Strix Halo). The fused Gated DeltaNet decode step (
ggml_cuda_try_gdn_decode_fusion, from #150)matches a single-token graph that writes the conv state in place.
llama-serverdoes not emit that graph when itserves with a draft: a 2-8 token verify step keeps rollback snapshots, so the conv state goes through the SET_ROWS
store form (
ARANGE -> SCALE -> cast -> SET_ROWSover the K slots). That form never matched, at any row count, so inserving every Gated DeltaNet layer ran the unfused conv, norm, gate and delta-net kernels on every verify step. On
Qwen3.8-Flash-Next (36 GDN layers) that is about 450 launches per 4-token pass that the fusion was meant to remove,
invisible to
llama-bench, which emits the in-place form and fuses.This PR teaches the matcher the rollback store form at 2-8 tokens and runs the chain for all tokens in one launch,
writing the K rollback slots the unfused graph would write (slot
sholds the window that starts at columnn_tokens - s). The fused kernel spells softplus aslog1pf(expf(x))like the unfused op, so the fused path producesthe same bits as the chain it replaces.
GGML_CUDA_FUSE_GDN_DECODE_T=0restores the unfused chain.GGML_CUDA_FUSE_GDN_DECODE_T1=1widens the match to one token(left off by default until verified on a model end to end).
the new code is ordinary CUDA C++ next to the existing matcher.
Scope:
ggml-cuda.cu(matcher),gated_delta_net.cu/.cuh(the rollback-slot store in the fused kernel),tests/test-backend-ops.cpp(rollback-chain cases at 2-8 tokens with a single-token sequential reference; the test-modecontext gets a per-test tensor budget because the reference builds
n_tokens + 1chains).Duplicate check
same function), so one of the two rebases over the other.
gated_delta_net.cufor prefill snapshots; unrelated in function, textual overlap only.Measurements
Both arms built the same way in the same session, run in the order base, PR, PR, base with the box's six services
stopped for the window.
llama-bench -fa on -ctk f16 -ctv f16 -b 2048 -ub 1024 -p 1,2,4,8 -n 32 -r 5, t/s per run (llama-benchemits thein-place form, so the new match is not taken here; the numbers show the change is neutral where it does not fire):
llama-server(-c 16384 -b 1024 -ub 1024 -fa on), three 8k-token prompts (code, prose, agentic), 256 generatedtokens, greedy. 4-row:
--spec-type draft-mtp --spec-draft-n-max 3, two cells per arm, two repetitions per cell; 1-row:plain decode, two cells per arm. Decode t/s, min-max over the cells (mean in brackets):
4-row decode +3.5 to +4.7 % on the means; 1-row unchanged (the match starts at 2 tokens). Prompt processing of the 8k
prompts is unchanged (8.4-8.7 s both arms). The first repetition of the first cell after the service stop reads low on
both arms (cold caches); it is included in the ranges above.
Output streams: the greedy token stream of every cell is identical to base, per prompt, at 1 and 4 rows (same stream
hash across all four arms); draft acceptance is unchanged.
Per-op profile of the 4-token verify graph (8538 nodes;
GGML_CUDA_OP_PROF=1 GGML_CUDA_DISABLE_GRAPHS=1, 64 tokenson the prose prompt): 63.9 ms over 2299 launches -> 60.4 ms over 1844 launches. The unfused conv, norm, gate and
delta-net kernels of the 36 GDN layers leave the profile and the fused step appears once per layer (it is accounted
under the chain's CONCAT node: 1.0 ms -> 2.2 ms).
Tests
test-backend-ops test -b ROCm0on the PR head: 45212/45212 passed (the full suite, including the new rollback-chaincases and the existing GDN cases).
Written with Claude, tested by me.
🤖 Generated with Claude Code