Repository navigation
hf, model: prepare reads Qwen3.8-Flash-Next-FP4-Local, its compressed expert scales decoded, its PLE table in NVFP4 rows and its MXFP8 weights as stored - #543
Conversation
There was a problem hiding this comment.
Verdict: MUST_FIX: The fixture generator duplicates the CSF32 part schema.
Must fix
1. Generate both CSF32 fixtures through one loop
crates/hf/tests/fixtures/csf_scales.py:142 and crates/hf/tests/fixtures/csf_scales.py:147 repeat the same five part names, dtypes, byte widths and serialization. This is one format fact with two owners (kind B; R14).
One loop removes the obligation to update both copies when the fixture format changes. Replace the two generation blocks at lines 139–148 with:
for stem, rows, cols in (("syn_csf32", 384, 43), ("syn_csf32k", 64, 8)):
m = scales(rng, rows, cols)
parts = csf32(m)
tensors.append((f"{stem}.weight_scale", "F8_E4M3", [rows, cols], bytes(v for r in m for v in r)))
for part, dtype, size, raw in zip(("bases", "codes", "page_bases", "offsets", "exceptions"), ("U8", "U8", "U32", "U16", "U16"), (1, 1, 4, 2, 2), parts):
tensors.append((f"{stem}.weight_scale.csf32_{part}", dtype, [len(raw) // size], raw))Checked
Both cited loops are added by the diff and contain the identical schema. The replacement reduces ten lines to six without adding a helper. It parses, produces the same 12 tensor records, and preserves the random generator state.
This is a full review; the PR is neither a revert nor a no-merge mirror. No ledger lessons apply. Escape catalog C1–C4 do not match the finding.
Notes
Rust and GPU tests were not rerun during validation. The PR body lacks the nvidia-smi line and just gate-* output required for GPU evidence.
Card check: needs-gpu. This pull request changes crates/gpu/src/arch/qwen3moe/body38.rs, crates/gpu/src/site.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)
…ups with one tensor scale, beside IQ4_NL and F8 gguf: GgmlType::NVFP4_ROWS (2002) is bloomery's own value type beside the F8 rows and MXFP8, with its row in qtype::OWN_ROWS: a group of 16 values in 9 bytes, its UE4M3 scale byte then its 8 code bytes in ModelOpt's order (value 2i in the low nibble of byte i, 2i + 1 in the high), its values e2m1 x scale x the one f32 of <stem>.scale. A row of any multiple of 16 values is whole groups; GGUF's NVFP4 block needs 64, and the FP4-Local checkpoint's PLE rows are 160 values (2.5 blocks). Every exhaustive table over GgmlType decides it (dequant_row refuses it, as it does the F8 rows, since it has no tensor scale; no card format or kernel entry takes it), and a split opens it as it opens the other own types. quant::Nvfp4Rows decodes such rows: the group's product e2m1 x scale is exact, so the tensor scale is the one rounding. A scale byte with bit 7 set or 0x7F is refused naming its group and the byte before any value is written. GgmlType::reads_scale names the types read with a <stem>.scale (NVFP4 and the F8 and NVFP4 rows), the one list the writer and the loader ask. gpu: Body38's PLE host takes the type as a third arm beside IQ4_NL and the F8 rows, its scale read by weights' tensor_scale, which asks reads_scale. The oracle is the ModelOpt rule computed from the checkpoint's own layout (codes [rows, k/2], one E4M3 scale a 16 values, the tensor scale), from the f64 e2m1 and UE4M3 test references: every scale byte that is a scale with every code at every place of its group, at scale 1 and at the table's weight_scale_2, and the first four rows of PLE parts 0 and 101 of nvidia/Qwen3.8-Flash-Next-FP4-Local b9ce18a6 (range-read), decode to the reference's f32 bits. The PLE host's rows over an NVFP4-row fixture equal Nvfp4Rows on the rows the hash names, and a table without its scale is refused by name, as for the F8 rows.
… as the plain weight_scale FP4-Local checkpoints store each routed expert's NVFP4 block scales in one of two encodings that weight_scale_encoding names: a row's base byte plus a 4-bit code, with the bytes the 16-wide window misses stored apart. hf::csf reads either back as the R x C F8_E4M3 bytes a plain checkpoint stores, by the rules of the encoders' published decoders (FlashInfer's _csf_blocks.py, vLLM's csf_scales.py), and refuses by name every part a rule does not allow. The fixture holds the real csf scales of layer 0 expert 0 gate_proj of nvidia/Qwen3.8-Flash-Next-FP4-Local, which decode to the sha256 of the plain weight_scale of the same weights in local-inference-lab's NVFP4 copy, and seeded csf and csf_32x2_v1 scales beside the bytes they encode; csf_scales.py regenerates it.
… PLE table in NVFP4 rows The table gains the lines nvidia/Qwen3.8-Flash-Next-FP4-Local needs: - NVFP4 with csf or csf_32x2_v1 scales: each weight's block scale is decoded (hf::csf) from the parts its place names, and the weight repacks as plain NVFP4 does, a linear or a routed stack, with the tensor scale its own place names. - NVFP4 read as a row table: GgmlType::NVFP4_ROWS, each 16-value group its scale byte then its 8 code bytes as stored, the tensor scale the one its place names; a scale byte that is no UE4M3 scale is refused by row and group, and a tensor scale that is not finite by name. prepare sizes and writes a .scale tensor from the type (GgmlType::reads_scale) rather than from the format, and each type's row sizes the tensor. prepare --keep-bf16 writes a BF16 matrix the map would make Q8_0 as stored. A normalized stack of two real ModelOpt experts, written as a split, opens through Split::open and decodes by dequant_row to the ModelOpt rule's rows: the path existing GGUF files take is unchanged.
…FP8 block as stored nvidia/Qwen3.8-Flash-Next-FP4-Local stores its full and linear attention, shared experts and indexer as MXFP8: F8_E4M3 values with a U8 E8M0 weight_scale, one byte a 32 values along k. The table writes such a weight as GgmlType::MXFP8 whatever plain type its role names: each row's blocks in order, each its scale byte then its 32 value bytes, so no value changes and splitting the blocks gives back the checkpoint's bytes. Every row is checked by gguf::quant::check_mxfp8 (E8M0 and E4M3 NaN, a product past f32) and refused naming its row; a stack, a weight that is not whole 32-value blocks and a scale of the wrong shape are refused by name. The MXFP8 row sizes the tensor in the shard plan (33 bytes a 32 values), and it reads no .scale. The V-head moves take whole MXFP8 blocks, as the row's block size already bounds them.
eace666 to
ac72792
Compare
There was a problem hiding this comment.
Verdict: CLEAN: No behavior or proven quality defect survived the input and consumer checks.
Checked
Duplicates: 48 new items checked; all five dryer pairs read. They use different error types or dispatch contracts. No duplicate warrants extraction.
Complexity: csf32 (29): validation/page walk/block decoding. nvfp4_rows (21): validation/packing. plain (23): moved code. PleHost::new (25) and prepare::run (63): format/CLI branches. as_u32/from_u32: harmless match arms.
Silent failure: four sites followed. Scale guards block invalid lookup entries; safetensors validation blocks partial words; missing PLE scales and unsupported format/role pairs return errors.
Tests: Static mutation review of new and changed tests:
- crates/gguf/src/qtype.rs:136: wrong row size breaks split assertions.
- crates/gguf/src/quant.rs:1033: dropped finite checks or swapped nibbles break refusal/reference assertions.
- crates/hf/src/csf.rs:275: wrong page origin, swapped nibbles or dropped structural checks break decode/refusal assertions.
- crates/hf/src/modelopt.rs:120: wrong format/role pairing breaks table assertions.
- crates/hf/src/modelopt.rs:222: accepting two row sources breaks the refusal test.
- crates/hf/src/modelopt.rs:378: wrong group scale or skipped validation breaks row assertions.
- crates/hf/src/modelopt.rs:290: dropped expert scales break split round-trip assertions.
- crates/hf/src/modelopt.rs:450: omitted scale bytes or accepted NaNs break MXFP8 assertions.
- crates/gpu/src/arch/qwen3moe/body38.rs:615: wrong decoder or missing scale acceptance breaks PLE assertions.
- crates/placement/src/kernels.rs:501: accepting row types as matrix sites breaks dispatch assertions.
- crates/model-hf/src/arch/qwen35moe.rs:1240: identity V-head ordering breaks the MXFP8 reorder assertion.
Fixture assertions cover all four compressed inputs. Rust and GPU suites were not rerun during validation.
Gates: Replaced unsupported-pair cases carry PIN(2026-10-20) and supported-path tests. No tolerance was relaxed.
Escape catalog: C1–C4 have no matching changes.
Card check: gpu-evidence. This pull request changes crates/gpu/src/arch/qwen3moe/body38.rs, crates/gpu/src/site.rs, crates/gpu/src/weights.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)
|
The review is done and the contribution check passed, so I'm merging this. |
|
화이팅이요!! |
NVIDIA의 Qwen3.8 FP4-Local 체크포인트를 prepare가 읽도록 하고, MXFP8 가중치는 값을 바꾸지 않고 MXFP8 블록으로 옮기는 작업입니다.
What and why
Part of #493, toward #458's "Qwen3.8-Flash-Next-FP4-Local served on one DGX Spark". It belongs to the shared format layer of #495 and does not touch the host types of the open IQ1_S round.
preparecould not readnvidia/Qwen3.8-Flash-Next-FP4-Localend to end. The checkpoint stores each routed expert's NVFP4 block scales compressed (weight_scale_encodingcsf, andcsf_32x2_v1in its sibling GLM checkpoint), the PLE table as NVFP4 parts of 160-value rows with one shared tensor scale, attention and the shared experts in MXFP8, and the rest in BF16. After this PR every one of its 1,224 mapped tensors gets a GGUF type, and the MXFP8 tensors keep their bytes. The PR adds table lines to the ModelOpt prepare path:hf::csfreads the two compressed encodings back as the plainweight_scalebytes and refuses each structural rule of the encoders' published decoders by name.normalizedecodescsfandcsf_32x2_v1scales first and then repacks as NVFP4 does. NVFP4 read as a row table becomesgguf::NVFP4_ROWS(from the PLE row PR): each 16-value group is its scale byte then its code bytes, and the tensor scale is the sharedweight_scale_2.normalizerefuses a row table whose tensor lists anything but exactly one source, and names the tensor.normalizewrites an MXFP8 matrix (F8_E4M3 values, one U8 E8M0 scale per 32 values along k) asGgmlType::MXFP8blocks byte for byte, with no requantization. It reusescheck_mxfp8for each row.prepare --keep-bf16writes a BF16 matrix as stored instead of Q8_0.Inputs that would overflow or exceed a size are refused by name instead of read:
Nvfp4Rows::decoderefuses any non-finite scaled value (a code times its group scale times the tensor scale) before it writes the destination.modelopt::nvfp4_rowscalls this one decoder for every stored group, so there is no second validator, and the error names the scale tensor, the row and the group.--shard-gibvalues whose byte count does not fit in u64 are refused, for example17179869185. The refusal table is the one already on main, anda_shard_size_out_of_range_is_refusedcovers it.modelopt_nvfp4.write, not a copy.Release notes: New:
preparereads NVIDIA's FP4-Local checkpoint of Qwen3.8-Flash-Next, and its MXFP8 weights keep their stored values.Code shape
linearandexperts. The row type is the PLE row PR's, and the product check lives in the one existing row decoder.cargo fmtandcargo clippy -D warningsare clean on what I touched; the lint count did not go up.Duplication found or removed (
path:line), or "none": the compressed-scale fixture writer is removed in favor ofcrates/hf/tests/fixtures/modelopt_nvfp4.py'swrite.What I ran
Head
ac72792857c7e30bc8cc97a9e1d63f2cc2774c07, base654f1b0e. The branch sits on upstream's move of the checkpoint map and the prepare binary intobloomery-model-hf, so this PR's changes are incrates/model-hf/src/arch/qwen35moe.rsandcrates/model-hf/src/bin/prepare.rs. Thebloomery-hfresult below ran on this head. The other test results ran on the earlier headef1fdafd; the later commits changed only the fixture generator, the row-table guard and the rebase.The reference for the MXFP8 check is the OCP MX rule computed independently from the raw checkpoint bytes: E4M3 value times 2^(E8M0 scale - 127) in f64, rounded once to f32. The two tensors were read from
nvidia/Qwen3.8-Flash-Next-FP4-Localatb9ce18a6887e18c089fdea8509a33e63429a3300by HTTP range requests.in_proj_a, 122,880 values, dequantized from the split MXFP8 blocksk_proj, 1,310,720 values, dequantized from the split MXFP8 blocksThe two tensors together are 1,433,600 values. This check ran on
38d228b4; the later fixes on this branch change only the NVFP4 row checks, size arithmetic and test fixtures.MAP-OK ... mapped=1224 with_gguf_type=1224 untyped=0. Of these, 396 are MXFP8: 300 with the Q8_0 role, 72 with the F32 role and 24 with the BF16 role.cargo test --release --locked -p bloomery-hf:test result: ok. 88 passed; 0 failed. It includescompressed_scales_and_row_tables_take_their_lines,a_compressed_scale_breaking_a_rule_is_refused_by_nameanda_row_table_of_two_sources_is_refused. Replacing the guard with a read of the first source only makes the last one fail.cargo test --release --locked -p bloomery-gguf --lib:test result: ok. 41 passed; 0 failed. It includesnvfp4_rows_refuse_by_name.cargo test --release --locked -p bloomery-model-hf --bin prepare:test result: ok. 3 passed; 0 failed; 1 ignored. It includesa_shard_size_out_of_range_is_refused.cargo test --release --locked -p bloomery-model --lib qwen35moe:test result: ok. 99 passed; 0 failed.cargo oxide test --arch sm_120 -- -p bloomery-gpu --release --lib -- ple_rows_decode_by_the_tables_type an_mxfp8_site_reads_the_f32_rows_and_is_a_gemv:test result: ok. 2 passed; 0 failed.cargo fmt --all -- --checkandcargo clippy --release --locked --all-targets -p bloomery-hf -p bloomery-tokenizer -p bloomery-gguf -p bloomery-placement -p bloomery-model -- -D warningspass on the same machine.Failing first:
called \Result::unwrap_err()` on an `Ok` value: Normal { type_id: 2002, dims: [160, 2], ...`. With the check, the same input is refused.capacity overflow.FAIL-FIRST: PASS.The two CSF32 blocks of
crates/hf/tests/fixtures/csf_scales.pyare now one loop. Regeneratingcsf-scales.safetensorsgives sha256214330ee31bda945074a4967cc54d696a6b0bc53c84c52daa674319d9f07b055, the same as the committed file.GPU evidence
On a DGX Spark (GB10),
just gate-gpu-nvfp4passed with exit code 0 in 9 s, and all 40 clause lines pass:It ran on
48554e24d605dcb4ed2746f869f405d521133888. Later rebases changed no GPU file of this PR.The gate loads synthetic NVFP4 tensors with their scales through
Weights::load_where, so it covers the NVFP4 row scale read inweights.rs. The PLE decode inbody38.rsis covered by the unit testple_rows_decode_by_the_tables_type.just gate-gpu-qwen4exp-e2ecould not run on this card: the gate refused withthe visible card NVIDIA GB10 is none of this workstation's cards (A6000, 3090).What I ran into
None of this blocks the PR.
Hardware (if the change is for a machine)
The change is for DGX Spark.
prepareis host-only Rust, and the RTX 5090 run covers the GPU tests that read these types.AI help
AI 코딩 에이전트가 코드를 작성한 후 설명을 썼고, 테스트를 마쳤습니다. diff 리뷰와 PR 초안 리뷰는 제가 직접 했습니다.