Repository navigation
gpu: zero recurrent stores on the device at reset - #643
Conversation
There was a problem hiding this comment.
Verdict: MUST_FIX: The new card reset stage repeats contracts already checked by the card row gate.
Must fix
1. Run the card path comparisons through one owner
gate_qwen4exp_e2e.rs:5596 calls paths, which checks eager = graph = pass. gate_qwen4exp_e2e.rs:3747 repeats those checks on the same card model and tokens, starting fresh each time. This is a kind B duplicate under R14 and the one-test-per-contract rule.
Consolidating now removes two owners of the same assertions and saves two token walks and one pass per card-leg run.
Delete reset_replay, including its comment, and the two new lines in card_leg that announce and invoke it. Replace card_rows with this definition; paths retains the new reset and prompt/decode checks:
fn card_rows(m: &mut Qwen38Model, toks: &[u32], plan: &PlanFacts) -> Result<bool, GateError> {
let (mut ok, _) = paths(m, toks)?;
let want_memops = shape().memops_card(hostless(plan));
let want = (
shape().nodes_verify_card(plan.card_layers) - (memops() - want_memops),
want_memops,
);
ok &= verify_structure::<2>(m, want)?;
ok &= verify_structure::<3>(m, want)?;
ok &= verify_structure::<4>(m, want)?;
let (rows, next) = verify_rows(toks)?;
let refs = (1..=LANES)
.map(|k| ref_run(m, Prefix::Steps(&toks[..PREFIX]), &[&rows[..k]], next))
.collect::<Result<Vec<_>, _>>()?;
let served = n_layer() - hostless(plan);
ok &= verify_case::<2>(m, toks, rows, next, 2, &refs, served)?;
ok &= verify_case::<3>(m, toks, rows, next, 3, &refs, served)?;
ok &= verify_case::<4>(m, toks, rows, next, 4, &refs, served)?;
Ok(ok)
}Non-blocking
⚠ Verify the final gate integration: gate_qwen4exp_e2e.rs:3925 integrates the reset check into the card leg. The reported hw_reset_replays_the_same_bits test is absent from this head. Run just gate-gpu-qwen4exp-e2e and just gate-gpu-lib on the final head and attach commands and output to validate the integration before merge.
Checked
Duplicates: 3 new functions searched; the card gate duplicate is above. Dryer reported 0 pairs; both new unit tests protect distinct clear/stamp contracts.
Complexity: paths rose 5 → 14 through reset-buffer validation and the prompt/decode clause; its orchestration remains bounded.
Silent failure: 2 fill results followed through callers; both propagate errors with ?. No new error-suppression sites.
Tests: static mutation check: omit either fill at recur.rs:84–85, clear/restamp at raon1/state.rs:63–64, or the model clear at body38.rs:4592; the corresponding zero/stamp assertion or gate verdict fails. The RecStore test also checks stable addresses and unchanged stamps; the Raon test checks fresh stamps.
Gates: no tolerance or threshold moved; reset checks were added, with FAIL-first results reported in the body.
Escape catalog: C1–C4 do not match.
Notes
Dryer did not scan crates/gpu-gates; its relevant owners were searched manually.
Source review only; no CUDA build or gate was run here. The supplied output does not establish a completed gate run after the reset clause moved into the card leg.
Card check: needs-gpu. This pull request changes crates/gpu-gates/src/bin/gate_qwen4exp_e2e.rs, crates/gpu/src/arch/nemotron_h/body.rs, crates/gpu/src/arch/nemotron_h_moe/body.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)
159f930 to
28e36b3
Compare
There was a problem hiding this comment.
Since the last review:
- Fixed: card_rows:3745 reuses
paths; the separate reset wrapper and repeated comparisons are removed. - Answered by author: the body reports completed GB10 owning-gate and clear/stamp unit runs, with the tested revisions identified.
Verdict: CLEAN: The consolidation retains the reset and path assertions and preserves their failure propagation.
Checked
Duplicates: 0 new items in the interdiff; the earlier duplicate is removed. Dryer reported 0 pairs.
Complexity: crapper flags paths, 5 → 14, for reset validation and prompt/decode orchestration; that function is unchanged in this interdiff.
Silent failure: 0 new suppression sites. The shared verdict reaches the gate's final error; both device-fill errors propagate.
Tests: no new tests in the interdiff. Static mutation check: dropping either fill at recur.rs:84–85 fails the positive-zero assertions; skipping restamping at raon1/state.rs:64 fails the fresh-stamp assertion. The body reports red fill mutants.
Gates: no tolerance or pin moved. The removed wrapper delegates to the retained assertions; each verify reference resets through Prefix::feed.
Escape catalog: C1–C4 do not match.
Notes
Dryer did not scan crates/gpu-gates; the changed gate owners were searched manually.
Source review only; no CUDA build or gate was run here. The supplied gate covers the fixture tier; eight real-tier clauses remain unrun.
Card check: gpu-evidence. This pull request changes crates/gpu-gates/src/bin/gate_qwen4exp_e2e.rs, crates/gpu/src/arch/nemotron_h/body.rs, crates/gpu/src/arch/nemotron_h_moe/body.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)
28e36b3 to
02cb058
Compare
There was a problem hiding this comment.
Verdict: CLEAN: carried from 28e36b33, not re-reviewed.
The approval of 28e36b33 stands for 02cb058b. This pull request's 1 commit are the same patches in the same order: git patch-id --verbatim (the changed lines, the lines around them and whitespace) and the subject are equal for every commit. That review ran under the reviewer instructions, tools and slag ledger that review this head, and it approved.
The base moved and also changed crates/gpu/src/arch/qwen3moe/body38.rs, which this pull request changes too. Each of its hunks still applies with the same context lines.
A carry covers each patch's own lines and the lines around them. What the base changed elsewhere is covered by CI on this head and by the landing gates.
Card check: gpu-evidence. This pull request changes crates/gpu-gates/src/bin/gate_qwen4exp_e2e.rs, crates/gpu/src/arch/nemotron_h/body.rs, crates/gpu/src/arch/nemotron_h_moe/body.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)
|
The review is done and the contribution check passed, so I'm merging this. |
새 요청마다 host의 0 버퍼 469,204,992 B를 card로 복사하던 recurrent 상태 초기화를, card에서 직접 0으로 채우도록 바꿉니다. 초기화 시간이 GB10에서 16.807 ms에서 2.416 ms로 줄었습니다.
Part of #565.
What and why
RecStore::clearresets a layer's recurrent state and ring buffers at the start of a request. It did that by copying a zero vector from host memory to both buffers, and every caller built that vector for each request. On the Qwen3.8 fixture's 36 stores, that is 469,204,992 bytes copied to the card per request, from a 12,582,912-byte host vector.This PR fills both buffers with zero on the card instead, with the existing
DeviceBuffer::zero_asyncon the engine stream.clearno longer takes a host source.Body38,Body35and the two Nemotron bodies no longer build the vector or compute its length, and the Raon state reset callsRecStore::clearinstead of its own copy of the same fill. Stamps are left as they were, and the change adds no kernel and nounsafe.On a GB10, clearing the 36 stores took 16.807 ms on main and 2.416 ms with this change (mean of two alternating runs per arm). That times the clear alone, from the caller's host zero vector to the final synchronize. It is not TTFT or decode tok/s. The small stamp and control copies at reset are unchanged.
Release notes: Under the hood: a request's recurrent state is zeroed on the GPU instead of copied from a host buffer, which cuts the reset's clear time on a DGX Spark.
Code shape
RecStore::clear, the one owner.clearare removed.?.cargo fmtis clean on what I touched. Clippy was not run on this head.Duplication found or removed (
path:line): the device zero copy incrates/gpu/src/arch/raon1/state.rsis replaced by a call toRecStore::clear.What I ran
The PR head is
033f058bcon mainbe69eb0ce.just contrib-check --tier t0(107 units, none red) and the fulljust gate-gpu-qwen4exp-e2eon a GB10 ran on this head. The clear timing, the unit tests and the bit comparison against main ran on an earlier revision of this branch. The clear path (crates/gpu/src/recur.rs,crates/gpu/src/arch/raon1/state.rsandcrates/gpu/src/arch/qwen3moe/body38.rs) is identical between that revision and this head, so those results carry over. The only change since is in the gate's own source, which now compares the reset through one shared path.GPU evidence
Card and driver, from
nvidia-smion the GB10 (CUDA 13.3.1 dev container):The whole card gate, on the Qwen3.8 fixture tier:
The card-leg and whole-card rows both run the reset clause through the shared
pathscomparison. It reads the stores back afterreset, requires every word to be positive zero, then replays the same five steps and a prompt followed by graph decode:The 8 clauses left to the real tier did not run.
The same gate with the two
zero_asynccalls inRecStore::clearskipped (card model, samepathsclause) fails:The test process exits with code 101, and the tracked sources are clean afterwards.
Against main, the five tokens and all 1,241,600 logit words match this change bit for bit.
The new unit tests,
recur::tests::hw_clear_keeps_stamps_and_addressesandarch::raon1::state::tests::hw_clear_store_resets_values_and_stamps, check that every word is positive zero, the buffer addresses stay and the stamps are kept. They run from the built test executable withhw_clear --ignored --nocapture --test-threads=1:A clear that leaves part of the ring untouched, and a Raon reset that skips
RecStore::clear, fail these two tests on the positive-zero assertion (test result: FAILED. 0 passed; 2 failed).Clear time A/B
Main and head alternated in one sitting, in the order M1, H1, M2, H2, on one GB10 with the clock cap lifted for the sitting and restored after. Each run allocates the 36 stores (state of 3,145,728 f32 and ring of 112,640 f32 each), fills them with 1, then times the clear and a stream synchronize. The main arm also times building the caller's host zero vector. The probe test is not part of the diff. Afterwards each run checks that every word is positive zero.
Delta (head minus main): clear time -14.391 ms (-85.6%).
Main here is
aa3d1690(upstream main plus the reset gate); its clear path is the same as onbe69eb0ce. Head here is02f604a1, whose clear path is the same as on033f058bc. Two runs per arm show the clear's cost, not end-to-end speed. To reproduce, add this probe tocrates/gpu/src/recur.rson each side (on main, theclearcall takes&zeros, andzerosisvec![0.0f32; 3_145_728]built before the loop), build the lib tests withcargo oxide test --arch sm_121 -- -p bloomery-gpu --release --lib --no-run, and run each executable with--exact recur::rec_clear_probe::request_clear --nocapture:Hardware
DGX Spark (NVIDIA GB10, driver 595.84, CUDA 13.3.1 container), built with
cargo oxide ... --arch sm_121. The model gate used a generated Qwen3.8 GGUF fixture (unsloth/Qwen3.8-Flash-Next-GGUF, UD-Q4_K_XL, seed 1). No full NVFP4 checkpoint was run.What I ran into
None of this blocks the PR.
Body38::resetstill does a small stamp and control copy for each store, andRecStore::restampbuilds its host stamp each time. I did not measure what moving those onto the card would save.AI help
AI 코딩 에이전트가 코드를 작성한 후 설명을 썼고, 테스트를 마쳤습니다. diff 리뷰와 PR 초안 리뷰는 제가 직접 했습니다.