Skip to content

app, gpu, qwen38: a load captures its rounds' passes and each slot's step and draft walks before it serves - #1096

Merged
juliankang4 merged 4 commits into
midagedev:mainfrom
juliankang4:dgx-spark-q38-spd-decode-graph
Nov 1, 2026
Merged

juliankang4 merged 4 commits into
midagedev:mainfrom
juliankang4:dgx-spark-q38-spd-decode-graph

Conversation

@juliankang4

@juliankang4 juliankang4 commented Nov 1, 2026 •

Copy link
Copy Markdown
Collaborator

Qwen3.8 디코드에서 다음 스텝을 응답 읽기 전에 먼저 실행하고, 로드 때 모든 슬롯의 그래프를 미리 캡처해서 FP4-Local 단일 요청 디코드를 1.05% 올립니다.

What and why

A greedy request's next step is now launched before the previous answer is read back (device token chaining), and a step's PLE rows are read on the host while the launch runs, so the GPU stays busy across tokens. A load also captures every round's passes, each slot's step and verify widths, and each slot's draft walks before the server accepts a request, so no request pays a graph capture on its first use. A save, a rollback, a reset or a slot change settles a step still launched ahead first, so a device fault that step raised is returned by that call instead of reaching the prompt cache. On FP4-Local Qwen3.8 at C=1 without a draft, decode goes from 31.44 to 31.77 tok/s (+1.05%, ranges apart); the other measured arms are within the measurement's resolution.

Release notes: Changed: Qwen3.8 decode launches a greedy request's next step before reading back the last answer, and a load captures every slot's graphs before serving.

Code shape

The review reads these first. A box left unticked needs one line of why.

  • No second copy. Logic two models (or two call sites) share has one common owner; I lifted it there instead of
    copying it (AGENTS.md "Common code first", docs/rust-quality.md R14). Where I found an existing copy, I
    named it below.
  • Model code holds only architecture facts. A model's own files carry only what its architecture forces
    (tensor shapes, the attention kind, the quant). A common owner gained no per-model branch, flag or trait method.
  • Dead code is gone. Nothing I made unused is left behind (functions, flags, gate clauses, docs).
  • No silent failure. Undefined input is a named error or panic, never a defined-looking output.
  • Comments state what is true now. No dates, issue numbers or how a bug was found (tools/check-comments.sh).
  • No relaxed gate. No band, tolerance or lint moved to make a check pass; a re-pin carries PIN(YYYY-MM-DD):
    and its reason.
  • cargo fmt and cargo clippy are clean on what I touched; the lint count did not go up.

Duplication found or removed (path:line): the step's node census had two copies (the Qwen3.8 seat and generate_qwen3moe); both now call step_census (crates/gpu-gates/src/nodes.rs:67, used at crates/gpu-gates/src/bin/shared/serve_seats/qwen38.rs:2896 and crates/gpu-gates/src/bin/generate_qwen3moe.rs:3239).

What I ran

Base is upstream cd7d88052e2f36dbf1b49e7c3996f49f7657f33a; PR head is f372621dbe91e1ed120dbf7b03e8b394406037b9.

Card (nvidia-smi):

$ nvidia-smi
Sun Nov  1 17:25:42 2026       
+-----------------------------------------------------------------------------------------+
| NVIDIA-SMI 595.84                 Driver Version: 595.84         CUDA Version: 13.3     |
+-----------------------------------------+------------------------+----------------------+
| GPU  Name                 Persistence-M | Bus-Id          Disp.A | Volatile Uncorr. ECC |
| Fan  Temp   Perf          Pwr:Usage/Cap |           Memory-Usage | GPU-Util  Compute M. |
|                                         |                        |               MIG M. |
|=========================================+========================+======================|
|   0  NVIDIA GB10                    On  |   0000000F:01:00.0 Off |                  N/A |
| N/A   53C    P8              5W /  N/A  | Not Supported          |      0%      Default |
|                                         |                        |                  N/A |
+-----------------------------------------+------------------------+----------------------+

+-----------------------------------------------------------------------------------------+
| Processes:                                                                              |
|  GPU   GI   CI              PID   Type   Process name                        GPU Memory |
|        ID   ID                                                               Usage      |
|=========================================================================================|
|  No running processes found                                                             |
+-----------------------------------------------------------------------------------------+
$ nvidia-smi --query-gpu=name,driver_version --format=csv,noheader
NVIDIA GB10, 595.84

Model: nvidia/Qwen3.8-Flash-Next-FP4-Local, revision b9ce18a6887e18c089fdea8509a33e63429a3300 (MODEL_FP4L below is its folder). SHA-256 of its files:

SHA256SUMS
b0ad2a8a314ca96618e21e40d50c0af6e181e6060f9cdd1996c7074d19284c1a  README.md
c3cf9e34abf4f9e36c2d72165aa9c132d3e2a725b6c2586aaa3a8af9d7a81041  chat_template.jinja
b50dbc52a0c83b0cd2a44a372c1fb6b5e0e6827d22f2611c97d4d030f92f6b28  config.json
e70c136c1b78ddc1fb0905bac8e733a4dc448d4f852a5dd75143fffc70be550e  generation_config.json
a9d356d7bdf1ef4949e3e748e95b8e10ad9d4e2e838eddc38a0a7b6b94d1db8d  merges.txt
5fa166bbb1cf25adda455117563efa72a2072272001f459eedece131ffc913e1  model.safetensors.index.json
27225450ac9c6529872ee1924fcb0962ff5634834f817040f444118116f4e516  preprocessor_config.json
ebf3648c5f4cd1f24e79789e7803498dc4e74cb52515cc515b2d22cf8161953b  tensors/model-00001-of-00021.safetensors
79a643fc5c024089cecd32ca27dc43e671cbec70ff3628b728909b7656ac43ec  tensors/model-00002-of-00021.safetensors
c45f942203db4c7f5a1071700b93b908495cc790271acddfff39091c2b953923  tensors/model-00003-of-00021.safetensors
071ab9cf963ca0f1a6a194b4cec485f5de18ef9804da915b2e6abd0eb0c707af  tensors/model-00004-of-00021.safetensors
f80d17870eb1d36917257494770984953476583c57737f61fdbd341c957b9715  tensors/model-00005-of-00021.safetensors
3e9183d4ebb267fa92429184d5132d302cb1a98fd049149e5d01dccd4ca65795  tensors/model-00006-of-00021.safetensors
aa1ad959c4d62e0bc4600fd0b57cc2939b463e9fb53dc01020e188552b52ce5a  tensors/model-00007-of-00021.safetensors
0b18844027be74b84b240f23bf3a744bc29b35de0bd384f41c40cd85e6339326  tensors/model-00008-of-00021.safetensors
2d0b6c66790c17f8b1fdcf442f541778c8f0a381aca26c11b9d7cfcf7c96f2f0  tensors/model-00009-of-00021.safetensors
3ed9bd73745aebf6dc136f437b67d6b9fc3d38d25ad84300b399164bc87a72b7  tensors/model-00010-of-00021.safetensors
4936ff28c6cc8b66653ddb9cae28bc284569a1a2f7116819a017dc1a0e517ed8  tensors/model-00011-of-00021.safetensors
dd7df5a6ff73e9960412243f744eab9ec35f4be40da5bb158dc4ba8796b33742  tensors/model-00012-of-00021.safetensors
28a455c8ea4ebaa847fb4cbed2bc1de9eff0b501dd3f848a3a3cfc38778e8500  tensors/model-00013-of-00021.safetensors
6941676e685abf9817d9c48a17fdeda20b2b72d16217555252aa4c602b7f98b8  tensors/model-00014-of-00021.safetensors
2a1129b5acfc24a45bf402aa63dcef08b531aedfdaf5233c65fd3d12dc303fdd  tensors/model-00015-of-00021.safetensors
635e97fbad78fa988647d407e2b58e55d551ef94d798c9b6fb5550de25e86429  tensors/model-00016-of-00021.safetensors
bf60d564d89a805b67f8be5f2847a1b1567a70dbc23d19754395c127568474ad  tensors/model-00017-of-00021.safetensors
c5bde22f9364e82eb25973456795592fdcb4b158bc2095898979a2566bf4c562  tensors/model-00018-of-00021.safetensors
da3dc3b4f428f5b9dd53362691043d0242f48d03adca9b7b553bd9f3a1e96350  tensors/model-00019-of-00021.safetensors
4978bb6b8480cfc02d3c8bc84ba86202889f5f10d090bb17c21fee663cea7683  tensors/model-00020-of-00021.safetensors
48203838f2c76921bddbf1cc51d20a23858c128821a21add55fa1778e5e25283  tensors/model-00021-of-00021.safetensors
0997f410c57a1f4e53b09e4be8f4a172d90edd9564368fb0847030937229b9f3  tokenizer.json
b11349aafa7cdc6a320767cf7ceb29ed82f7eda5d65e8e0819e76f0ce947bf27  tokenizer_config.json
7768af27c1fafa9cc9011c1dc20067e03f8915e03b63504550e11d5066986d13  video_preprocessor_config.json
ce99b4cb2983d118806ce0a8b777a35b093e2000a503ebde25853284c9dfa003  vocab.json

Decode A/B, PR head against base. Both builds:

git -C base checkout cd7d88052e2f36dbf1b49e7c3996f49f7657f33a
(cd base && cargo oxide build --arch "$(bash tools/arch.sh)" -- -p bloomery-gpu-gates --features glm5next,clef,vision,mimo2,solar2,minimaxm3,flint,gemma-embedding2,hf,checkpoint --release --bin bloomery-serve)
git -C head checkout f372621dbe91e1ed120dbf7b03e8b394406037b9
(cd head && cargo oxide build --arch "$(bash tools/arch.sh)" -- -p bloomery-gpu-gates --features glm5next,clef,vision,mimo2,solar2,minimaxm3,flint,gemma-embedding2,hf,checkpoint --release --bin bloomery-serve)

Plain decode at C=1 (fp4l-off), one server per round, 8 windows of 4,096-id prompts and 128 generated tokens, six rounds (three base, three head) after one discarded lead-in, base and head servers started from their own build folders. The base server and one client call (LOAD_CLIENT is the load-generating client script that posts the windows to /completion and writes the per-window decode tok/s):

env BLOOMERY_DRAFT=off BLOOMERY_HOST_ROOM=96G ./base/target/release/bloomery-serve -m "${MODEL_FP4L}" --host 127.0.0.1 --port 18731 --parallel 1 --ctx-size 16896 & server_pid=$!
until curl -fsS http://127.0.0.1:18731/health; do sleep 1; done
python3 "${LOAD_CLIENT}" load --port 18731 --ids "${CODE_IDS}" --prompt-len 4096 --n-predict 128 --count 1 --conc 1 --offset 0 --bound 0 --label fp4l-off-1 --temperature 0 --out fp4l-off-1-timed-code-fn-client.jsonl --window-plan sitting-windows.json --eos-shift 1024

The client line repeats at offsets 50000, 100000, 150000, 200000, 250000, 300000 and 350000. The other arms use the same client with these servers:

env -u BLOOMERY_MTP_DRAFT BLOOMERY_DRAFT=mtp BLOOMERY_HOST_ROOM=96G BLOOMERY_MTP_WIDTH=cost ./head/target/release/bloomery-serve -m "${MODEL_FP4L}" --host 127.0.0.1 --port 18731 --parallel 1 --ctx-size 16896    # fp4l-mtp, C=1
env -u BLOOMERY_MTP_DRAFT BLOOMERY_DRAFT=mtp BLOOMERY_HOST_ROOM=96G BLOOMERY_MTP_WIDTH=cost ./head/target/release/bloomery-serve -m "${MODEL_FP4L}" --host 127.0.0.1 --port 18731 --parallel 2 --ctx-size 16896    # fp4l-mtp-c2s, C=2
env BLOOMERY_DRAFT=off BLOOMERY_HOST_ROOM=96G ./head/target/release/bloomery-serve -m "${MODEL_FP4L}" --host 127.0.0.1 --port 18731 --parallel 2 --ctx-size 16896    # fp4l-off-c2s, C=2

with --count 2 --conc 2 --temperature 0.7 --seed 42 on the C=2 arms. Corpora SHA-256: code-fn 7520b471436fb307e91ee22640ad8100701d48e63e3da7de9160b705b92915d1, prose-en d10c7044df8884fdd200304604772d81a4b56a228f802d5f05db724b245ef77a. Greedy output is equal on base and head.

Decode tok/s, median of three rounds (base and head rounds on one card):

Arm Base Head Change Ranges overlap
fp4l-off code-fn (C=1) 31.44 31.77 +1.047% no
fp4l-off-c2s code-fn (C=2) 22.38 22.26 -0.527% yes
fp4l-mtp code-fn (C=1) 59.60 59.63 +0.055% yes
fp4l-mtp prose-en (C=1) 40.89 41.05 +0.389% yes
fp4l-mtp-c2s code-fn (C=2) 31.60 31.89 +0.905% yes
fp4l-mtp-c2s prose-en (C=2) 26.17 26.41 +0.925% yes

Only the first row separates from run-to-run spread; the rest are inside it, and no arm is slower beyond its spread.

Captures at load, none while serving. Each arm ran ./target/release/bloomery-serve --host 127.0.0.1 --port 18731 --parallel N --ctx-size 16896 (BLOOMERY_DRAFT=<off|mtp|lookup>, BLOOMERY_HOST_ROOM=96G, BLOOMERY_MTP_WIDTH=cost for mtp) under a CUDA API trace from the server start, with consecutive requests (three for the C=1 arm, two for the others) of python3 "${LOAD_CLIENT}" load --port 18731 --ids "${CODE_IDS}" --prompt-len 4096 --n-predict 128 --count N --conc N --offset <k*50000> --bound 0 --temperature 0, N being the slot count; the cuGraphInstantiate calls after the first request began were counted from the exported trace:

CARD-RESULT fp4l-mtp-c1 load_instantiates=9 served_instantiates=[]
CARD-RESULT fp4l-off-c2 load_instantiates=5 served_instantiates=[]
CARD-RESULT fp4l-mtp-c2 load_instantiates=42 served_instantiates=[]
CARD-RESULT fp4l-lookup-c2 load_instantiates=12 served_instantiates=[]

Load log of the --parallel 2 MTP arm:

capture verify rows=2 nodes=1237
capture verify rows=3 nodes=1237
capture verify rows=4 nodes=1237
capture rounds slots=2 rows=4 passes=24 slot_graphs=1

Fixture gates, run with BLOOMERY_BOX_LOCAL=1 BLOOMERY_BOX_CARD=local BLOOMERY_TIER=fixture just <recipe>:

GATE-RESULT e2e gate-gpu-qwen4exp-e2e tier=fixture rc=0
GATE-RESULT serve gate-gpu-qwen38-serve tier=fixture rc=0
GATE-RESULT mtp gate-gpu-qwen4exp-mtp tier=fixture rc=0

The e2e gate's ahead fault clause (a fault raised behind a step launched ahead is returned by the next save, lane save, rollback and reset), run as BLOOMERY_BOX_LOCAL=1 BLOOMERY_BOX_CARD=local BLOOMERY_TIER=fixture just gate-gpu-qwen4exp-e2e:

ahead fault: the step of 157377 launched ahead (true), a save -> saved, then the step_ahead of 157377 took it (true) (want launched, saved, taken) PASS
ahead fault: a fault behind the step launched ahead (true), then a save -> error "qwen4exp snapshot: device fault at the output head site logit (a head logit not finite); sites raised in the output head (Qwen35moe step order): logit", then a reset clears it (true) (want the fault, poisoned by it) PASS
ahead fault: a fault behind the step launched ahead (true), then a save on a lane -> error "qwen4exp snapshot: device fault at the output head site logit (a head logit not finite); sites raised in the output head (Qwen35moe step order): logit", then a reset clears it (true) (want the fault, poisoned by it) PASS
ahead fault: a fault behind the step launched ahead (true), then a rollback -> error "GpuModel::rollback: device fault at the output head site logit (a head logit not finite); sites raised in the output head (Qwen35moe step order): logit", then a reset clears it (true) (want the fault, poisoned by it) PASS
ahead fault: a fault behind the step launched ahead (true), then a reset -> error "GpuModel::reset: device fault at the output head site logit (a head logit not finite); sites raised in the output head (Qwen35moe step order): logit", then a reset clears it (true) (want the fault, poisoned by it) PASS
clauses: 28 ran, 9 left to the real tier
gpu-gate.sh: gate_qwen4exp_e2e ran 439 s (exit 0)

Compile check of the changed crates:

cargo check -p bloomery-gpu-gates --bins --features glm5next,clef,vision,mimo2,solar2,minimaxm3,flint,gemma-embedding2,hf,checkpoint,gpu
cargo check -p bloomery-gpu-gates --bin bloomery-serve-qwen38 --features deepseek41,gemma-embedding2,hf

Both finish with rc 0.

Hardware (if the change is for a machine)

Card Driver CUDA
NVIDIA GB10 595.84 13.3

All numbers above were measured on this card.

AI help

AI 코딩 에이전트가 코드를 작성한 후 설명을 썼고, 테스트를 마쳤습니다. diff 리뷰와 PR 초안 리뷰는 제가 직접 했습니다.

@github-actions github-actions Bot added gpu The card engine: crates/gpu*, crates/app needs-gpu Changes code a card must check, and carries no gate run on a card serve The HTTP server: crates/serve labels Nov 1, 2026

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict: MUST_FIX: stopping generation can leave an ahead-step device fault unreported and save its state.

Must fix

1. Check the last ahead step before its state can be saved (kind A)

crates/gpu/src/model.rs:1441 copies the previous step's fault words before launching the ahead step. With one slot, graph mode, no draft, and token budget remaining, a greedy EOS answer is evaluated ahead. A non-finite value in its untied BF16 embedding raises a device fault, but the call returns the previous step's clean result. Generation stops without another readback. crates/gpu/src/arch/qwen3moe/body38.rs:5423 checks only recorded poison and saves that state. crates/gpu/src/model.rs:1159 then clears the unread fault on a one-slot reset.

Catch this before prompt caches can retain condemned recurrent state across requests. Track and validate the pending ahead result before save/reset. Until that lifecycle check exists, insert this after the served match to validate the launched step before returning:

let served = served.and_then(|()| {
    head.copy_tokens(gpu)?;
    head.copied_token().map(|_| ())
});

This conservative fix waits for the ahead step. Add a device gate that raises a fault only in the ahead step, stops on its input token, and requires an error before a snapshot succeeds.

Non-blocking

⚠ Refresh the revision evidence: crates/gpu/src/model.rs:1385. The reported gates and A/B name 0dbe02c → 3c70dec; this review covers 547a846 → 59d1df5. Attach the owning gates and dispatch A/B for this pair, or establish that the tested patches are identical. Resolving that now makes the reported speed change attributable to the code being merged.

Checked

Silent failure: traced the copied readback, host service on a card-only load, poison recording, synchronous and asynchronous snapshots, and reset. Successful results do not read the ahead step's fault.

Tests: the added API test compares plain and ahead mock answers and saved token counts. It does not exercise device faults.

Gates: the unsafe-count change carries a dated PIN reason. The PR supplies no FAIL-first output for the added tests.

Escape catalog: no matching pattern. Ledger: no lessons in force.

Notes

Static review only. No build or device gate was run here.

Card check: gpu-evidence. This pull request changes crates/app/src/lib.rs, crates/gpu-gates/src/bin/gate_qwen4exp_e2e.rs, crates/gpu-gates/src/bin/generate_qwen3moe.rs … and carries a gate run on the author's card, which counts as verified.

🔨 Shingler, bloomery's review bot: approves a clean pull request and requests changes on a must-fix (how it works)

@github-actions github-actions Bot added gpu-evidence Verified on the author's card: the pull request carries the gate run and its output and removed needs-gpu Changes code a card must check, and carries no gate run on a card labels Nov 1, 2026
…ts answer is read back

A greedy request that reads no row feeds every answer back unless it
stops there. The server now tells the engine so (Engine::next_ahead), and
on one slot the engine may launch the answer's step on the card, its
input copied from the head's argmax there, before the host reads the
answer back. The next next_ahead of that answer takes the launched step
and feeds nothing; any other call keeps the answer fed. The engine says
which it did (Ahead), and the slot books what the engine fed, so what
the slot holds is what the engine holds at every end of a request.

GpuModel::step_ahead chains the step behind the one in flight: the
body stages its input from the card (ChainBody::refresh_chained), the
head's readback is copied behind the step before, the replay is launched,
and the body hears the answer before its host service
(ChainBody::chained_token). The Qwen3.8 body takes it: its PLE arrival
flag is lowered by the stream between the two walks, and the answer's
PLE rows are named and delivered once it is read back.
…step and draft walks before it serves

A pass of several slots was captured on the first round that ran its key
(the busy slots and their row counts), so a decode paid the capture and
the instantiation of each new key. A parked slot's own graphs, its
one-token step and its MTP draft's walks, were captured the same way on
its first lone step or chain, and so were the live slot's draft walks on
a load of one slot. Session::capture_rounds captures every key the rounds
of the load's slots run, each busy set in slot order at each row count,
cut as a round cuts them, then each slot's own graphs
(GpuModel::capture_each_slot: the step, and GpuModel::capture_seq, which
ChainBody::capture_seq answers; Body38 with every walk key its draft
replays). The Qwen3.8 seat calls it at load for two slots: the drafted
rounds up to a verify's rows a slot, the plain rounds of a row. The
shared SlotDrafts::open captures each slot's draft walks beside its
verify widths, so a load of any slot count serves its first proposal
from captured walks.
@juliankang4
juliankang4 force-pushed the dgx-spark-q38-spd-decode-graph branch from 59d1df5 to f372621 Compare November 1, 2026 19:01

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since the last review:

Verdict: CLEAN: the interdiff closes the pending-fault defect and introduces no proven blocker.

Non-blocking

⚠ Refresh the revision evidence: crates/gpu-gates/src/bin/gate_qwen4exp_e2e.rs:2363. The gate and A/B evidence names 0dbe02c → 3c70dec; this review covers e9f238b → f372621. Attach current-revision owning-gate output, FAIL-first output for ahead_fault, and the dispatch A/B, or establish tested-patch equivalence. This ties the reported results to the code being merged.

Checked

Duplicates: 3 new items checked; no duplicate owner. Both dryer pairs read: builders share syntax but set different facts; their patches are unchanged since the prior review.

Complexity: new ahead_fault is 22, from four handoffs and result formatting. run grows 57 → 59 by calling the new clause. The remaining flags (launch_chained, SeatEngine::spawn, card_structure, Head::with_gain) are unchanged in the interdiff.

Silent failure: 7 handoff sites followed. Saves, reset, rollback, seed-depth changes and slot switches propagate pending faults before changing state. A second save is refused by poison; a subsequent reset clears it.

Tests: static mutation analysis of the new gate: deleting body38.rs:5426 or model.rs:1154 makes its fault check fail. Clearing ahead on a clean read makes next.took fail. The gate aggregates these checks into its error result.

Gates: no pins or thresholds moved in the interdiff.

Escape catalog: C1–C4 do not match. No ledger lessons are in force.

Notes

Static review only. No build or device gate was run here.

Card check: gpu-evidence. This pull request changes crates/app/src/lib.rs, crates/gpu-gates/src/bin/gate_qwen4exp_e2e.rs, crates/gpu-gates/src/bin/generate_qwen3moe.rs … and carries a gate run on the author's card, which counts as verified.

🔨 Shingler, bloomery's review bot: approves a clean pull request and requests changes on a must-fix (how it works)

@juliankang4

Copy link
Copy Markdown
Collaborator Author

The review is done and the contribution check passed, so I'm merging this.

@juliankang4
juliankang4 merged commit 990a5cc into midagedev:main Nov 1, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gpu The card engine: crates/gpu*, crates/app gpu-evidence Verified on the author's card: the pull request carries the gate run and its output serve The HTTP server: crates/serve

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant