Skip to content

flashnext cuda: opt-in short-row GDN chains on the two-threads-a-row kernel - #4484

Merged
ashhart merged 4 commits into
mainfrom
lead/flashnext-gdn-chain-tpr
Nov 24, 2026
Merged

ashhart merged 4 commits into
mainfrom
lead/flashnext-gdn-chain-tpr

Conversation

@ashhart

@ashhart ashhart commented Nov 22, 2026

Copy link
Copy Markdown
Owner

What this changes

Flash Next's CUDA GDN decode/verify chain spends 61,440 warp shuffles and as many reduction adds per token per layer (five butterfly levels per state row). The repository already has fn_gdn_chain_tpr, which gives each state row two threads and does the within-thread levels first, with the same bit order as fn_gdn_rows_to (its contract compares every output and state byte); today it is used only from 64 rows up.

With TF_FLASHNEXT_GDN_CHAIN_TPR=1, ordinary windows below 64 rows select it too (one shuffle level instead of five: about 80% fewer shuffles). Default off. Only the ordinary rows/rows_to route changes; pending (rows_late) semantics and the shared-lane wrapper are untouched. No dtype or arithmetic change.

  • The switch is registered in the environment table (strict 0/1) and counted in the Flash Next table test.
  • Served contract cells R = 1, 4, 8, 16, 32 for the full-head form and both TP=2 _h8 rank forms compare every ys and state byte with the current path, including planted NaN/Inf and rollback _to state.

Checks

  • zig fmt --check, ast-check, the 600-line cap and the lean count pass; compile-cuda-tests and test-flashnext-glue-contract-host exit 0.

Still to run (GB10)

tf-cuda-test kernel-contract fn_gdn_chain_tpr byte equality; chain and whole-window timings at R = 1/4/8/16 A-B-B-A; served drafted decode with tokens compared. Kill on any byte or token difference, a slower R = 1/4, R = 8 and 16 under 10% faster in chain median, or whole drafted decode under +3%.

@ashhart
ashhart force-pushed the lead/flashnext-gdn-chain-tpr branch 3 times, most recently from ea476c8 to d252728 Compare November 24, 2026 01:59
@ashhart
ashhart force-pushed the lead/flashnext-gdn-chain-tpr branch from d252728 to 603ef55 Compare November 24, 2026 10:05
@ashhart
ashhart merged commit 31726c0 into main Nov 24, 2026
12 checks passed
@ashhart
ashhart deleted the lead/flashnext-gdn-chain-tpr branch November 24, 2026 10:05
ashhart added a commit that referenced this pull request Nov 24, 2026
ashhart added a commit that referenced this pull request Nov 24, 2026
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.

1 participant