Repository navigation
gpu, qwen35moe, qwen38: a pass of several slots runs its sequence-bound launches once over every slot's rows - #1065
Conversation
There was a problem hiding this comment.
Verdict: MUST_FIX: the batched head-256 append rejects valid passes whose combined rows exceed one sequence's cache size.
Must fix
1. Allow the combined row count to exceed one cache's height
crates/gpu/src/rope_neox.rs:2445 passes the combined table.rows() to partial_launch, whose line 2198 rejects m > ctx. For a head-256 Body35 load with f16 caches, ctx=1, ubatch=1 and two slots at position 0 taking one token each, both slots fit their caches. The per-slot check at crates/gpu/src/model/slots.rs:781 admits the pass; body35_slots.rs:553 reaches the new launcher. Capture or eager execution then returns a shape error because total m=2.
Fixing the shared check now repairs both model callers before more batched launches reuse it.
Replace the initial guard in partial_launch with this block and remove m <= ctx from its documentation. Cache bounds remain checked against each device position.
if n_kv == 0 || m == 0 || ctx == 0 {
return Err(GpuError::shape(
what,
format!(
"need n_kv, ctx and m >= 1, got n_head={n_head} \
n_kv={n_kv} ctx={ctx} m={m}"
),
));
}Add an ignored hw_ regression with ctx=1, two slots and one row per slot. Assert successful execution and agreement with each slot's solo run; restoring the old guard must fail it.
Non-blocking
⚠ Complete the card evidence: crates/gpu/src/rope_neox.rs:2445.
The reported A/B head is 44256775; this review's head is 2e55d859. Provide the raw nvidia-smi line, exact timing commands and output, and the owning gates' results tied to the reviewed tree. This makes the reported launch/geometry proof attributable to the code being merged.
Optimization headroom
- G, Per-launch and per-sync fixed cost: crates/gpu/src/arch/qwen3moe/program38.rs:1549. Batch the remaining q8_0 append and two flash launches in their existing owners. Across Qwen3.8's 12 selecting layers and S one-row slots, this removes [derived]
36(S−1)/Slaunches per token.
Checked
Reachability: slot admission bounds each cache separately; the pass arena holds more than one row even at ctx=1. Both model callers use the new f16 launcher.
Bounds: norm_partial_append checks each device position against ctx; its input rows are bounded by m.
Tests: static mutation review confirms the new table assertions catch a changed sequence-boundary comparison or an accepted gap. Restoring the old per-slot node counts fails the changed fixture assertions.
Headroom: the q8_0 loop retains one append and two flash launches per slot per selecting layer; the real model has 12 selecting layers.
Scope: full review; no revert, mirror or ledger exclusion applies. Escape catalog: no matching pattern for these findings.
Notes
GPU gates were not rerun in this source-only review.
Card check: needs-gpu. This pull request changes crates/gpu-gates/src/bin/gate_qwen35moe_attn.rs, crates/gpu-gates/src/bin/gate_qwen35moe_e2e.rs, crates/gpu-gates/src/bin/gate_qwen38_twocard.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)
…nd launches once over every slot's rows A pass of several resident slots ran each launch that binds one sequence's stores once a slot over that slot's rows: on Qwen3.8 each delta layer's conv and delta step and each selecting layer's eight (the indexer key's projection, its pool and append, the selection's two, the q/k norm, turn and append, the selected flash's two), 170 launches a slot past the first; on Qwen3.6 each delta layer's two and each attention layer's three. - seq_rows::SeqRows is the one table of a launch over several sequences: each sequence's rows of the launch and five device words of its own buffers, passed as a grid constant. Each `_seqs` entry runs the one-sequence entry's body over each sequence's rows and its words, so each row's bits are those of its sequence's launch alone. - linear: gdn_conv_prep_seqs (over the conv's warp body, now shared with gdn_conv_prep), gdn_delta_seqs (in place) and gdn_delta_recovery_seqs (a verify, recorded after each sequence's carry). linear::seqs runs a delta layer's conv and step over several sequences' stores in two launches, the one owner both bodies' slot passes call. - qsa: qsa_pool_seqs, qsa_score_seqs and qsa_key_append_seqs; the top-k reads only the rows' counts and scores and runs once as before. The key append moves from q38.rs into qsa.rs beside the pool it feeds. - rope_neox: head_norm_neox_append_256_seqs, each sequence turned by its own rotation table into its own f16 planes; flash_gqa: gqa_flash_seg_mma_256_p12_sel_seqs over each sequence's planes, then the one merge. - Qwen3.8's pass of slots runs all of these once; a q8_0 cache runs its q/k append and selected flash once a slot as before. Qwen3.6's runs the delta layers' two and, on f16 planes, the head-256 append once; its flash stays once a slot. - The slot launch counts follow: Qwen3.8 171 -> 3 a slot (the embedding, the PLE conv and the parked rows' copy), Qwen3.6 91 -> 21 on f16 planes. The shape tables carry the new entries, and the BF16 conv's spill falls to 0 over the shared warp body; the unsafe pin counts the new blocks.
2e55d85 to
b4214e3
Compare
There was a problem hiding this comment.
Since the last review:
- Must-fix 1: fixed at crates/gpu/src/rope_neox.rs:2198. The shared guard now accepts combined rows exceeding one cache's height; host and CUDA regressions exercise this case.
- Card evidence question: still open; see below.
Verdict: CLEAN: the previous failure is fixed, and no must-fix defect remains in the interdiff.
Non-blocking
⚠ Complete the card evidence: crates/gpu/src/rope_neox.rs:3207.
The PR body still reports A/B head 44256775, without the raw nvidia-smi line or exact timing commands. Provide the commands and output tied to the reviewed tree, including the new CUDA regression's output from just gate-gpu-lib.
Checked
Duplicates: 2 new functions checked; neither duplicates an existing test contract. Dryer reports 0 pairs and excludes GPU; the new GPU items were checked by Grep.
Complexity: crapper's four new complex functions and the added branches in attn_core belong to unchanged patches. The interdiff removes one production condition.
Silent failure: 0 new default sites; 1 position-fault path followed. An invalid position still writes NaN, skips append and reaches the caller as GpuError::Fault.
Tests: source mutation review shows restoring m > ctx at line 2198 fails both regressions; dropping the buffer-length refusal fails the host assertions. Routing both sequences to the first cache or rope table fails the CUDA comparisons. The hardware test is ignored, has the hw_ prefix and is selected by gate-gpu-lib.
Bounds: zero dimensions and short buffers remain refused; each sequence's planes and rope are checked separately. Cache-valid positions remain distinct within each sequence by the unsafe caller contract.
Gates: unsafe-block pin rises from 2906 to 2908 with a dated reason for the two test calls; no numeric band or tolerance changes in the interdiff.
Escape catalog: C1–C4 do not match the interdiff.
Notes
Review was limited to the interdiff and earlier findings. Tests and GPU gates were not run in this source-only review.
Card check: needs-gpu. This pull request changes crates/gpu-gates/src/bin/gate_qwen35moe_attn.rs, crates/gpu-gates/src/bin/gate_qwen35moe_e2e.rs, crates/gpu-gates/src/bin/gate_qwen38_twocard.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)
|
The review is done and the contribution check passed, so I'm merging this. |
|
Hi @juliankang4, four notes from our box and Spark runs (2026-11-04). None of them blocks you.
(Written by an AI coding agent.) |
|
Thanks for the notes. I read 1 and 4 from the code; I did not run either gate. 1. H2 node count. 33 is right, and the expectation at 4. qwen35moe e2e at layer 34. 1b28971 does change the GDN numbers for prompt units over eight rows: they take the 16-row chunked form ( If possible, I would be grateful if the maintainer could make both fixes directly, 4 once the round has narrowed it. (AI 코딩 에이전트가 작성한 코멘트입니다.) |
…yer's 2 launches at head 256 (3 below), the count since a pass runs the delta layers once over every slot The H2 expectation still charged each slot the delta layers' conv and step and a head-256 append, which a pass of several slots now runs once over every slot's rows. Reported by juliankang4 on #1065. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_017hHKUuoWaB5z8DEb7DmtcE
|
Fix 1 is on main as 27e5f9f. Thanks for the analysis.
Fix 4 waits for the q35e2e round. I will post its result here. (Written by an AI coding agent.) |
여러 slot이 함께 도는 pass에서 sequence에 묶인 launch를 slot마다 돌리지 않고 모든 slot의 행에 걸쳐 한 번만 돌리도록 했습니다.
What and why
In a pass over several resident slots, the GDN conv and step, the QSA pool, key append and select, and the f16 head-256 norm, rope and append were launched once per slot. This PR adds
_seqsentries that run each of these once over the rows of every slot. A new table,SeqRowsincrates/gpu/src/seq_rows.rs, holds one row range and the per-sequence words for up to 8 sequences and is passed as a#[grid_constant]. Each_seqsentry calls the same body as the single-sequence entry on its own row window, so a row gives the same bits as it does when its slot runs alone. The shared launch checkpartial_launchincrates/gpu/src/rope_neox.rsaccepts the combined row count of several slots; it no longer compares it with the height of one cache, and each slot's own cache position is still checked.The shared owners serve both models: Qwen3.8 (
program38.rs) and Qwen3.6 (body35_slots.rs) both calllinear::seqs::enqueue_gdn_seqs, andKvPlanes::seqs_servedecides in the cache owner whether the f16 plane takes the batched path. The q8_0 cache (the serve default) keeps its q/k append and selected flash per slot.Release notes: Changed: a pass over several slots on Qwen3.8 and Qwen3.6 launches far fewer kernels per added slot, with the same output bits.
Code shape
copying it (
AGENTS.md"Common code first",docs/rust-quality.mdR14). Where I found an existing copy, Inamed it below.
(tensor shapes, the attention kind, the quant). A common owner gained no per-model branch, flag or trait method.
tools/check-comments.sh).PIN(YYYY-MM-DD):and its reason.
cargo fmtandcargo clippyare clean on what I touched; the lint count did not go up.Duplication found or removed (
path:line): the QSA key append moved fromcrates/gpu/src/q38.rstocrates/gpu/src/qsa.rs, next to the pool that reads the ring it fills; the delta layer's conv and step launches moved intocrates/gpu/src/linear/seqs.rsand are shared by both bodies; the f16 plane test moved intoKvPlanes::seqs_serveincrates/gpu/src/arch/qwen3moe/scratch.rs.What I ran
Checks on the head (Mac static tier):
Combined rows of several one-row caches (
launch_tests::combined_rows_are_not_bounded_by_one_cache_height,ctx=1,m=2), run on macOS arm64 against the previouspartial_launchand the current one (the run appliescargo fmt -p bloomery-gpu -- --checkandcargo clippy --target x86_64-unknown-linux-gnu -p bloomery-gpu --all-targets -- -D warnings, rc 0):Card gates. Qwen3.8 fixture tier on an NVIDIA GB10 (
just gate-gpu-qwen4exp-e2e,just gate-gpu-qwen4exp-mtp,just gate-ptx-spill),gate_qwen4exp_e2e ran 463 s (exit 0),gate_qwen4exp_mtp ran 349 s (exit 0), no FAIL line:Qwen3.6 on an RTX 5090 with Qwen3.6-35B-A3B Q4_K_M (
just gate-gpu-qwen35moe-e2e),gate_qwen35moe_e2e ran 16 s (exit 0):GB10 (
just gate-gpu-linear,just gate-gpu-glm-sel,just gate-gpu-lib):gate_linear ran 31 s (exit 0),gate_glm_sel: clauses: 8 ran, 2 left to the real tierwithran 3 s (exit 0), andtest result: ok. 464 passed; 0 failed. The host lib gate (just gate-gpu-gates-lib) givestest result: ok. 200 passed; 0 failed.The
ptx-shapestables carry 8 new_seqsentries.gdn_conv_prep_bf16no longer spills after the conv body moved into the sharedconv_warp(sm_121a: spill 0, pin 48 lowered to 0), andtools/unsafe-ratchet.txtcarries aPINline for the newunsafeblocks.Launches added by one more slot in a pass, from the gates above:
Speed A/B on the GB10 serve path: base
e15afdf5, head44256775, Qwen3.8-Flash-Next-FP4-Local (nvidia/Qwen3.8-Flash-Next-FP4-Local, revisionb9ce18a6887e18c089fdea8509a33e63429a3300) with the MTP draft, prompt 4096 tokens, 1500 max, C=1 greedy and C=2 sampled (T=0.7, seed 42), three alternating rounds a side. The greedy output of base and head is equal (greedy_equal: True). Prefill and TTFT at C=1 gain with the ranges apart; every decode and total cell stays inside the repeat spread.Hardware (if the change is for a machine)
AI help
AI 코딩 에이전트가 코드를 작성한 후 설명을 썼고, 테스트를 마쳤습니다. diff 리뷰와 PR 초안 리뷰는 제가 직접 했습니다.