Repository navigation
perf(gdn): take b and a in the recurrence kernel on decode - #925
Draft
RaunakGengiti2725 wants to merge 1 commit into
Draft
RaunakGengiti2725 wants to merge 1 commit into
RaunakGengiti2725 wants to merge 1 commit into
Conversation
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.
This branch has not been deployed
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.
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=0turns 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.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_bafails if decode launchesin_proj_baagain or, on dots any order sums exactly, stop matching it bit for bit;tests/spec/test_gdn_verify.py -k ba_foldfails if graph replay breaks.Tested on real hardware by me.