Repository navigation
qwen38: a checkpoint folder's plan holds its load's least part reads - #898
Conversation
There was a problem hiding this comment.
Verdict: MUST_FIX: the two new gate clauses copy the same 17-line kernel launch, and no failure path survived in the code itself.
Must fix
1. f32_alignment and finite_scaled_word repeat one launch block (kind B, one owner per fact)
gate_nvfp4.rs:906 and gate_nvfp4.rs:971 both build sel, y and the same Nvfp4Stack and SelArgs. Both call enqueue_nvfp4_gemv_sel_f32, read y[0], then call take_fault. Grep finds no other caller of enqueue_nvfp4_gemv_sel_f32 in gpu-gates, so these two are the only copies, and both are in this diff. The helper replaces about 40 lines in the two clauses with about 25, and removes two sel, two y and two Nvfp4Stack and SelArgs literals.
Fix: add this helper and call it from both clauses.
/// One expert-select launch of a one-row, one-expert NVFP4 stack over `x`:
/// the row's f32 and the fault the launch raised.
fn sel_f32(
gpu: &Gpu,
(qs, e, scales): (&DeviceTensor<u32>, &DeviceTensor<u32>, &DeviceTensor<f32>),
x: &DeviceBuffer<f32>,
) -> Result<(f32, Option<bloomery_gpu::Fault>), GateError> {
let stream = gpu.stream();
let sel = DeviceBuffer::from_host(stream, &[0u32])?;
let mut y = DeviceBuffer::from_host(stream, &[SENT])?;
gpu.q8f32().enqueue_nvfp4_gemv_sel_f32(
stream,
Nvfp4Stack { qs, e, scales },
&bloomery_gpu::q8f32::SelArgs {
x,
sel: &sel,
n_slots: 1,
rows_per_expert: 1,
slots_per_col: 1,
},
gpu.unlabelled_sink(),
&mut y,
)?;
Ok((y.to_host_vec(stream)?[0], gpu.take_fault()?))
}In f32_alignment, replace the sel, y, launch, got and fault lines with let (got, fault) = sel_f32(gpu, (&qs, &e, &scales), x)?;. In finite_scaled_word, use let (got, fault) = sel_f32(gpu, (&qs, &e, &scales), &x)?; let clean = fault.is_none();. Remove the now-unused sel upload in f32_alignment. Adjust the types if the compiler asks.
Non-blocking
⚠ Doc claims a result the PR did not run: docs/contrib/dgx-spark.md:129 says --parallel 2 and --parallel 4 start without a context flag. The PR body shows a run only for --parallel 4, on one GB10 with one checkpoint. Name that run's conditions or drop --parallel 2.
Checked
- Duplicates: 14 new items checked (functions, types, constants, one variant). One duplicate, the launch block (item 1). dryer: 0 pairs.
- Complexity:
f32_alignment(new, 21) is a gate clause with one loop and one branch per case.Checkpoint::read_bytes15→20 grows by one bool,widened, and its factor term.routed::run+4 andqwen38::run+2 are even growth. No#[kernel]body was split.nv_wordandnv_word_dotare#[inline(always)]. - Silent failure: 6 sites followed.
own_draftuseslayer.ok().flatten(), butfolder_draft_for(qwen38.rs:992) has already refused or turned off the draft on thatErr.ArenaFloor::of(plan)?andleast_reads(..)?propagate.pool_shortreturnsNoneoff a unified pool, so a discrete card still stops the seat. A set--ctx-sizestays refused throughRule::Set. - Numeric order: the scalar fallback maps word
wto the same values and quads as the aligned walk (first + off + 4·(off/4)equals quads2w − w%2and+2).nv_word_dotmatchesNvfp4Values::at(code timesue4m3_half). The sum-order change is gated by the two new clauses. - Read bound:
modelopt::plaincopiesraw.bytes.to_vec()forMatrix(Plain::Bf16), so dropping the ×4 for a whole, single-source, unstepped BF16 matrix is right. F32 and stacked tensors keep ×4. - Folder check:
least_readspasseshost_bytesroom 0 andfolder_holdsputs the peak, ring included, inread_ahead. The load putspeak − ringinread_aheadandringinshadows, so the sum is equal. The arena at its floor matchesHostNeed::grant. The plan check is a lower bound of the load's check. - Tests (mutation):
read_peaks_cover_the_owned_inputs_and_resultsturns red if the factor goes back to 4.routed_f32_alignmentturns red if the fallback sum order differs (FAIL shown in the PR body).routed_f32_finite_scaled_wordturns red if the scale moves after the activation multiply (FAIL shown on GB10).a_folder_plan_holds_its_reads_on_the_arena_floorturns red if the folder check is dropped fromPlans::holds(shown). ThePoolBudgetandpool_shorttests pin the newShortvalues. No test only prints. - Gates: no band, tolerance or lint moved. The
unsafe-ratchetre-pins carry dated PIN lines with the reason. - Performance: hot path is the NVFP4 select gemv (decode). The PTX diff in the PR body shows
fma49→41 and scalar loads 39→15, with registers and local memory equal. The timed A/B shows no change within resolution. Headroom: none named. - Escape catalog: no pattern matched (no shell script changed).
Notes
- The PR body leaves
cargo fmt,cargo clippyandtools/check-comments.shunrun on this head. Run them before merge. The diff adds no date, issue number or measured number to a comment undercrates/*/src. - Evidence on a card: the body has the
nvidia-smiline andjust gate-gpu-nvfp4output, but no commit hash of the head that ran. The speed table names only base hashes.
Card check: needs-gpu. This pull request changes crates/gpu-gates/src/bin/gate_nvfp4.rs, crates/gpu-gates/src/bin/generate_qwen3moe.rs, crates/gpu-gates/src/bin/shared/qwen3moe_place.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)
…state the FP4-Local defaults
The seat holds a folder plan's least part reads beside its host need, with the NVMe tier arena at its floor (ArenaFloor::of), since the load's own check (HostNeed::grant) shrinks the arena to make room for them. On a unified pool that refusal reads as short, so an unset context halves and a set one is refused; where each card has its own memory the refusal stands. HostTotals::room keeps the reading that decided the room the plan was held to, so HostNeed::check_planned refuses at that room and names it: the reading's own HostRead when its plan room binds, and HostRead::Machine (the host's usable bytes less the OS reserve, or the unified pool) when a machine cap does or the plan was made without a room. Plan::violations names its machine-figure check the same way.
65746a1 to
45680be
Compare
There was a problem hiding this comment.
Verdict: CLEAN: the earlier must-fix is fixed, and no new failure path survived in the changed commits.
Since the last review:
- Must-fix 1 (the repeated launch block): fixed. gate_nvfp4.rs:883 adds
sel_f32.f32_alignment(line 930) andfinite_scaled_word(line 975) call it. The unusedselupload inf32_alignmentis gone. - ⚠ The doc claim for
--parallel 2: fixed. docs/contrib/dgx-spark.md now names--parallel 4on one GB10 with the FP4-Local folder, which is the run in the PR body.
Checked
- Duplicates: the one new item,
sel_f32, checked.enqueue_nvfp4_gemv_sel_f32has no other caller ingpu-gatesoutside the existingresident_sel_f32sites, which go throughsite::. dryer: 0 pairs. - Complexity:
f32_alignmentis now smaller than the 17 crapper reported and is one loop with one branch. The other flagged functions are unchanged since the last review. - Silent failure:
sel_f32propagates everyResultwith?. It readsfaultthroughtake_faultand the caller checks it.FaultisCopy, sofault.is_some_and(..)followed byfault.is_none()compiles. - Tests (mutation): the helper keeps the same launch arguments as the two removed blocks (
n_slots1,rows_per_expert1,slots_per_col1,sel=[0],y=SENT). The earlier mutants still turn the same clauses red: a changed fallback sum order forrouted_f32_alignment, and a scale applied after the activation multiply forrouted_f32_finite_scaled_word. - Gates: no pin moved by the new commits.
- Escape catalog: no pattern matched (no shell script changed).
Notes
- The PR body leaves
cargo fmt,cargo clippyandtools/check-comments.shunrun on this head. Run them before merge, because the helper edit is new on this head. - Card evidence: the body has the
nvidia-smiline and the gate output, but no commit hash of the head that ran.
Card check: needs-gpu. This pull request changes crates/gpu-gates/src/bin/gate_nvfp4.rs, crates/gpu-gates/src/bin/generate_qwen3moe.rs, crates/gpu-gates/src/bin/shared/qwen3moe_place.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. |
Qwen3.8 FP4-Local을 DGX Spark 한 대에서
--parallel 4로 켤 때 로드가 거절되던 문제를 고치고, 서버가 시작 설정을 한 줄로 출력하게 합니다.What and why
On one DGX Spark,
bloomery-serve -m <Qwen3.8-Flash-Next-FP4-Local folder> --parallel 4with no--ctx-sizewas refused by the load. The context choice halved the default to 131,072 positions a slot, but its plan did not count the host bytes the load reads ahead of its parts, so the plan passed and the load then refused it. This PR makes the plan count them, so the default halves further until the load fits.What changes, one item for each commit:
placement: an unset context halves on a unified pool when no card share fits.PlacementError::PoolBudgetnow carries the first refusal's host room and floor, andcard_shortreads it as a host-short memory. Callers that plan in the pool (the qwen35moe/qwen38, glm5next and deepseek41 plans) halve an unset context where they used to refuse the start. A set--ctx-sizethat does not fit is still refused.qwen38: a checkpoint folder's plan holds the load's least part reads.Folder::least_readsasks the part source for its least read peak, and the plan is held to its need with that read-ahead, the NVMe tier's arena counted at its floor (ArenaFloor::of), because the load's own check shrinks the arena to make room for the reads. The check runs at the room the plan was made at and names the reading that decided it. On a unified pool the context choice reads that refusal as short; where each card has its own memory the refusal still stops the seat.model-hf:Checkpoint::read_bytescharged every BF16 or F32 part four extra copies for widened values. A BF16 matrix read whole is copied as stored, so its bound is now its stored bytes plus the copy. For the FP4-Localoutput.weight(1,525,678,080 B stored) the bound drops from 15,256,789,000 B to 9,154,076,680 B.qwen38: the checkpoint folder's MTP draft reuses the header the folder was opened with, instead of opening the folder two more times.qwen38: the server prints onesetupline before its address: the draft (mtp,lookuporoff), where the draft reads its layer (folderorfile), the slots, the context each serves and the settings that change them.docs/serving.mdanddocs/contrib/dgx-spark.mdstate the FP4-Local defaults: one slot, the folder's own MTP draft on, and 262,144 positions a slot halved until the plan fits.q8f32:nvfp4_gemv_sel_f32, the expert-select gemv of the checkpoint MTP draft, now owns whole code words per lane, asq8_0_gemv_sel_f32does, instead of decoding one value at a time. Launch, grid, fault and expert-scale rules are unchanged. Each code is multiplied by its sub-block scale before it meets its activation, so every product is the stored weight's. Activations that are not 16-byte aligned take scalar loads in the same word and value order, so one input gives one sum at either address. The lane's sum order changes, sogate_nvfp4gains two clauses:routed_f32_finite_scaled_word(code 7 under scale byte 0x01, activations 2^125) holds the row to the f64 reference's f32 bits with no fault, androuted_f32_alignmentruns cancelling and overflowing lane sums at an aligned and a four-byte-offset address and expects the same result at both.f32_fold_valuestakes the weight as a closure sonv_word_dotuses it instead of a second eight-term fold.The draft default at more than one slot (off) and the single default slot are unchanged.
Release notes: Fixed: Qwen3.8 FP4-Local starts with
--parallel 4and no--ctx-sizeon one DGX Spark, and the server prints its setup before its address.Code shape
The review reads these first. A box left unticked needs one line of why.
PlacementError::card_short; the part-read count is the existingHostNeed::read_aheadterm filled fromPartsLoad::host_bytes, the one owner of a part source's read peak.nv_wordandnv_word_dotare the only NVFP4 f32-activation walk.Resultis propagated with?; the kernel's launch contract and the expert checks are unchanged.tools/check-comments.shon this head.tools/unsafe-ratchet.txtre-pins the GPU count for the newunsafeblocks, each with its SAFETY line and aPIN(...)note.cargo fmtandcargo clippydid not run on this head.Duplication found or removed (
path:line), or "none": none.What I ran
The GPU gates and the serve-rules gate ran on the branch before its last rebase onto upstream main, which moved the placement code into modules and changed no behavior; the placement tests ran after it. The serve and speed runs below used earlier tips, and the kernel path they run is unchanged since.
gate_nvfp4on an RTX 5090 machine (sm_86PTX, JIT for compute capability 12.0):All 50 clauses passed, none failed. With the old one-value walk in the unaligned path, the same gate fails on the offset rows:
On a DGX Spark (GB10,
sm_121a), with the old one-value walk and the finite-scaled clause, the gate fails on that clause alone:tools/ptx-compare.shofgenerate_ds41(sm_86, JIT for compute capability 12.0) against an earlier build of the same kernel file reports one changed entry,nvfp4_gemv_sel_f32. Registers, blocks per SM and local memory are the same on both sides, and only the unaligned path's instruction counts differ:Host tests, x86_64:
read_peaks_cover_the_owned_inputs_and_resultspinsbf.weightat 4 S + 2 A + 8. With only the pin and the old bound it fails withleft: 12296,right: 10248.just gate-q38-serve-ruleson the RTX 5090 machine calls the seat's ownPlans::holdson a checkpoint folder's header. A folder's reads hold on the arena's floor, an unset context halves on a unified pool and a set one is refused. The same test fails when the folder check is removed fromPlans::holds:and the same gate with it in place:
On the DGX Spark, an earlier tip of this branch served the FP4-Local checkpoint (
b9ce18a6887e18c089fdea8509a33e63429a3300) withbloomery-serve -m <folder> --parallel 4and no--ctx-size. It started, where the load refused it before:Speed, one DGX Spark (GB10), 4,096-token prompt, 128 generated tokens, eight windows, three rounds each side, greedy output equal on both sides.
fp4l-mtpdrafts from the checkpoint folder (basee009acd4);fp4l-offis the draft-off path (basea87b49d9). The comparison ran before the unaligned path was reordered and before the last rebase; the aligned path it runs is unchanged.Prefill and p95 TTFT differ by less than 0.5% on every arm, ranges overlapping. The decode differences are inside the smallest effect the runs resolve, so this PR claims no speed change.
Not run:
gate-gpu-qwen38-serve(it needs an RTX 3090, and none was available),gate-placement(the DS41 Q3 model files were not on the RTX 5090 machine),gate-gpu-e2e,tools/check-comments.shandcargo clippyon this head.Hardware
DGX Spark with one GB10, driver 595.84, CUDA 13.3,
sm_121abuild, the FP4-Local checkpoint folder above. The kernel gate and the serve-rules gate also ran on an RTX 5090 machine, driver 595.99.02, CUDA 13.2. Host tests ran on x86_64.AI help
AI 코딩 에이전트가 코드를 작성한 후 설명을 썼고, 테스트를 마쳤습니다. diff 리뷰와 PR 초안 리뷰는 제가 직접 했습니다.