Repository navigation
hf, model-hf: an FP8 or unquantized stack normalizes from bounded input batches into one output reserved at its length, as an NVFP4 stack does - #1101
Conversation
…ost peak, and every load the process's peak resident set
…ut batches into one output reserved at its length, as an NVFP4 stack does
There was a problem hiding this comment.
Verdict: CLEAN: No must-fix behavior or quality defect was proved in the changed code.
Non-blocking
⚠ Validate the reviewed revision: crates/model-hf/src/part.rs:1775.
The body names base 39ed53b8 and head f551c541; this review has base d748b6e0 and head 16876378. Attach gate output tied to this head and the hf/model-hf test commands and output, including the FP8 and BF16 batch cases.
Checked
Duplicates: 12 new or renamed items checked; no actionable duplicate. Dryer reported 0 pairs. GPU owners were searched manually. The byte append avoids the temporary value vector that safetensors::f32_values returns.
Complexity: crapper flagged no function. The added format arms select writers; no kernel body changed.
Silent failure: 5 fallback/error sites followed. Unsupported stack writers use the normal reader; malformed input returns a named error. An empty read plan reports zero duration. An RSS error omits the optional field.
Tests: static mutation audit, test line → production line and mutant below; each is caught by an assertion or test failure by inspection.
crates/gpu/src/parts.rs: 858 → 261, return zero read duration; 1121 → 243, skip release.crates/hf/src/modelopt.rs: 1865 → 1554, swap packed nibbles; 1884 → 1559, drop an expert scale; 1951 → 1381, swap BF16 bytes; 2330 → 1156, use the wrong scale index; 3219 → 1493, apply the input scale; 3252 → 756, drop the shape guard.crates/model-hf/src/part.rs: 1421 → 266, reverse expert order; 1523 → 644, retain every shard handle (direct reads supported); 1668 → 264, read all experts in one batch.
Gates: no pin, tolerance or gate was relaxed or removed.
Escape catalog: no C1–C4 pattern matched.
Adversarial checks: non-finite values, mismatched shapes, out-of-order read completion and an expert larger than the batch limit are handled by existing checks or the single-source batch rule. Changes affect loading; no decode or prefill cost changed.
Notes
Rust and GPU tests were not executed here. Independent arithmetic checks covered finite BF16 widening, final-length reservations and read-span aggregation. GPU evidence is marked unverified because the supplied commit hashes differ from the reviewed revisions.
Card check: needs-gpu. This pull request changes crates/gpu-gates/src/record.rs, crates/gpu/src/arch/qwen3moe/mtp38.rs, crates/gpu/src/host/node.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. |
FP8과 비양자화(BF16, F32) expert stack도 NVFP4 stack처럼 입력을 batch로 나눠 읽고 출력을 한 번만 잡게 하고, load 기록에 읽기 시간과 메모리 최대치를 더한 PR입니다.
What and why
Only an NVFP4 stack of expert tensors was read in bounded batches and accumulated into one output reserved up front. An FP8 or unquantized (BF16 or F32) stack held its whole input and grew its output as it went. This PR moves that rule into one shared
hf::modelopt::Stackthat every stack format uses. Input is read in bounded batches, and the output is reserved once at its final length. The folderCheckpointincrates/model-hf/src/part.rsreads every tensor this writer handles that way. A single FP8 tensor goes through the sameStack, so its planned read peak is counted once instead of three times.The
load phasesrecord gains three optional fields:read_s(wall time of the part reads),read_peak(the planned host peak of those reads) andrss_peak(the process's peak resident set). The checked-in record schemas are updated.Release notes: Under the hood: FP8 and unquantized expert stacks load from bounded input batches into one output reserved at its length, and the load record reports read time and peak memory.
Code shape
The review reads these first. A box left unticked needs one line of why.
copying it (
AGENTS.md"Common code first",docs/rust-quality.mdR14). Where I found an existing copy, Inamed it below.
(tensor shapes, the attention kind, the quant). A common owner gained no per-model branch, flag or trait method.
tools/check-comments.sh).cargo fmtandcargo clippyare clean on what I touched; the lint count did not go up.Duplication found or removed (
path:line), or "none":Nvfp4Stack,Nvfp4,nvfp4(),fp8()andplain_stack()incrates/hf/src/modelopt.rsare replaced by the oneStack. A single plain tensor and a plain stack write through the sameplain_values. The per-format scratch accounting thatpart.rskept for the read peak now comes fromStack::scratch.What I ran
The upstream base is
39ed53b875a0811cdaf587dd19963da24a650c48and the PR head isf551c541f85a2c7342c54ad5f0a5690f85945d31.Card and driver (raw output):
Model:
nvidia/Qwen3.8-Flash-Next-FP4-Local, revisionb9ce18a6887e18c089fdea8509a33e63429a3300. SHA-256 of each file:Build the PR head and start
bloomery-serveon the model above. The server prints its load record when the model is up:GB10 gates for the changed
gpuparts code:The clippy ratchet on the PR head (
cargo clippy --workspace --all-targetswith the workspace feature set):Hardware (if the change is for a machine)
AI help
AI 코딩 에이전트가 코드를 작성한 후 설명을 썼고, 테스트를 마쳤습니다. diff 리뷰와 PR 초안 리뷰는 제가 직접 했습니다.