Skip to content

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

Merged
juliankang4 merged 2 commits into
midagedev:mainfrom
juliankang4:dgx-spark-q38-usab-startup-2
Oct 28, 2026
Merged

juliankang4 merged 2 commits into
midagedev:mainfrom
juliankang4:dgx-spark-q38-usab-startup-2

Conversation

@juliankang4

@juliankang4 juliankang4 commented Oct 28, 2026 •

Copy link
Copy Markdown
Collaborator

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).

  • LoadPlan keeps one read-ahead, window, in place of its runs. It is the largest run the plan already reserves in host_bytes, so a placed load's host need does not change.
  • LoadPlan::admits decides 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_staged takes the whole plan. Readers start through Builder::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: the parts.rs row 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

  • No second copy. Read costs come from model::part::read_ahead and the live reading from host_available_read; admits replaces checked_runs.
  • Model code holds only architecture facts. No model file changed.
  • Dead code is gone. LoadPlan::runs and checked_runs are removed.
  • No silent failure. Every reader, admission, read, release and stage failure ends the load with a named error.
  • Comments state what is true now.
  • No relaxed gate. No band, tolerance or lint moved. The replaced run test carries a PIN(2026-10-28) line.
  • cargo fmt and cargo clippy are clean on what I touched: cargo fmt --check passed on bloomery-gpu, and just lint passed for the default target and sm_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-Local at b9ce18a6887e18c089fdea8509a33e63429a3300, base main at 89a728d26d90a8f2a693ce011f84c395b0cea69c and head at 96cc88dd4e1391e65c342940a1ddc7588e25c025, 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.

Metric Base Head Difference Ranges overlap
Start to health, cold 46.13 s (45.67 to 77.55) 36.75 s (36.72 to 36.97) -9.38 s (-20.3%) no
Start to health, warm 45.92 s (45.41 to 45.93) 36.75 s (36.69 to 38.76) -9.17 s (-20.0%) no
Checkpoint upload, cold 35.70 s (35.47 to 66.63) 26.51 s (26.40 to 26.58) -9.19 s no
Checkpoint upload, warm 35.65 s (35.26 to 35.84) 26.41 s (26.23 to 28.58) -9.24 s no

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.

RELEASE-BUILD arm=base rc=0 seconds=526
RELEASE-BUILD arm=head rc=0 seconds=500
INSTALL arm=base rc=0
INSTALL arm=head rc=0
GREEDY-SAME=1 replies=24
SUMMARY arm=base state=cold starts=3 up=3 start_median_s=46.13 start_min_s=45.67 start_max_s=77.55 upload_median_s=35.70 upload_min_s=35.47 upload_max_s=66.63 jit_bytes=0,0,0
SUMMARY arm=base state=warm starts=3 up=3 start_median_s=45.92 start_min_s=45.41 start_max_s=45.93 upload_median_s=35.65 upload_min_s=35.26 upload_max_s=35.84 jit_bytes=0,0,0
SUMMARY arm=head state=cold starts=3 up=3 start_median_s=36.75 start_min_s=36.72 start_max_s=36.97 upload_median_s=26.51 upload_min_s=26.40 upload_max_s=26.58 jit_bytes=0,0,0
SUMMARY arm=head state=warm starts=3 up=3 start_median_s=36.75 start_min_s=36.69 start_max_s=38.76 upload_median_s=26.41 upload_min_s=26.23 upload_max_s=28.58 jit_bytes=0,0,0

Tests on a GB10, and the mutant each test must catch:

$ cargo fmt -p bloomery-gpu -- --check
FMT rc=0
$ bash tools/gate.sh --oxide -p bloomery-gpu --release --lib -- parts::tests
test result: ok. 7 passed; 0 failed; 2 ignored; 0 measured; 432 filtered out; finished in 0.19s
$ bash tools/gate.sh --oxide -p bloomery-gpu --release --lib -- parts::tests::hw_ --ignored
test result: ok. 2 passed; 0 failed; 0 ignored; 0 measured; 439 filtered out; finished in 17.52s
  • Admitting past the read-ahead, ignoring the live reading, or dropping the lone part's check each fails a_part_reads_beside_the_held_parts_within_the_read_ahead_and_the_live_room.
  • The reader loop admitting each part as if none were held (plan.admits(i..i, available)) reads all four parts of the two-part read-ahead at once, and parts_stage_in_order_as_their_reads_arrive fails on its held-parts count ("the read-ahead of 2 parts held 4").
  • Queuing a release when release is off fails parts_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.
  • A stage that never frees its read-ahead stalls a load, and parts_stage_in_order_as_their_reads_arrive aborts on its 10 s watchdog (SIGABRT, exit 101 after 12.4 s).
  • Dropping the unwind guard leaves a load waiting after a reader or a stage panics, and the same test aborts on its watchdog (SIGABRT, exit 101).

Hardware

| NVIDIA-SMI 595.84                 Driver Version: 595.84         CUDA Version: 13.3     |
|   0  NVIDIA GB10                    On  |   0000000F:01:00.0 Off |                  N/A |

One DGX Spark, Linux aarch64.

AI help

AI 코딩 에이전트가 코드를 작성한 후 설명을 썼고, 테스트를 마쳤습니다. diff 리뷰와 PR 초안 리뷰는 제가 직접 했습니다.

…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.
@github-actions github-actions Bot added dgx-spark The DGX Spark (aarch64, GB10) port documentation Improvements or additions to documentation gpu The card engine: crates/gpu*, crates/app needs-gpu Changes code a card must check, and carries no gate run on a card labels Oct 28, 2026

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 new read_staged) checked, none duplicated (UnwindFlag in bench_v41_host.rs:1503 is a different shape). dryer: 0 pairs.
  • Complexity: read_staged 11 → 25, new branches in one function (reader loop, release queue, wait, stage loop). All paths read: no lost wakeup (state changes under the lock, then notify_all), the unwind guards drop after w, 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 (flipped at < i, dropped live check, dropped lone check). The stage-order test kills a stage that never sets staged (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)

@github-actions github-actions Bot added gpu-evidence Verified on the author's card: the pull request carries the gate run and its output and removed needs-gpu Changes code a card must check, and carries no gate run on a card labels Oct 28, 2026
@juliankang4

Copy link
Copy Markdown
Collaborator Author

Thanks for the review.

  • Must fix 1: parts_stage_in_order_as_their_reads_arrive now counts the parts read and not yet staged, and the two-part read-ahead must hold two at its peak. The reader loop admitting each part as if none were held reads all four at once and fails that count.
  • R33: the bare true and false arguments are now named release and keep.
  • Non-blocking 1: charging the held parts against the live reading is on purpose. A reader advances next and unlocks before its read allocates, so when the next reader checks, the live reading may not yet lack the earlier admitted reads. Counting the whole held range keeps two readers from both passing on the same room, so I kept that check.

(AI 코딩 에이전트가 작성한 코멘트이며, 내용은 제가 확인했습니다.)

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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, release and keep are named locals.

Checked

  • Duplicates: the new items are tests, one static pair and one peak_of closure; none duplicates another. dryer: 0 pairs.
  • Complexity: read_staged 11 → 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 on Short" makes the tight peak 2, red at line 911. A reader's admission error that fail drops gives "a part reader stopped", red at line 915. hw_a_parts_load_releases_its_parts_only_under_release: a fixed release in load_plan changes 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 now 71b0dce. 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)

@juliankang4

Copy link
Copy Markdown
Collaborator Author

The review is done and the contribution check passed, so I'm merging this.

@juliankang4
juliankang4 merged commit 49d84ec into midagedev:main Oct 28, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dgx-spark The DGX Spark (aarch64, GB10) port documentation Improvements or additions to documentation gpu The card engine: crates/gpu*, crates/app gpu-evidence Verified on the author's card: the pull request carries the gate run and its output

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant