Skip to content

EXL3 Flash Next: DeltaNet head split, opt-in (7/7) - #1447

Closed
BlivionIaG wants to merge 7 commits into
ashhart:mainfrom
BlivionIaG:pr/exl3-s7-gdn-split
Closed

BlivionIaG wants to merge 7 commits into
ashhart:mainfrom
BlivionIaG:pr/exl3-s7-gdn-split

Conversation

@BlivionIaG

@BlivionIaG BlivionIaG commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

Draft, slice 7 of 7 in the chain of #1419 (opt-in, off by default). Stacked on slice 6: this branch contains the earlier slices, review only the last commit. Numbers marked "pending" are being measured and will be filled in before this leaves draft.

What

TF_FLASHNEXT_GDN_SPLIT=1 splits the 48 DeltaNet value heads (and 16 key heads) of every linear-attention layer across the two TP=2 ranks for decode rows (rounds and windows under 64 rows). Rank r runs key heads 8r..8r+7 and value heads 24r..24r+23: its q, k, v and z projections read half of the replicated EXL3 weights through column views (a pointer offset and a shorter extent, no copy), the recurrence updates half of the state in the whole-layer layouts, and the out projection, cut by input rows, gives a partial sum that one fp32 all-reduce adds. Prompt passes keep running every head, so weights, conv windows and states keep their sizes and layouts.

Files: cuda_exl3_gdn_split.zig (views), head-subset variants fn_gdn_front_h, fn_gdn_rows_h, fn_gdn_rows_to_h, fn_gdn_norm_h in flashnext_batch.cu, and the hooks in cuda_batch.zig / cuda_prompt_load.zig.

Why it is opt-in

  • It reorders an fp32 reduction (the out projection's partial sums are added across ranks), so the text is not byte-identical to the replicated path: on 24 prompts 20 reply texts are identical and 4 diverge after 84, 220, 285 and 423 characters; all 20 checkable answers are correct. Under the repo's reduction-order rule this needs the FP64 per-projection-class receipts before it can be on by default; they are not in this PR.
  • It gains little once drafts are on: plain decode (no drafts) improves, drafted decode is neutral.

Notes on the measurements

The split is off by default, so the receipt tables below are the default path and match slice 6 within noise. A table with the split enabled (TTFT, prefill, decode, ITL): pending; prefill is unchanged by design, the split applies to decode rows only. Extending the split to prompt passes was tried and rejected (TTFT +18%).

Tests run

On this tree: zig build native -Dnvcc=nvcc -Dsm=120, test-flashnext-exl3-host (294 pass), compile-cuda-tests, test-kernel-contract on sm_120; zig fmt --check; python3 tools/zig/lean_check.py at 428 problems, the same set as upstream main; Linux zig build test (4899 pass, 18 skipped, 0 failed), HIP build and test as on main; zig build dev-tools -Dcpu=apple_m1; a mutation of the draft guard is caught by its unit test. Not run: other architectures, test-golden on a Mac for this slice (run on slice 1), the FP64 references.

Contract

The four _h kernels have geometry-only pending records (flashnext_gdn_split_pending.zig; launch bounds 256/128/128/128, resource usage unmeasured, so every architecture including sm_120 stays pending until measured).

Not done in this PR

  • Measured resource usage for the _h kernels.

Receipts (2x RTX 5060 Ti 16 GB sm_120, PCIe 4.0 x8, EPYC 7452, 251 GB RAM, driver 615.71, CUDA 13.4, Zig 0.17.0)

Measured on this slice's tree before the rebase onto current main (same code); a smoke run on the rebased heads of slices 1, 2 and 7 reproduces every output hash above and drafted equals plain, with plain timings within 5%. Open item: with drafts on, cold TTFT was higher on that run (slice 7 Zig 19.2 s against 10.9 s plain, docs 21.0 s against 10.7 s); the earlier run above shows 11.5 s and 11.2 s, so it is being re-checked. 192 output tokens, temperature 0; cold is the first request after server start, warm the identical repeat; the bench has no prompt cache. Peak memory and the prompt-cache check are in the receipt files.

bench2.py: three prompts (short = 40 tokens, zig = 16,022 tokens of source files, docs = 12,780 tokens of docs), 192 new tokens, temperature 0, ignore_eos, thinking off, streamed over the OpenAI chat API, two repetitions each. Cold = the first request of that prompt after server start (includes first-touch and graph capture), warm = the identical repeat. The prompt cache is off (--prompt-cache-gib 0 or none), so the warm repeat prefills again from scratch. Prefill tok/s = prompt tokens / TTFT; decode tok/s = (gen-1) / (last-first chunk span); mean ITL = that span / (gen-1).

Plain decode (no drafts)

prompt prompt tok gen tok TTFT cold s TTFT warm s prefill cold tok/s prefill warm tok/s decode cold tok/s decode warm tok/s mean ITL cold ms mean ITL warm ms text hash
short 40 192 1.90 0.32 21.0 124.9 44.28 47.75 22.58 20.94 90e6c65ca5ba
zig 16022 192 10.89 10.63 1471.8 1507.4 34.29 35.67 29.16 28.04 6dfc89b1abb6
docs 12780 192 10.61 10.37 1204.4 1232.5 36.36 37.80 27.51 26.45 e6834625432c

Drafted decode (MTP head loaded, drafts enabled)

prompt prompt tok gen tok TTFT cold s TTFT warm s prefill cold tok/s prefill warm tok/s decode cold tok/s decode warm tok/s mean ITL cold ms mean ITL warm ms text hash
short 40 192 1.99 0.37 20.1 109.1 42.49 46.59 23.54 21.46 90e6c65ca5ba
zig 16022 192 11.45 11.23 1399.9 1427.1 103.31 104.89 9.68 9.53 6dfc89b1abb6
docs 12780 192 11.19 10.95 1142.2 1166.7 53.76 57.59 18.60 17.37 e6834625432c

Repeat of the drafted session (second server start, same binary and settings, run after all slices to check run-to-run variance):

prompt prompt tok gen tok TTFT cold s TTFT warm s prefill cold tok/s prefill warm tok/s decode cold tok/s decode warm tok/s mean ITL cold ms mean ITL warm ms text hash
short 40 192 1.98 0.37 20.2 108.8 42.46 46.51 23.55 21.50 90e6c65ca5ba
zig 16022 192 11.47 11.23 1397.1 1426.2 103.59 104.82 9.65 9.54 6dfc89b1abb6
docs 12780 192 11.20 10.97 1141.3 1165.0 53.71 57.40 18.62 17.42 e6834625432c

drafted == plain

prompt plain hash drafted hash drafted == plain (all reps) plain decode cold drafted decode cold ratio plain ITL drafted ITL plain decode warm drafted decode warm
short 90e6c65ca5ba 90e6c65ca5ba yes 44.28 42.49 0.96x 22.58 23.54 47.75 46.59
zig 6dfc89b1abb6 6dfc89b1abb6 yes 34.29 103.31 3.01x 29.16 9.68 35.67 104.89
docs e6834625432c e6834625432c yes 36.36 53.76 1.48x 27.51 18.60 37.80 57.59

bench_openai 256-token greedy token hashes, plain vs drafted: fibonacci-raw: plain ['97f8951316ab'] drafted ['97f8951316ab'] -> equal; gpu-chat-no-think: plain ['de2cc2940523'] drafted ['de2cc2940523'] -> equal

Repo-client receipts

bench_openai decode, 256 tokens x3 greedy (plain)

prompt decode tok/s median 3 reps TTFT s prefill tok/s mean ITL ms ITL p50 ITL p95 token sha
fibonacci-raw 37.88 36.69/37.88/38.64 0.227 61.7 26.40 24.6 35.2 97f8951316ab
gpu-chat-no-think 42.70 41.98/42.70/43.35 0.329 94.2 23.42 22.8 28.5 de2cc2940523

bench_cache cold prefill, exact token-id prompts, --require-cold (plain)

requested tok prompt tok cold prefill TTFT s prefill tok/s decode tok/s cache state client verdict
2048 2048 2.42 845.4 29.66 cold qualified=True; repeats cold TTFT 2.3/2.4
8192 8192 5.44 1505.7 29.02 cold qualified=True; repeats cold TTFT 5.4/5.3
30000 30000 21.14 1418.8 28.85 cold qualified=True; repeats cold TTFT 21.0/21.0

bench_openai decode, 256 tokens x3 greedy (drafted)

prompt decode tok/s median 3 reps TTFT s prefill tok/s mean ITL ms ITL p50 ITL p95 token sha
fibonacci-raw 57.26 57.26/59.04/40.31 0.259 54.1 17.47 0.0 85.2 97f8951316ab
gpu-chat-no-think 48.42 47.44/48.42/49.14 0.368 84.2 20.65 23.5 56.4 de2cc2940523

bench_cache cold prefill, exact token-id prompts, --require-cold (drafted)

requested tok prompt tok cold prefill TTFT s prefill tok/s decode tok/s cache state client verdict
2048 2048 2.52 811.9 29.34 cold qualified=True; repeats cold TTFT 2.4/2.4
8192 8192 5.74 1426.6 29.95 cold qualified=True; repeats cold TTFT 5.6/5.6
30000 30000 22.21 1350.5 33.10 cold qualified=True; repeats cold TTFT 22.0/22.0

bench_concurrent, 1 and 2 streams, --alone --serial (PARALLEL=2 server)

prompt streams aggregate tok/s per-stream tok/s TTFT max s mean ITL ms ITL p95 ms end-to-end tok/s failed equal-to-alone equal-to-serial(no draft)
code 1 39.3 39.3 0.23 25.42 31.5 38.2 0 3 eq / 0 neq / 0 fail 1 eq / 0 neq / 0 fail
code 2 71.9 36.4 1.52 27.54 33.1 69.9 0 6 eq / 0 neq / 0 fail 1 eq / 0 neq / 0 fail
chat 1 39.1 39.1 0.36 25.59 31.3 37.2 0 3 eq / 0 neq / 0 fail 1 eq / 0 neq / 0 fail
chat 2 73.2 36.9 0.54 27.10 32.0 69.9 0 6 eq / 0 neq / 0 fail 1 eq / 0 neq / 0 fail

FP64 receipt (reduction order)

What changes. With TF_FLASHNEXT_GDN_SPLIT=1, decode-sized rows (under 64) of the DeltaNet layers run half of the value heads on each rank; the out projection's K = 6144 reduction becomes two K = 3072 reductions whose fp32 partials are added across ranks, instead of one rank reducing all of K.

Method. Real weights (the 3.05 bpw pack) and real activations: the 12,780-token docs prompt (every 64th position, 200 rows) and a 31-token prompt, each followed by 40 greedy tokens, run through the real server with a read-only capture of each op's input and of the fp32 value it produced. The reference recomputes the op in float64 from the pack's dequantized weights (W = diag(suh) H Wq H diag(svh), Wq = the fp16 trellis values; its bitstream and codebook decoding reproduces the repo's numpy-oracle fixture bit for bit) on the captured input; the router's picks and weights are the device's own. Error = device value minus float64 value, relative L2 per row; the ratio is regrouped / current, paired on the same (layer, position). The 95% interval is a bootstrap over pairs of the geometric mean of the per-pair ratio.

projection class samples split off rel. L2 error vs fp64 split on ratio of means pair ratio (95% interval) split closer
DeltaNet out projection, rows on the split path (decode rows and the 31-token prompt) 3924 2.698e-04 2.699e-04 1.000 1.000 (0.999-1.002) 50%
of which generated-token (decode) rows 2808 2.705e-04 2.708e-04 1.001 1.001 (0.999-1.003) 50%

Slices 3 to 6 reorder nothing on these paths. Slice 7's tree with the split off produces the same bytes as slice 2 on every sampled row (rank 0's records, 2 prompts):

dumps/tp vs dumps/s7: records only in one: 0
  moe_in      identical 14832/14832
  moe_picks   identical 14832/14832
  moe_wts     identical 14832/14832
  moe_branch  identical 14832/14832
  mix_in      identical 14832/14832
  mix_branch  identical 14832/14832
  head_in     identical 80/80
  logits      identical 80/80

and the shipped slice-7 configuration (deep prefill, BF16 KV paging, CUDA graphs, expert-parallel) gives the same greedy replies as slice 2 on every prompt tried: 8 of 8 replies identical. For scale, slice 1 and slice 2, which do differ in grouping, give identical replies on only 2 of 8 of the same prompts.

gpu: 2 NVIDIA GeForce RTX 5060 Ti, 615.71.09, 12.0
nvcc: Build cuda_13.4.r13.4/compiler.38855100_0
zig: 0.17.0
python: Python 3.12.3 numpy 1.26.4
cpu: AMD EPYC 7452 32-Core Processor, 1 threads
kernel: Linux 6.8.0-147-generic
nccl: NCCL version 2.32.3+cuda13.4

@BlivionIaG
BlivionIaG force-pushed the pr/exl3-s7-gdn-split branch 4 times, most recently from 555b4ca to 14c3d37 Compare October 27, 2026 12:48
@BlivionIaG
BlivionIaG force-pushed the pr/exl3-s7-gdn-split branch from 14c3d37 to 9a2994d Compare October 27, 2026 14:46
@ashhart

ashhart commented Oct 27, 2026

Copy link
Copy Markdown
Owner

Thanks for keeping this opt-in, and for reporting the divergence plainly. We can't take the head split as designed,
even off by default.

  • The out projection runs on each rank's half of its input rows (cuda_exl3_gdn_split.zig:100), and an fp32
    all-reduce adds the halves (cuda_batch.zig:300).
  • So the sum's order differs from TP=1 and from the replicated path, and your 4 diverging replies out of 24 show it.
  • An FP64 receipt doesn't change that: the bar is bit-identical to TP=1.

Two more things we noticed:

  • halfRows() (cuda_batch.zig:314) counts rows only, so a prompt piece under 64 rows splits too.
  • A split pass updates only the rank's own heads of the state and conv window. That leaves the other half stale for a
    later all-heads pass on the same sequence.

A split that gathers whole heads' gated rows, then runs the full out projection with TP=1's plan on each rank, would
keep the bits. If you try that, a byte-equality receipt against TP=1 would let us look again. Otherwise we'd suggest
closing this one.

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.

2 participants