Repository navigation
gpu: Qwen3.8's ubatch walk allocates its BF16 streams and normed streams at their width - #1001
Conversation
…eside it A verify of a GDN layer (MTP's rows and every slot of a joint pass) records each row's key, rounded update scalar and head decay in a record buffer of its own instead of two spare state lanes, so its replay at the commit reads the record and writes the kept state into the one lane in place. Each of the 36 delta layers of a slot holds 3 MiB of state and a 288 KiB record of four rows, where it held 12 MiB of four lanes: 314 MiB less a slot, draft on or off. The replay table carries the record's address beside the state, stamp and carry; its overlap check covers the record. The verify's row count is its own constant (`DELTA_VERIFY_ROWS`), apart from the state's lane count, and the plan counts the lane's stamp and the record.
…ams at their width The ubatch walk carries its residual streams as BF16 values in the stream buffer other than the final one, so that buffer is allocated at a halfword a value: 20,480 B a ubatch position less, 80 MiB at 4,096 positions, which the plan's arena count follows. On a dense MMA card where every HC mix has a BF16 down, the wide mixes norm their streams into BF16 words alone, so the wide HC scratch holds the normed streams at a halfword a value too, another 80 MiB at 4,096 positions: the BF16 down's span check counts those words two values a word, and a mix that norms into F32 values on such a scratch is refused by name before any launch. The Qwen3.8 file's plan figures (kv, scratch, each card's experts and the largest context) move with the delta stores' record and this buffer.
There was a problem hiding this comment.
Verdict: CLEAN: No must-fix behavior or quality defect was established in the changed code.
Non-blocking
⚠ Establish the failing gate's baseline: crates/model/src/arch/qwen35moe/place.rs:1923 changes the planner's recurrent bytes. The PR reports the fixture e2e plan holding 254–255 experts per layer instead of 256. Attach this clause's base and head results on the same card and fixture to establish whether it regressed.
⚠ Supply throughput evidence: crates/gpu/src/linear/delta.rs:2680 changes verify-record stores. The introduction claims unchanged throughput without timing output. Attach the card/driver line, exact base and head hashes, model path, and timed A/B commands with output. Include PTX resource columns; an occupancy change requires the owning gate and one timed A/B under the base contract.
Checked
Duplicates: 10 new named items, including renames, checked by Grep; no qualifying duplicate. The new record sizing delegates to runtime::stores; tile span checks remain shared. Dryer reported zero pairs; its GPU exclusions were searched manually.
Complexity: check_wide adds BF16 cases; recovery_layers_clauses adds overlap cases; recovery_clauses adds one-lane coverage; misaligned_refused adds record windows. RecoveryTable::new and enqueue_mix add validation; delta_carried, load_placed and Arena38::alloc extend allocation. No kernel split.
Silent failure: 3 added fallback/bound sites followed. Saturating slot multiplication and the row cap retain their existing semantics. A failed BF16 eligibility lookup selects full scratch; the launch still validates the weight and returns its named error.
Tests: static mutation checks only. Dropping the update store linked above fails scalar recovery-state comparisons. Removing the F32-capacity guard (hc_gated.rs, line 2843) fails the new refusal clause. Restoring full-width streams at scratch38.rs:438 fails the arena byte assertion. Removing the record term linked above fails layout and plan assertions. These cover the changed recovery, HC, arena and byte/plan contracts; no tests ran locally.
Gates: byte, placement and context pins carry dated reasons; obsolete lane-rotation and planted-lane cases have a dated removal reason. The body reports red-before/green-after plan pins, but no FAIL-first run for the new HC clauses.
Adversarial: four verify rows on one lane, a parked-slot commit after another slot changes position, and split ubatches are bounded by record lengths, saved record metadata, per-slot stores/tables and BF16 windows. Reset and checkpoint restore restamp the live lane.
Escape catalog: no C1–C4 pattern matched. No ledger lessons were in force.
Notes
The gate evidence lacks the required nvidia-smi line and exact head commit hash; gpu.json records evidence=false. CUDA gates were reviewed statically.
Card check: needs-gpu. This pull request changes crates/gpu-gates/src/bin/gate_hc_gated.rs, crates/gpu-gates/src/bin/gate_linear.rs, crates/gpu-gates/src/bin/gate_qwen4exp_e2e.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. |
|
@juliankang4 FYI: c245910 changed the f32_tile short-x refusal to "x holds … values". I changed the clause to look for "x holds " (b5d08f3, on main). Same commit: the Silu nan_o case's graph replay raised the fault again after its take, so the next case read it; the case now clears the word. |
|
@midagedev Thanks for catching the wording change and fixing the clause and the nan_o replay case. "x holds " reads fine here, nothing more needed on this side. (AI 코딩 에이전트가 작성한 코멘트입니다.) |
Qwen3.8의 GDN 상태를 슬롯당 레인 하나로 줄이고, ubatch 걸음의 BF16 스트림 버퍼를 BF16 폭으로 잡아 GPU 메모리를 줄인 PR입니다.
What and why
A Qwen3.8 GDN layer kept four state lanes per slot so a verify could write each row's result beside the live state. It now keeps one lane, and a verify records each row's key, rounded update and head decay in a compact record buffer beside it (
DELTA_VERIFY_ROWS = 4rows). The ubatch walk also allocates its BF16 stream buffer, and on a dense MMA card with BF16 HC downs the wide HC normed streams, at their BF16 width instead of F32. Per slot the stores shrink by 329,122,224 B (36 GDN layers), and at ubatch 4,096 the load holds 496,894,096 B less. Throughput does not change and greedy output stays equal.Release notes: Under the hood: Qwen3.8 keeps one GDN state lane per slot and allocates its BF16 stream buffers at BF16 width, freeing 329,122,224 B of stores per slot; output is unchanged.
Code shape
The review reads these first. A box left unticked needs one line of why.
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), or "none":crates/gpu-gates/src/bin/gate_qwen4exp_e2e.rs:681andcrates/gpu-glm5next/src/pair.rs:72: different things. The gate's row count is the Qwen3.8 delta record's, held equal toruntime::stores::DELTA_VERIFY_ROWSby a const assert; GLM'sLOAD_ROWSis an unrelated load constant.crates/gpu/src/arch/qwen3moe/program38.rs:494and:507:rec_ofborrows a delta store's state, stamp and record,qsa_ofa selecting store's planes, ring and pooled keys; each refuses the other variant by name, as the rest of the file does.crates/gpu/src/gemm/f32tile.rs:2566and:2581: reused.mma_launch_wordscounts BF16 words and calls the sametile_spansthattile_launchcalls.What I ran
Memory, real binary
bloomery-serve-qwen38, Qwen3.8 FP4-Local with its MTP draft, upstream base977e8e74against the PR head, 6 rounds per arm in the order base, head, head, base, base, head, prompt 4,096 tokens, 128 new tokens.store_bytesandresident_bytesare the server's own load line:store_bytesresident_bytesstore_bytesresident_bytesgreedy_equal: True, and no server error in the 12 rounds. This PR makes no speed claim.Gates on a GB10 (commands from the repository root):
The one FAIL in the e2e gate is a card-leg plan count that the lane change does not touch; every verify and slot clause the lane change reaches passes.
The plan pins this change moves, red before the re-pin and green after:
Unit tests on a Linux CPU node:
Hardware (if the change is for a machine)
AI help
AI 코딩 에이전트가 코드를 작성한 후 설명을 썼고, 테스트를 마쳤습니다. diff 리뷰와 PR 초안 리뷰는 제가 직접 했습니다.