Skip to content

qwen3_5 cuda: decode MLP gate and up as one segmented launch off GB10 (TF_QWEN_MLP_SEG, default off) - #6163

Open
jojomondag wants to merge 1 commit into
ashhart:mainfrom
jojomondag:qwen-cuda-mlp-one-launch
Open

jojomondag wants to merge 1 commit into
ashhart:mainfrom
jojomondag:qwen-cuda-mlp-one-launch

Conversation

@jojomondag

Copy link
Copy Markdown
Contributor

What this changes

Off GB10, a drafted decode round of the dense Qwen3.8-27B launches each layer's MLP gate and up projections as two GEMV launches over the same input; the key and value projections of the same round already share one segmented launch, and GB10 already runs gate and up as one. With TF_QWEN_MLP_SEG=1 (default off), on a GPU with the split form (e.affine.split != null, every GPU but GB10), a decode window of 1 to 16 rows runs gate and up through projMany, the segmented launch the key and value projections take. No kernel is added or changed: gemvSeg gives each member the bits of its own decode() launch, so gate and up are the same words and replies are unchanged. Unset, nothing changes.

Checks on this head

  • Head commit: e37365463 on main 0ba35fe6d.
  • Lean checker, python3 tools/zig/lean_check.py, on the base and on this head: 88 and 88, the same findings (0 new).
  • Tests run, with the command and pass, fail and skip counts:
    • zig build -Dfixed-cpu test-host: exit 0, no failed step.
    • zig build test-qwen35-mlp-seg-host (reached by test-host): exit 0; with a wrong expectation planted (17 to 64 rows taking one launch), exit 1.
    • zig fmt --check build.zig zig and git diff --check: clean. zig build native -Dsm=120: compiles.
  • CI: not run yet on this pull request.
  • Not run, and why: SM classes other than 170 (one RTX 5090); several streams; windows of 17 to 32 rows (the wide verify pass on sm_120, left on today's launches); Metal, HIP, XPU (CUDA-only change). No kernel changes, so no kernel contract run.

Receipt

  • Main against branch: cells and numbers, or why they can't be run: the switch unset against set on the branch (unset is main's path), one RTX 5090, one server an arm (the switch is read once), order unset, set, set, unset in one run; --drafter --kv-cache fp8 --prompt-precision int8 --context 262144 --parallel 1, tools/bench_long_decode.py --tokens 256, sampled replies (T=1, seed 1234) and one greedy reply an arm and cell; tok/s is all tokens over all decode time of a cell's replies:

    message cached tokens unset (tok/s) set (tok/s) change tokens and output equal
    1,500 words 0 (read cold each time) 244.9 / 245.5 247.9 / 248.3 +1.2 % yes, 13 replies in each of the 4 servers
    24,000 words 20,480 218.7 / 218.7 220.5 / 220.8 +0.9 % yes, 13 replies in each of the 4 servers
    88,000 words 86,016 187.7 / 187.6 190.7 / 190.9 +1.7 % yes, 9 replies in each of the 4 servers

    Ten more starts on the first cell (four unset, then six set, 4 replies each): 249.2 to 249.9 tok/s unset, 253.0 to 253.2 set (+1.4 %), every reply equal to the first server's. No panic line in any server log. These ran on the tree before the commit named qwen3_5 cuda: decode MLP gate and up as one segmented launch off GB10 (opt-in TF_QWEN_MLP_SEG): decode +0.9 to +1.7 % on one RTX 5090, replies equal #6153; that tree differs from the head in one string, the issue number in the profile row.

  • Hash runs (tools/perf_receipt.py of ci: add tamper-evident performance receipt hash run and GitHub verifier #6078), on this head, base 0ba35fe6d against head e37365463, --pairs 2 --draft --check-draft, servers with --drafter --kv-cache fp8 --context 262144 --parallel 1; in all three the tokens are equal on all four prompts, the planted control diverged and drafted equals "draft": false (receipts attached in qwen3_5 cuda: decode MLP gate and up as one segmented launch off GB10 (opt-in TF_QWEN_MLP_SEG): decode +0.9 to +1.7 % on one RTX 5090, replies equal #6153 (comment)):

    run environment of both arms decode, base -> head (tok/s) change base against base
    control switch unset 347.93 -> 348.08 +0.04 % 0.29 %
    1 TF_QWEN_MLP_SEG=1 347.13 -> 348.63 +0.43 % 0.05 %
    2 TF_QWEN_MLP_SEG=1 347.27 -> 351.75 +1.29 % 0.14 %

    The two runs with the switch set, back to back, do not agree on the size (0.4 and 1.3 %); verify fails run 1 on the 0.5 % floor and passes run 2. The receipts are in the issue comment, not committed: a receipt committed on the branch cannot name the commit that holds it (the question is open on cuda w4a8: smaller tiles of the int8 prompt GEMM where the 128x128 grid leaves SMs idle (TF_QWEN_INT8_TILES, default off) #6098).

  • One start I cannot explain, as in the issue: in my first run of this branch, made while a compiler was building on the same host, one of the two set servers returned other replies than the other three from its first decode on. 62 further starts (30 unset, 32 set), 40 of them during a build and 8 under memory pressure, all returned the first server's replies. I kept that server's log and can send it.

  • Boxes it reaches: Qwen 3.5/3.8 dense with MLX affine 4-bit weights on CUDA off GB10, decode windows of 1 to 16 rows, only with the switch set. Prompt rows, windows of 17 or more rows, learning runs, EXL3 and ModelOpt MLPs and GB10 (its own one-launch path) keep their launches.

  • New switch? Default, accepted values, profile row: TF_QWEN_MLP_SEG, 0 or 1, unset 0, profile class identical, in docs/environment.md, docs/environment-names.md, platform/environment.zig, environment_valid_cases.zig, core/profile.zig and the CLI's environment list. No stored-data change.

  • Environment, with the TensorFold commit, Zig and backend toolchain, machine and GPU, checkpoint and revision: head e37365463 on main 0ba35fe6d, zig build native -Dsm=120, Zig 0.17.0, nvcc 13.4; one RTX 5090 32 GB (170 SMs), driver 615.78.08, Ryzen 7 9800X3D, Linux, nothing else on the GPU during a timed run; TensorFold/Qwen3.8-27B-MLX-4bit@22d8d538, drafter z-lab/Qwen3.8-27B-DFlash2@50307d4c.

  • Paths and platforms the change reaches, which I ran and which I could not: ran on sm_120 (170 SMs): one stream, drafted, greedy and sampled, cold and 20k/86k cached. Could not run: other SM classes, several streams.

  • Exactness, from tools/bench_concurrent.py --alone --serial or token_sha against "draft": false: the fixture's token and output hashes in every server (one start excepted, above), and the hash runs' four prompts (base and head token-equal, drafted equal to "draft": false).

  • Main against this branch, same machine and checkpoint, posted before asking for a run on our machines (or why you can't): the table above (unset is main's path) and the hash runs (main's binary against the head's).

  • Decode speed before and after, from tools/bench_openai.py: the tables above.

  • Prompt speed before and after: n/a, the switch is read only for decode windows of 1 to 16 rows.

  • Licence of any new weights or drafter, or "n/a": n/a

Checklist

  • The title and description match the head commit, including the receipt and the stack.

  • New tests fail before the change, pass after it, and skip cleanly without their dependency.

  • Comments and docstrings are one line. No measurements or history in the source.

  • No personal data, machine names, internal hosts or local paths in the diff or its commits. No AI attribution lines.

  • Every token still goes through the lane rounds. No serial path, and nothing that needs drafts off.

  • Drafted output equals "draft": false, a resumed prompt equals a fresh one, and concurrent equals solo. Drafted against "draft": false is shown by the hash runs on one prompt; a resumed prompt against a fresh one and concurrent against solo were not run on this change.

  • No precision traded for speed. If the bits change, the description says which sums change and why.

  • Decode and prompt processing are no slower than main at one stream and the widest admitted; with --drafter, no slower than without it, greedy and sampled. Measured: one stream with --drafter. Several streams and the drafter off were not measured.

… (TF_QWEN_MLP_SEG, default off)

With the switch set, a decode window of 1 to 16 rows on a GPU with the split form runs the dense MLP gate and up
projections through projMany, the segmented launch the key and value projections already take, instead of two
launches. Each member keeps the bits of its own decode launch. Prompt rows, wider windows, learning runs and GB10
are unchanged.

Refs ashhart#6153
@ashhart ashhart added kind:perf Classified by Synthena as performance improvement synthena:needs-device Initial diff review passed; waiting for device and slowdown check before READY labels Dec 3, 2026
@ashhart

ashhart commented Dec 3, 2026

Copy link
Copy Markdown
Owner

Synthena Initial Review — Initial diff check passed (awaiting device run) (kind:perf)

Adds TF_QWEN_MLP_SEG (default off) so off-GB10 CUDA decode windows of 1-16 rows run the dense MLP gate and up projections through the existing segmented projMany launch instead of two separate GEMV launches, with no kernel changes.

  • Touches runtime, kernel, or serving paths; awaiting device and performance verification before landing.
  • Synthena

@jojomondag

Copy link
Copy Markdown
Contributor Author

The red zig check on e37365463 is the serving pin, not the change: test-gradient-serving pins the sha256 of zig/src/platform/environment.zig in zig/tests/fixtures/gradient-serving.tsv, and this branch adds the switch's row to that file. Merged with main 863406e4d the file hashes to 83b0b961c9a3e46e0d1e6bf19349fc20098fdce6d60e251b6c211dfa4d9e40df against the pinned b79e6ed9…; it is the only pinned file the branch touches. It is the same one-line re-pin as your adapt: commits on #6095 and #6098.

I have not pushed it, since the hash is only right against the main it lands on and changes again when #6095 or #6098 lands first. If you would rather have it from me, say so and I merge main and re-pin.

@ashhart

ashhart commented Dec 5, 2026

Copy link
Copy Markdown
Owner

Thanks @jojomondag for the switch, the receipts and the pin diagnosis.

What stands: the change is one gated condition and a 28-line module, the switch is default-off and registered as a profile-identical flag, the launch is the existing segmented projMany path that already serves the key and value projections, and each member keeps the bits of its own launch. Your RTX 5090 table shows tokens equal in every cell with +0.9% to +1.7% decode, and the hash runs show base and head token-equal with drafted equal to "draft": false. The one unexplained start among 63 is logged and does not recur, which is the right way to leave it.

What we still need is the A/B on our side, plus the cells your own checklist leaves open: a resumed prompt against a fresh one, and concurrent against solo, were not run on this change. Several streams and the drafter off were also not measured. The serving pin is the other open item — the re-pin depends on which main it lands on, so it stays with the landing.

The A/B: RTX 5090, Qwen3.8-27B MLX-4bit with the DFlash2 drafter, the switch unset/set/set/unset in one run, token equality per cell, and the resumed-versus-fresh and concurrent-versus-solo cells added.

  • Synthena

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

kind:perf Classified by Synthena as performance improvement synthena:needs-device Initial diff review passed; waiting for device and slowdown check before READY

Projects

None yet

Development

Successfully merging this pull request may close these issues.

qwen3_5 cuda: decode MLP gate and up as one segmented launch off GB10 (opt-in TF_QWEN_MLP_SEG): decode +0.9 to +1.7 % on one RTX 5090, replies equal

2 participants