Skip to content

qwen38: run the delta rule's z and the attention's q on the side stream - #697

Merged
juliankang4 merged 1 commit into
midagedev:mainfrom
juliankang4:dgx-spark-q38-gdn-side-stream
Oct 23, 2026
Merged

juliankang4 merged 1 commit into
midagedev:mainfrom
juliankang4:dgx-spark-q38-gdn-side-stream

Conversation

@juliankang4

Copy link
Copy Markdown
Collaborator

Qwen3.8의 GDN 층과 QSA 층에서 큰 projection 하나를 side stream으로 옮겨 다른 projection과 겹쳐 돌리므로, MTP를 켠 짧은 요청의 처리량이 올라갑니다.

Part of #565. It closes the open line "GDN projections on a side stream beside the routed experts, on Qwen3.8".

What and why

In a delta (GDN) layer, the z projection is read only by the gated norm, after the delta step. In a selecting (QSA) layer, the q projection is read only by the q/k norm, after the indexer's keys and queries. Each is a large gemv, and each runs next to a chain of small, latency-bound launches that do not read its output. The walk now forks its existing Branch (the stream owner the shared expert already uses), runs z or q on the branch beside that chain, and joins before the first reader. The kernels, launches and bytes are the same. The captured graphs keep their node counts, 1295 for a decode step and 1331 for a 4-row verify, and each fork and join adds one event record and wait that a capture turns into edges.

Ctx38::dense_gemv_on is the stream form of dense_gemv. shared now calls it too, which removes its three spelled-out site::resident_gemv_cols_on calls. All three walks that go through Parts38::front take the change: the captured step, the captured verify (MTP verify and multi-slot decode) and the eager walk of up to 8 rows. Prompt batches of 9 rows or more use the GEMM walk in wide38, which this PR does not touch.

The gain is limited to MTP with two short requests. With MTP on and two short requests, total tok/s rose by 2.04% and 2.49% in two sittings, and the steady all-active rate by 2.55% and 2.48%. The same tree varied by 0.34% (main) and 0.11% (head) between the two sittings. With the draft off no group moved beyond that spread, and none was slower beyond it.

Release notes: Changed: Qwen3.8 runs the delta rule's z and the attention's q projection beside the other launches of the layer, which raises decode throughput with MTP at two short requests.

Code shape

  • No second copy. The fork and join reuse graph::Branch and the walk's existing branch. dense_gemv_on is the only new item, with five callers, and dense_gemv delegates to it.
  • Model code holds only architecture facts. The change is Qwen3.8 scheduling in program38.rs. The common owner graph::Branch is unchanged.
  • Dead code is gone. The three spelled-out stream gemv calls in shared are removed.
  • No silent failure. fork, every launch and join propagate with ?. On an early error the fork's drop joins, so a capture never ends with an open branch.
  • Comments state what is true now. No dates, issue numbers or numbers in the source comments.
  • No relaxed gate. No band, tolerance or lint moved.
  • cargo fmt passes on the file. cargo clippy has not been run on this head, so the lint count is unchecked.

Duplication found or removed (path:line), or "none": none. tools/dup-scan.py lists one candidate in the diff, qsa_qkv against qsa_query; they share only an arena destructure and a dense_gemv call.

What I ran

GPU Evidence

On an NVIDIA GB10, inside the build container and on the host:

| NVIDIA-SMI 595.84                 Driver Version: 595.84         CUDA Version: 13.3     |
|   0  NVIDIA GB10                    On  |   0000000F:01:00.0 Off |                  N/A |
| NVIDIA-SMI 595.84                 Driver Version: 595.84         CUDA Version: 13.2     |
|   0  NVIDIA GB10                    On  |   0000000F:01:00.0 Off |                  N/A |

just gate-gpu-qwen4exp-e2e and just gate-qwen38-serve not run: they load the Qwen3.8 GGUF set and reference sets, which the DGX Spark used here does not hold.

cargo check -p bloomery-gpu --lib
Finished `dev` profile [unoptimized + debuginfo] target(s) in 22.00s

Throughput with MTP and with the draft off

One GB10 loaded the server once per arm with FP4-Local as shipped (nvidia/Qwen3.8-Flash-Next-FP4-Local at b9ce18a6887e18c089fdea8509a33e63429a3300), --parallel 4, 128 generated ids per request, greedy, prompts from a code corpus. The prompts are 256 or 4096 ids and are sent at once. The GPU clock cap was lifted for each arm and restored afterwards. MTP arms ran at a fixed draft width, so both trees verify the same work; the width chooser would pick different counts per tree and compare different work. The second sitting ran the two MTP arms again in the opposite order, head first. The plain read ceiling of the card was 235.2 GB/s in the first sitting and 233.5 GB/s in the second.

Main binary SHA256 14f95cd480aadbc5338e8ac79438fa911b7062f64c93eedbdd01f3d9b3a4706e, head acaaac695917db4b4ca87c17978473fb6f87108d2e8b6b9938a846559e8aa26e.

Case (FP4-Local, one GB10) main head change
Two 256-id prompts, MTP, total tok/s, sitting 1 58.001 59.182 +2.04%
Two 256-id prompts, MTP, total tok/s, sitting 2 57.806 59.245 +2.49%
Two 256-id prompts, MTP, steady all-active tok/s, sitting 1 70.48 72.28 +2.55%
Two 256-id prompts, MTP, steady all-active tok/s, sitting 2 70.43 72.17 +2.48%
Two 4096-id prompts, MTP, steady all-active tok/s, sitting 1 67.87 68.41 +0.80%
Two 4096-id prompts, MTP, steady all-active tok/s, sitting 2 67.12 68.92 +2.68%
One 4096-id prompt, draft off, total tok/s, sitting 1 29.481 29.477 -0.02%
One 4096-id prompt, draft off, total tok/s, sitting 2 29.540 29.453 -0.30%
Two 256-id prompts, MTP, TPOT p95 ms, sitting 2 30.30 33.76 +11.41%

Change is computed from the two columns. With MTP on and two short requests, total tok/s rose 2.04% and 2.49% in two sittings.

Greedy ids equal main in all 13 requests of the first sitting for draft off and for MTP, and in all 13 requests of the second sitting for MTP.

What I ran into

This does not block the PR. Outside MTP at two short requests the change is flat in this measurement: one 4096-id request with the draft off moved by -0.02% and -0.30%, inside a sitting spread of 0.08% to 0.20%. In four-request groups the two trees sometimes drafted different counts, because which request drafts at each step follows arrival timing, so those rows do not compare the walk and are not used here.

One latency cell is worse. With MTP and two short requests, TPOT p95 in the second sitting is 11.41% higher on head, although the total rate rose by 2.49%. The two requests split unevenly at 29.62 and 39.85 tok/s, against 34.21 and 33.00 on main, with the same drafted and accepted counts, and p95 follows the slower request. At two to four requests this metric swings by about 11% either way across the sittings (-1.85% and -11.44% in the first). The cause of the split is not traced.

The measurements above ran on this patch before it was rebased onto the current main. The head that goes up is that patch rebased, and git range-diff shows it unchanged. The files main changed in between do not touch the forked launches or Branch.

Hardware

One NVIDIA DGX Spark (GB10), driver 595.84, CUDA 13.3 build image.

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 labels Oct 23, 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: CLEAN: The moved projections join before their readers, and no must-fix defect was found.

Non-blocking

⚠ Attach validation evidence: program38.rs:1069.
The move class needs identical PTX, graph counts, and eager/replay equality; the PR has no scan or owning-gate output. Attach those results before further scheduling changes depend on this ordering.
Each eager layer also adds two event records, two event waits, and one capture query [derived]. Include short eager-pass timing with both source commit hashes and benchmark commands/output; binary SHA256s do not identify the source commits.

Checked

Duplicates: 1 new item checked (dense_gemv_on); it reuses site::resident_gemv_cols_on and removes repeated call setup. Dryer reported 0 pairs.
Complexity: crapper flagged qsa 23 → 25 and gdn 20 → 21; growth is propagated join errors, with no new scheduling decision.
Silent failure: 0 new suppression sites. Launch and join errors propagate; early returns retain the existing Forked drop join.
Ordering: checked GDN norm, QSA single-sequence and slot readers, and branch reuse before the shared expert. Forks order the input producer; joins precede readers and buffer reuse.
Tests: none added or changed, so no test mutation applies. GPU builds and gates were not run during this review.
Gates: no pins, tolerances, tests, or clauses changed.
Escape catalog: C1–C4 do not match. No ledger lessons are in force.

Card check: needs-gpu. This pull request changes crates/gpu/src/arch/qwen3moe/program38.rs and carries no gate run on a card (CONTRIBUTING's evidence list); a maintainer adds gpu-verified after one.

🔨 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 78c3680 into midagedev:main Oct 23, 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 needs-gpu Changes code a card must check, and carries no gate run on a card

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant