Skip to content

perf(gdn): take b and a in the recurrence kernel on decode - #925

Draft
RaunakGengiti2725 wants to merge 1 commit into
FlashML-org:mainfrom
RaunakGengiti2725:pr/gdn-ba-fold
Draft

RaunakGengiti2725 wants to merge 1 commit into
FlashML-org:mainfrom
RaunakGengiti2725:pr/gdn-ba-fold

Conversation

@RaunakGengiti2725

@RaunakGengiti2725 RaunakGengiti2725 commented Nov 20, 2026 •

Copy link
Copy Markdown

Related: #921. This is one of the changes in the fork build measured there.

When a GDN layer's b|a projection is its own bf16 linear (as here: qkv|z quantized, b|a not), decode and verify steps of 1 to 64 rows no longer launch it: the recurrence kernel computes those dots itself, rounded to bf16 as the linear stores them. One launch less per GDN layer; prefill unchanged. It logs gdn b|a in the recurrence kernel on decode: on (or why not); FREETOKEN_GDN_BA_IN_KERNEL=0 turns it off.

A/B against main 2fb371e. RTX 5090 (575 W), AMD EPYC 9354, driver 615.71.09, nvidia/Qwen3.6-35B-A3B-NVFP4. One interleaved run, 2 rounds, order reversed. Both arms: ft serve --model nvidia/Qwen3.6-35B-A3B-NVFP4 --enable-timings-report --moe-strategy fused --max-running-requests 1 --speculative-algorithm mtp --speculative-num-steps 3; a math and a code prompt, 5 passes, 1,024 warm-up + 2,048 timed tokens, checkpoint sampling, server timings.

main main A/A this PR
math tok/s 495.9 493.9 (-0.40%) 529.6 (+6.81%)
code tok/s 441.9 441.6 (-0.06%) 489.1 (+10.69%)
steps/s, math / code 151.7 / 153.3 151.1 / 153.3 163.2 / 164.7

Steps/s +7.57% / +7.38%; tokens per step -0.72% / +2.71% with the changed text. Same sign both rounds. Text: 0 of 20 windows equal main's (A/A 20 of 20). On my fork, not rerun on main: KL 0.00207 nats; hard math 27 against 27 of 30.

Tests (GPU): tests/layers/test_gdn.py -k split_ba fails if decode launches in_proj_ba again or, on dots any order sums exactly, stop matching it bit for bit; tests/spec/test_gdn_verify.py -k ba_fold fails if graph replay breaks.

Tested on real hardware by me.

When b|a is its own bf16 linear (qkv|z quantized, b|a not), a decode or verify step of 1 to 64 rows no
longer launches it: the recurrence kernel computes each value head's two dots from the hidden states and
the b|a weight and rounds them to bf16 as the linear stores them. One launch less per GDN layer; prefill
is unchanged. The first decode step logs once whether the fold is on, and FREETOKEN_GDN_BA_IN_KERNEL=0
launches the linear again.
@github-actions github-actions Bot added the perf label Nov 20, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant