Repository navigation
gpu: shrink a part read run to the live host reading instead of refusing - #870
Conversation
There was a problem hiding this comment.
Verdict: CLEAN: every failure path I built for the shrunk read runs is blocked by the code or by a test.
Non-blocking
⚠ The cut-run line has no test: crates/gpu/src/parts.rs:167. Dropping the eprintln! or its n < left.len() filter turns no assertion red. The line is the only sign to the user that a run was cut, and the PR body promises it. This is acceptable because stderr is hard to assert; consider it only if a cheap seam exists.
Checked
- Duplicates: 0 new functions, 2 new fields (
costs,serial_bytes) and 1 closure (with_ring) checked. The cut reusesmodel::part::read_aheadat crates/model/src/part.rs:166; no second copy of that logic. dryer: 0 pairs. - Complexity: crapper flagged no function.
- Silent failure: 5 sites followed. A live-reading error, a
read_aheaderror and a part alone over the reading all returnrefusedwith byte counts.read_aheadon a non-empty slice always returnsn >= 1, soleftalways shrinks and the iterator cannot loop. A failedavailable()leavesleftunchanged, andload_planstops at the firstErrthroughrun?. - Bounds: a cut run is a prefix of its planned run, so it never exceeds the planned peak (
host_bytes) the placed caller reserved.checkon the serial peak matcheshost_byteswhen every run is one part, sohw_a_parts_load_refuses_a_short_host_before_readingstill holds (288 MiB). - Tests: mutants checked. Dropping the
bytes > liveguard turns the final refusal assertions red (needs 25165824 B). Usinghost_bytesincheckturnsshared.check(288 * mib)red. Wrongleft.start += nturns the length and name assertions red. The[199, 199]case pins the cut. - Gates: no band, tolerance or pin moved. The removed case (refusal just under a planned run) is the behavior this PR changes; the PR body gives the reason.
- Performance: load-time code only, not a hot path. The PR body carries a timed A/B on GB10 with overlapping ranges.
- Escape catalog: C1 to C4 are shell patterns; none match.
Notes
- Evidence: the PR body has the GB10
nvidia-smiline, both hashes and the reproduction output. It has nojust gate-*run, and the unit test run on the RTX 5090 has nonvidia-smiline. A maintainer runs the gates. - The body says clippy was not run. CI runs the ratchet.
Card check: needs-gpu. This pull request changes crates/gpu/src/parts.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. |
체크포인트 폴더를 읽을 때 남은 호스트 메모리가 병렬 part 읽기 묶음보다 조금 작으면, 거절하지 않고 그 여유에 맞게 묶음을 줄여 읽도록 고칩니다.
What and why
Loading a checkpoint folder on a DGX Spark can stop with
parts::load: part read-ahead needs N B, the host has M B availablealthough the model fits.LoadPlan::checked_runsincrates/gpu/src/parts.rsread each planned run of parts at its planned size and refused the run as soon as the live host reading (MemAvailable, read just before the run) was below it, even by a little. GB10 has unified memory, so the card upload and the page cache lower that reading during the load, and more so right after another process has freed or taken memory. Withnvidia/Qwen3.8-Flash-Next-FP4-Localthe planned run was 36637682020 B and the reading 34983829504 B.Now
checked_runsreads the live value before each run and applies the existingmodel::part::read_aheadto the parts that remain, with the live value as the room. When the reading covers the planned run,read_aheadreturns the whole run and nothing changes. When it does not, the run is cut to the leading parts that fit, and the reading is taken again before the next run, down to one part at a time. A single part over the reading is refused with the same message as before. Each run that is cut prints one line to stderr:LoadPlan::check, which runs before any read, now refuses on the serial peak (the largest single part plus the upload ring, new fieldserial_bytes) instead of the planned peak, because a load can finish at that size.LoadPlan::host_bytes, which the placed caller reserves in its host need, is unchanged. Every run is still no larger than the reading taken just before it, so the load still refuses where it would have run out of memory.Release notes: Fixed: a checkpoint-folder load no longer stops when the free host memory falls a little below a planned read run; it reads the parts in smaller runs.
Code shape
model::part::read_ahead, and the serial peak comes from the same function with no room. The change adds no new function.refusederror with the byte counts; each cut run prints its line.cargo fmtandcargo clippyare clean on what I touched; the lint count did not go up.cargo fmt -p bloomery-gpu --checkis clean; I did not run clippy.Duplication found or removed (
path:line), or "none": none.What I ran
Base
0df4076ef29b8b6f193d3c2d63c44f78350681dc(main), heada266c556c848fb4a370b40b362542a7b60e7ac03. The runs below were taken on the same change before its last rebase, on main at95a483fc2. None ofcrates/gpu/src/parts.rs,crates/model/src/part.rs,crates/gpu/src/model.rsorcrates/gpu/src/upload.rsdiffers between that main and the base above.Unit tests, on an RTX 5090 machine (I do not have its
nvidia-smioutput saved):The changed test,
later_reads_use_their_own_peak_under_a_falling_host_room, now covers a reading under a planned run (199 MiB against a 200 MiB run, which reads as two runs of one part), the newcheckbound (288 MiB) and the refusal of a part alone over the reading.Reproduction on a DGX Spark with
nvidia/Qwen3.8-Flash-Next-FP4-Localatb9ce18a6:with
BLOOMERY_DRAFT=off, and a second process that takes 16 GiB about nine seconds into the load, after the host-need line has printed.Base (main at
95a483fc2), exit 1:Head, same conditions, starts and answers the same prompt with the same text as the head without the extra process (
Paris. The capital of Germany is Berlin. The capital of Italy is Rome.):Head without the extra process prints no
parts::loadline.Load time on the normal path, to check that the change adds no cost when no run is cut. Median of three rounds after one lead-in round,
FP4-Localwith draft off, base95a483fc2against the same change:The smallest effect these runs resolve is 4.53% for the cold load and 0.70% for the warm load, so the table shows no difference beyond noise. This run used a 16896-token context, not the 33024 of the reproduction; no run is cut on this path, so the reads are the same.
just gate-gpu-libnot run: the unit tests above coverparts::testsonly, and a maintainer runs the selected gates on the workstation. I did not runjust contrib-check --tier t0or the clippy ratchet.Hardware
One DGX Spark running the reproduction and the load times above.
bloomery-servewas built forsm_121a. The unit tests ran on an RTX 5090 machine.AI help
AI 코딩 에이전트가 코드를 작성한 후 설명을 썼고, 테스트를 마쳤습니다. diff 리뷰와 PR 초안 리뷰는 제가 직접 했습니다.