Repository navigation
gpu: count named file formats in weight censuses - #715
Conversation
There was a problem hiding this comment.
Verdict: CLEAN: The censuses and staging budget now use the existing format selector and match the upload layouts.
Checked
Duplicates: 1 new item checked, the regression test; no duplicate contract found. Dryer reported 0 pairs in crates/gpu; crates/gpu-gates was not searched by dryer and its changed callers were checked manually.
Complexity: crapper flagged no function; the changed callers replace sizing expressions without adding branches.
Silent failure: 4 error/default sites followed. P10 rejects unknown formats, Qwen propagates errors or panics with context, and the budget fallback only sizes the bounded staging ring. Upload validation still rejects invalid layouts.
Tests: restoring type-only sizing at crates/gpu/src/weights.rs:1394 fails the new assertions for both BF16 head widths. The PR reports FAIL-first host checks for the budget and all three census paths; that harness is absent from the supplied tree.
Gates: no pins, thresholds or cases removed or relaxed. The assertions still compare predicted bytes with loaded bytes.
Escape catalog: no patterns matched.
Adversarial checks: aligned and unaligned BF16 heads select the uploaded layouts; tied embeddings retain F32 sizing. Empty or zero-sized tensors and odd-width BF16 heads reach explicit refusals.
Performance: load-time sizing and gate code only; no decode, prefill or kernel path changed.
Notes
The GB10 gate witness omits both tested commit hashes, so GPU evidence is marked false. The author did not run the P10 or Qwen dense gates. This review was static; no CUDA build or gate was run here.
Card check: needs-gpu. This pull request changes crates/gpu-gates/src/bin/gate_p10.rs, crates/gpu-gates/src/bin/gate_qwen35_dense.rs, crates/gpu/src/weights.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. |
BF16 출력 헤드(output.weight)의 적재 크기를 실제로 올라가는 형식(MXFP8 또는 BF16 원본)으로 계산하도록 고치는 수정입니다.
Part of #565. Tracked in #699.
What and why
A standalone BF16
output.weightis uploaded as MXFP8 when K is a multiple of 128, and as raw BF16 otherwise. Three census paths and the load's staging-ring budget sized that tensor withresident_size, which takes only the tensor type and so counts the default F32 layout. A correct load then tripped its own resident-byte census, and the staging budget was larger than the bytes the upload moves. For a head with 64 rows and K=256 the old arithmetic gave 65,536 B where the upload takes 16,896 B; at K=320 it gave 81,920 B where the upload takes 40,960 B.The defect came in with e53cabe (#665), which made the head's format depend on its name while these callers kept sizing by type alone.
The fix reuses
weights::part_format, which already picks the format by tensor name and computes its resident bytes throughCardFormat::resident_bytes, the arithmetic the uploads check against. No new helper or public item is added, and uploads, weight conversion, kernels and output bits are unchanged.crates/gpu/src/weights.rs:upload_budgettakes the bytes frompart_formatand falls back to the file bytes only when the tensor has no named format. The doc comment ofresident_sizenow says it sizes the type's default format and points file tensors topart_format.crates/gpu-gates/src/bin/gate_p10.rs: the file-tensor census loop usespart_format. The derived Q8_0 sizing, which is not a file tensor, keepsresident_size.crates/gpu-gates/src/bin/gate_qwen35_dense.rs: the derived weight sum and the all-file sum usepart_format.I checked the other
resident_sizecallers.gate_p2tests the Q5_0 format itself.gpu-gemma-embedding2::card_bytesis limited bycheck_typesto Q8_0 matrices and F32 vectors, so a standalone BF16 head cannot reach it.model::probecounts the resident variants that were actually loaded.Release notes: Fixed: a BF16 output head is sized by the format it is loaded in, so the weight censuses and the upload staging budget agree with the uploaded bytes.
Code shape
part_formatowner. Duplication found or removed: none.cargo fmtandcargo clippy:rustfmt --edition 2024 --checkon the three changed files reports no diff (rc 0), andcargo clippywas not run for this body.What I ran
The test added in
crates/gpu/src/weights.rs,file_upload_budget_counts_the_named_format, checks bothpart_formatandupload_budgetfor six cases: the BF16 head at K=256 and K=320, the tied token embedding, an ordinary BF16 matrix, an F32 head and a Q8_0 head. A host-side harness compiles the functions and the byte arithmetic from the test-only baseline commit and from the fix commit against the real placement and GGUF crates, with only the GPU error wrapper replaced by a host stand-in. It runs four checks: that test, the P10 census loop, the Qwen derived-weight sum and the Qwen all-file sum. The census checks read a GGUF file with a BF16output.weightand ablk.64.attn_q.weighttensor, each with 64 rows and K=256, and expect 16,896 B for the head, 65,536 B for the ordinary tensor and 82,432 B in total.The baseline fails all four checks first, and the upload budget check computes 65,536 B where 16,896 B is expected. The fix passes the same four checks. The harness prints
headcensus: PASS: base 4 assertion failures; head 4 passesand exits with rc 0.Also run:
git diff --check upstream/main...HEAD(rc 0) and the duplicate-code scan of the branch (rc 0, no candidates).GPU evidence. The card, driver and CUDA lines from
nvidia-smion the DGX Spark that ran the GPU gate:just gate-gpu-p10andjust gate-gpu-qwen38dneed DeepSeek-V2-Lite Q3_K_M and Qwen3.8-27B Q4_K_M, which were not on the machine, so I did not run them. Instead I ranjust gate-gpu-qwen3moe-types, which builds its own two-layer qwen3moe GGUF and loads it whole and placed onto the card through the sameWeightsload path. It ran on this fix and on upstream main without it:Both runs print the same four result lines and end with rc 0. This gate has no BF16 output head, so it shows that the real upload path still loads and passes its resident check with the new sizing. It is not a FAIL-first for this defect. The FAIL-first is the four host checks above.
What I ran into
This does not block the PR.
gate-gpu-p10,gate-gpu-qwen38d) were not run. A run on a machine that has those models would confirm the fix end to end.expected_planeshas no reference packing for an arbitrary BF16 file. Widening that support is a separate change from this arithmetic fix.AI help
AI 코딩 에이전트가 코드를 작성한 후 설명을 썼고, 테스트를 마쳤습니다. diff 리뷰와 PR 초안 리뷰는 제가 직접 했습니다.