Skip to content

gpu: a placed load reads the parts its host bytes planned instead of planning them again - #1030

Merged
juliankang4 merged 4 commits into
midagedev:mainfrom
juliankang4:dgx-spark-q38-opt-upload-full-write
Oct 30, 2026
Merged

juliankang4 merged 4 commits into
midagedev:mainfrom
juliankang4:dgx-spark-q38-opt-upload-full-write

Conversation

@juliankang4

Copy link
Copy Markdown
Collaborator

Qwen3.8 FP4-Local와 NVFP4 체크포인트를 카드에 올리는 시간을 DGX Spark에서 줄이는 PR입니다.

What and why

Loading a Qwen3.8 FP4-Local or NVFP4 folder onto a card spends most of its load time in the weight upload (upload_s). This PR shortens that step with three changes that touch only how the bytes get to the card:

  • crates/gpu/src/tensor.rs, weights.rs, upload.rs: a weight upload that writes its whole buffer no longer zero-fills the buffer first. DeviceTensor::unfilled allocates without a memset, and upload_whole rejects a take that is not the buffer's full size before it allocates. UploadRing::copy_split now rejects a row that does not fill both planes exactly. K-quant tails that rely on zero padding still use DeviceTensor::zeroed.
  • crates/model-hf/src/part.rs: Wholes::read splits a shard's extents over READ_LANES = 8 threads, so one shard's direct reads stay in flight together. A part still holds one shard open at a time, and the first error in extent order is the one returned.
  • crates/gpu/src/parts.rs: PlacedSource::reading plans a card's parts and costs once per card and card-tensor set, and a different room recomputes only the read-ahead (LoadPlan::at). Before, the host-bytes memo was keyed by room and missed at the load's room, so the load planned every part again. load_placed_in_place is folded into PlacedSource::load, its only caller, and two doc references are updated.

The placement rules, model formats, normalization, resident layout, zero padding and precision are unchanged.

Release notes: Changed: weight uploads skip the zero fill, a part's direct reads run in parallel and a placed load plans its parts once, so FP4-Local and NVFP4 folders load faster.

Code shape

  • No second copy. The size check lives in upload_whole and copy_split; the F32 and BF16 arms and planes::fill_whole no longer repeat it.
  • Model code holds only architecture facts. No model file changed.
  • Dead code is gone. fill_whole, its test and load_placed_in_place are removed.
  • No silent failure. A take or row that does not fill its buffer is refused by name before anything is written.
  • Comments state what is true now. The new comments carry no dates, numbers or issue numbers.
  • No relaxed gate. No band, tolerance or lint moved. tools/unsafe-ratchet.txt rises for the new allocation, with a PIN line.
  • cargo fmt and cargo clippy are clean on what I touched; the lint count did not go up.

Duplication found or removed (path:line), or "none": none. The duplicate scan reported no candidates.

What I ran

Timing is on one DGX Spark. The base is f924cd8c4a8e90dabf86cf7534afa4ee4152fcfb and the head is 69642d1480692433d8280a3717076a154c552ddd, both built with cargo oxide build --arch sm_121a -p bloomery-gpu-gates --release --bin bloomery-serve. The models are nvidia/Qwen3.8-Flash-Next-FP4-Local at b9ce18a6887e18c089fdea8509a33e63429a3300 and nvidia/Qwen3.8-Flash-Next-NVFP4 at fc694b54fb0174e0913e6adf86691ef85a4ead47.

| NVIDIA GB10, 595.84 | CUDA Version: 13.3 |

To reproduce, serve each side three times per model, alternating base and head, and read the load phases line the server prints at start:

BLOOMERY_DRAFT=off BLOOMERY_HOST_ROOM=96G ./target/release/bloomery-serve -m <model folder> --host 127.0.0.1 --port 18731 --parallel 1 --ctx-size 16896

Each cell is the median of three starts with its range in parentheses.

Metric Base Head Difference Ranges overlap
FP4-Local upload_s 11.33 s (11.31 to 11.47) 10.15 s (9.86 to 10.28) -1.18 s (-10.4%) no
NVFP4 upload_s 12.32 s (12.21 to 12.55) 9.94 s (9.86 to 10.00) -2.38 s (-19.3%) no
FP4-Local other_s 0.53 s 0.09 s -0.44 s no
NVFP4 other_s 0.46 s 0.07 s -0.39 s no

Decode, prefill and p95 TTFT are unchanged: FP4-Local decode 31.18 to 31.31 tok/s and NVFP4 decode 22.73 to 22.71 tok/s, with every range overlapping. The greedy replies of base and head are identical (greedy_equal: True).

GPU tests and gates on an RTX 5090 machine, driver 595.99.02, at head 9c23050339726b34a7425dd8bd0a6f1f14776cf1:

$ bash tools/gate.sh --gpu --oxide -p bloomery-gpu --release --lib -- --include-ignored parts:: planes:: weights::tests::hw_whole_uploads_leave_no_stale_byte
test parts::tests::a_placed_source_plans_a_cards_parts_once ... ok
test weights::tests::hw_whole_uploads_leave_no_stale_byte ... ok
test result: ok. 12 passed; 0 failed; 0 ignored; 0 measured; 457 filtered out; finished in 17.86s
$ just gate-gpu-nvfp4
gate_nvfp4 ran 19 s (exit 0)
$ just gate-gpu-mxfp8
gate_mxfp8 ran 29 s (exit 0)
$ just gate-gpu-bf16
gate_bf16 ran 6 s (exit 0)

AI help

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

@github-actions github-actions Bot added 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 30, 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: CLEAN: No must-fix defect was found in the changed allocation, shard-read or load-plan paths.

Non-blocking

⚠ Record FAIL-first runs: crates/gpu/src/weights.rs:1934. The PR lists passing runs only. Add failing mutant runs for the whole-buffer checks, room-sensitive cache reuse and extent ordering. This confirms the regression assertions before merging.

Checked

Duplicates: 8 new items checked, none duplicated; dryer reported no candidate pairs.
Complexity: crapper flagged no functions.
Silent failure: 5 sites followed. Whole/split size mismatches and truncated extents return named errors; unsupported direct IO uses mapped bytes; the empty-lane default is unreachable.
Tests: static mutation checks show that removing weights.rs:1792 or weakening upload.rs:192 breaks short-upload assertions; reusing a cached window across rooms breaks the cache assertion; removing part.rs:727 breaks extent-order assertions.
Gates: no numerical bands moved; the unsafe-count increase has a dated PIN and allocation-specific reason. The hardware test is ignored and hw-prefixed.
Adversarial checks: disjoint pread windows, empty extent sets, short buffers, changed room and changed card selections have guards or defined handling. Changes run at load time.
Escape catalog: C1–C4 do not match.

Notes

Static review only; builds and gates were not run here.
GPU evidence is incomplete: the GB10 card/driver line accompanies timings, while the RTX 5090 gate output lacks that card's nvidia-smi line and a matching base/head pair. Add those beside the gate output.

Card check: needs-gpu. This pull request changes crates/gpu/src/folder.rs, crates/gpu/src/model.rs, 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)

@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 294f8d6 into midagedev:main Oct 30, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gpu The card engine: crates/gpu*, crates/app needs-gpu Changes code a card must check, and carries no gate run on a card

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant