Skip to content

Flash Next on CUDA: prompts 15-23% faster at --parallel 1 on one GPU - #2246

Merged
ashhart merged 2 commits into
mainfrom
lead/fn-solo-lone
Nov 5, 2026
Merged

ashhart merged 2 commits into
mainfrom
lead/fn-solo-lone

Conversation

@ashhart

@ashhart ashhart commented Nov 5, 2026 •

Copy link
Copy Markdown
Owner

What

At --parallel 1 on one GPU, a Flash Next prompt pass now takes up to 8,192 rows instead of 1,536.

A larger pass reads each routed expert fewer times, so a prompt gets faster. What it normally costs is a wait for any other stream, because a pass isn't interrupted. At --parallel 1 there's no other stream, so that cost doesn't apply. Two costs remain: about 3.2 GiB more scratch, and a cancel that arrives during a pass waits for that pass to end, about 3.6 s at most instead of 0.8 s by my estimate from the pass rate.

This is TF_FLASHNEXT_CHUNK_SOLO's existing behaviour with a new default for this case only. Setting the variable still decides. Servers with more than one stream, including --parallel auto, and two ranks keep their passes.

Numbers

One GB10, MLX 4-bit MTP, --parallel 1 --context 73728, main against this branch, base-new-new-base. Prompt tok/s on a first run from the start of the corpus:

Prompt tokens Main This PR
2,048 1,774 2,046 +15.4%
8,192 1,907 2,341 +22.8%
16,384 1,911 2,294 +20.1%
32,768 1,854 2,244 +21.0%
65,536 1,811 2,117 +16.9%

The other 15 cells, from other corpus offsets and repeated prompts, range from +16.4% to +22.8%. Decode speed is level in all 20 cells, within ±0.6%. No token rows differ, and the 65,536-token long-context cell passes on both sides.

How the pass size trades off, 65,536 tokens, three fresh servers each:

Solo pass First token Model and scratch at startup
1,536 35.5 s 75.8 GiB
4,096 30.7 s 77.0 GiB
8,192 29.5 s 79.0 GiB
16,384 28.8 s 82.9 GiB

8,192 takes most of 16,384's gain for under half its memory.

With the prompt cache full

The known-issues note warned that a large pass could push the n-gram tables out of memory once saved prompt states fill the cache. I measured that at 16,384 rows, the worst case, with seven long chats of about 65,000 tokens filling the default 16 GiB cache, two runs each:

1,536 16,384
First-turn time, mean 38.0, 37.9 s 32.6, 31.3 s
First-turn time, slowest 40.7, 40.3 s 38.9, 33.0 s
Least memory available 20.0, 20.7 GiB 11.1, 13.2 GiB

The tables page at both sizes, but the 1.5x swing in the old note doesn't appear: 16,384 rows beat 1,536 on average in both runs, though one turn was level and one resume took 4.6 s against about 0.8 s. Replies and cached counts match in every row. This PR rewrites that note with these numbers. 8,192 rows wasn't run through this test; it uses about half the extra scratch.

FP4

nvidia/Qwen3.8-Flash-Next-FP4-Local on a second GB10, with the same settings and order. Prompt tok/s on a first run from the start of the corpus:

Prompt tokens Main This PR
2,048 1,787 2,058 +15.2%
8,192 1,904 2,058 +8.1%
16,384 1,915 2,279 +19.0%
32,768 1,870 2,151 +15.0%
65,536 1,839 2,178 +18.5%

The 8,192 row's two runs on this PR were 1,805 and 2,312, so that cell overlaps main. The same prompt repeated goes from 1,908 to 2,308 (+20.9%). The other 15 cells range from +15.2% to +21.4%. Decode speed is level in all 20 cells, within ±0.8%. No token rows differ, and the 65,536-token long-context cell passes on both sides.

Not measured

Other CUDA GPUs with less memory haven't been run: a server that fits today could start with about 3.2 GiB less room, and TF_FLASHNEXT_CHUNK_SOLO=1536 restores today's passes.

Tests

A new host test in cuda_chunk.zig covers the default and that the variable still decides. test-cuda-host and the Linux compile-cuda-tests pass.

…2 rows

No other stream can wait on a pass there, and fewer passes read each expert fewer
times. On one GB10, a 65,536-token prompt's first token goes from 35.5 s to 29.5 s for
3.2 GiB more scratch, with the same replies. TF_FLASHNEXT_CHUNK_SOLO still decides when
set; other servers and two ranks keep their passes. The known-issues note on these
passes is measured again.
@ashhart
ashhart merged commit e6f313b into main Nov 5, 2026
0 of 7 checks passed
ashhart added a commit that referenced this pull request Nov 7, 2026
Step: test-gradient-serving. Old pins: e166f3f. New base: 063d881 (origin/main).
Sets the hash of the 46 changed entries in gradient-serving.tsv to 063d881's bytes; paths,
modes (all raw) and note columns are unchanged. pocket-serving-approved.tsv needs no edit: its
entries for these files have prefix 0, so they never read the manifest hash. No code changes;
1/1 test passes.

Recorded, as merged and reviewed:
- #1784 (cf63ff6): Flash Next at --tp 2 splits dense output columns with exact FP32 gathers.
- #1784 (cde4fe7): the BF16 prompt tile folds a pinned (cut) weight's whole K-slice order.
- #1942 (15f118a): a shared round's DeltaNet steps run as one launch over its lanes.
- #1792 (52b9f90): the whole shared expert's down writes straight into its output slot.
- #2160 (a54748a): beside another open stream a greedy chain stops at 0.6 a draft; wide
  rounds draft 6 deep.
- #2246 (4294752): at --parallel 1 on one GPU a prompt pass takes 8,192 rows.
- #2214 (e4d7f13): kept prompt states with drafts across ranks.
- #2230 (1f2c993): Gemma 4's PLE kernel in its own image; controls and blob constant.
- #2103 (a3962b4, 194115d): synchronous downloads stage through a pinned bounce, on
  integrated devices only, and the bounce counts in memory use.
- #2289 (e9ee738): the remaining synchronous readbacks use that staging; close() releases it.
- #2127 (b2c277a): the lane host's KV ledger counts the paged pool's promises.
- 4fb2f65, 60d80da, 8cc6ac4, 36a87df, 41ff25d, efdf28f, fcb1529, f3bcb78,
  ecef17d, 2ebc3c2, 42d3461, a86c31c, 1913a46, 80218cd: comments, verbatim moves,
  test-block imports, exports, and opt-in or off-by-default paths only.
@ashhart
ashhart deleted the lead/fn-solo-lone branch November 10, 2026 16:34
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