Repository navigation
gpu: a parts load reads each part once the parts before it not yet staged leave it room, so the drive keeps reading across the whole load - #919
Conversation
…aged leave it room, so the drive keeps reading across the whole load A folder load read its parts a run at a time: every part of a run was read, normalized and staged before the next run's reads began, so on Qwen3.8's FP4 folder the drive alternated between 3.3 GB/s and nothing each second while the run's parts normalized. A reader now takes the next part as soon as it and the read parts not yet staged fit the planned read-ahead (the largest run the plan reserved) and the live host reading; a part's bytes leave the read-ahead when its stage returns, and the readers drop its source pages after that. A part alone over the live reading is still refused by name. A reader that cannot start ends the load with a named refusal, and the readers already started stop.
There was a problem hiding this comment.
Verdict: MUST_FIX: no test turns red when the reader loop ignores the read-ahead, and that bound is what keeps a load inside its reserved host bytes.
Must fix
1. The read-ahead wiring in read_staged has no test that bounds the held parts
Evidence: parts.rs:174 passes w.staged..i to admits. The test parts_stage_in_order_as_their_reads_arrive (parts.rs:866) runs turning (window of 2 parts) but never counts how many parts are read and not yet staged.
Mutant: plan.admits(i..i, available). Each part is then admitted as "alone", all 4 read at once, and every assertion still passes (order, released list, the q3 error). Only admits itself is tested (a_part_reads_beside_...); the call that feeds it the held range is not. In a real load this mutant reads the whole checkpoint into host memory, far over host_bytes.
Cost: the PR body says "admitting past the read-ahead" is caught; it is caught in admits only. Adding the count now is 6 lines.
Fix, in the test:
static HELD: AtomicUsize = AtomicUsize::new(0);
static PEAK: AtomicUsize = AtomicUsize::new(0);
// in Slow::read, first line after the `assert_ne!`:
PEAK.fetch_max(HELD.fetch_add(1, Ordering::SeqCst) + 1, Ordering::SeqCst);
// in `stage`, after `order.push(...)`:
HELD.fetch_sub(1, Ordering::SeqCst);
// before the `turning` call:
HELD.store(0, Ordering::SeqCst);
PEAK.store(0, Ordering::SeqCst);
// after the `turning` call:
assert!(PEAK.load(Ordering::SeqCst) <= 2, "the read-ahead held more than 2 parts");(use std::sync::atomic::{AtomicUsize, Ordering} in the test module.) The count is exact: a part counts from its read start to the end of its stage, which is before w.staged moves.
Non-blocking
⚠ Live reading is compared against the held parts twice: parts.rs:346 calls fits(live) on parts[at..=i], the held parts and the new one. The doc above admits says the live reading already lacks what the held parts hold. With the parts read so far already subtracted from live, a tight room needs about 2 × held + new before a part reads, so Short fires earlier than needed and fewer parts overlap. It is safe (the wait ends at the next stage), only slower in the case the PR targets. Compare the new part's added bytes (bytes(at..=i) - bytes(at..i)) with live, or answer why the double count is wanted.
⚠ R33: the test calls read_staged(&slow, &whole, room, true, ...) and ..., false, ... with a bare bool (parts.rs:867). Bind let release = true; or use a named local at each call.
Checked
- Duplicates: 5 new items (
Admit,Window,OnUnwind,admits, the newread_staged) checked, none duplicated (UnwindFlaginbench_v41_host.rs:1503is a different shape). dryer: 0 pairs. - Complexity:
read_staged11 → 25, new branches in one function (reader loop, release queue, wait, stage loop). All paths read: no lost wakeup (state changes under the lock, thennotify_all), the unwind guards drop afterw, a failed release after the last stage is returned. No split asked; it adds elements. - Silent failure: 9 sites followed (reader start, mask, admit, read, release, stage, 2 panics, poisoned lock); each reaches the caller as a named error or a re-raised panic.
- Tests:
a_part_reads_beside_...kills the three mutants it names (flippedat < i, dropped live check, dropped lone check). The stage-order test kills a stage that never setsstaged(watchdog) and a release dropped. It does not kill finding 1. - Gates: none moved. The
PIN(2026-10-28)on the replaced test is present with its reason. - Escape catalog: none matched (no shell changed).
Notes
- Performance: load time only, no hot-path finding. The timing table in the PR body carries the card, both hashes and the model.
Card check: gpu-evidence. This pull request changes crates/gpu/src/parts.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)
…aged, and a load's release wiring
|
Thanks for the review.
(AI 코딩 에이전트가 작성한 코멘트이며, 내용은 제가 확인했습니다.) |
There was a problem hiding this comment.
Verdict: CLEAN: the new commits add the held-parts bound the last review asked for, and no failure path survived.
Since the last review
- Must fix 1 (no test bounds the held parts): fixed. parts.rs:817 counts a part from its read start to its stage, and parts.rs:900 asserts a peak of 2.
- ⚠ R33 (bare bool at the call): fixed,
releaseandkeepare named locals.
Checked
- Duplicates: the new items are tests, one
staticpair and onepeak_ofclosure; none duplicates another. dryer: 0 pairs. - Complexity:
read_staged11 → 25 was read in the first review; the new commits change only tests. - Silent failure: no production line changed in the new commits.
- Tests: mutant
plan.admits(i..i, available)makes the peak 4, red at line 900. Mutant "never read beside a held part" gives peak 1, red when the pool has 2 or more threads. Mutant "read onShort" makes thetightpeak 2, red at line 911. A reader's admission error thatfaildrops gives "a part reader stopped", red at line 915.hw_a_parts_load_releases_its_parts_only_under_release: a fixedreleaseinload_planchanges the released list of one of its two loads, red. - Gates: none moved. The
PIN(2026-10-28)line is present. - Escape catalog: none matched; no shell changed.
Notes
- The PR body names head
96cc88dd; the head is now71b0dce. The timing table was measured before the test-only commits, and no production line changed since, so it still holds.
Card check: gpu-evidence. This pull request changes crates/gpu/src/parts.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. |
DGX Spark(GB10)에서
bloomery-serve -m <폴더>로 FP4-Local 체크포인트를 띄울 때, 체크포인트 읽기가 묶음마다 멈추지 않고 이어지게 해서 서버가 health를 열기까지의 시간을 줄이는 PR입니다.Part of #565.
What and why
A folder load read its parts a run at a time, so the drive sat idle while each run's parts normalized and staged. Now a reader takes the next part as soon as it and the read parts not yet staged fit the planned read-ahead and the live host reading, and the main thread stages parts in plan order as they arrive (
crates/gpu/src/parts.rs).LoadPlankeeps one read-ahead,window, in place of its runs. It is the largest run the plan already reserves inhost_bytes, so a placed load's host need does not change.LoadPlan::admitsdecides when the next part may read. A part beside the held parts reads only when it and the held parts fit the read-ahead and then the live host reading; otherwise it waits. A part alone over the live host reading is refused by name, as before.read_stagedtakes the whole plan. Readers start throughBuilder::spawn_scoped, and the first refusal (a reader start, mask, admission, read, release or stage) or a reader or stage that panics stops every reader.tools/spawn-allow.txt: theparts.rsrow names the test's watchdog thread beside the readers.docs/contrib/dgx-spark.md: the load now "reads fewer parts at once" when the live host room is short.Release notes: Changed: a DGX Spark server loading an FP4-Local folder keeps the drive reading through the whole checkpoint upload, so it starts sooner.
Code shape
model::part::read_aheadand the live reading fromhost_available_read;admitsreplaceschecked_runs.LoadPlan::runsandchecked_runsare removed.PIN(2026-10-28)line.cargo fmtandcargo clippyare clean on what I touched:cargo fmt --checkpassed onbloomery-gpu, andjust lintpassed for the default target andsm_121a.Duplication found or removed (
path:line), or "none": none.What I ran
Start time of
bloomery-serve -m <folder>from an installed release archive (just release-build 0.3.10,tools/release/install.sh),nvidia/Qwen3.8-Flash-Next-FP4-Localatb9ce18a6887e18c089fdea8509a33e63429a3300, base main at89a728d26d90a8f2a693ce011f84c395b0cea69cand head at96cc88dd4e1391e65c342940a1ddc7588e25c025, three rounds of base cold, head cold, base warm, head warm. Cold drops the page cache and the JIT cache. The metric is spawn to a 200 from/health; each cell is the median of three starts with its range.Cold start to health is 9.38 s shorter (46.13 s to 36.75 s); warm start is 9.17 s shorter (45.92 s to 36.75 s); the ranges do not overlap.
Tests on a GB10, and the mutant each test must catch:
a_part_reads_beside_the_held_parts_within_the_read_ahead_and_the_live_room.plan.admits(i..i, available)) reads all four parts of the two-part read-ahead at once, andparts_stage_in_order_as_their_reads_arrivefails on its held-parts count ("the read-ahead of 2 parts held 4").releaseis off failsparts_stage_in_order_as_their_reads_arrive, and so do readers that end before every part is staged and a release error dropped after the last stage.parts_stage_in_order_as_their_reads_arriveaborts on its 10 s watchdog (SIGABRT, exit 101 after 12.4 s).Hardware
One DGX Spark, Linux aarch64.
AI help
AI 코딩 에이전트가 코드를 작성한 후 설명을 썼고, 테스트를 마쳤습니다. diff 리뷰와 PR 초안 리뷰는 제가 직접 했습니다.