Repository navigation
gguf, engram, model, gpu: Qwen3.8's PLE table in F8_E4M3 rows with one tensor scale, beside IQ4_NL - #490
Conversation
…e tensor scale, beside IQ4_NL gguf: F8E4M3_ROWS is bloomery's own value type (private id 2000, one byte a value): its values are the F8_E4M3 bytes times the one f32 of <stem>.scale. Split::open sizes it through bloomery's private table, so a model split may carry it while the strict opens and ggml's readers still refuse the file; Split::block answers a block's values and bytes for ggml's types and that one. quant::E4m3Rows decodes such rows through a 256-entry table built once from the scale; 0x7F and 0xFF, E4M3's NaNs, are refused with the byte and its index. engram: SplitTable sizes a row by Split::block, so the NVMe tier reads an F8 table as it reads a ggml-typed one. model: qwen35moe's role table gives the PLE table's per_layer_token_embd.scale the site's layer and Role::Unread, so the plan classifies a file that carries it and leaves the scalar in the file for the load to read by name. gpu: Body38's PLE host decodes the rows the hash names by the table's type: IQ4_NL by dequant_row as before, F8 rows by E4m3Rows at the table's scale, read by weights' tensor_scale (now also for that type). The oracle is the existing f64 ue4m3 test reference in quant.rs, signed: every byte decoded from the E4M3 definition times the scale, at scale 1 and at the checkpoint's BF16 0x3951, rounded once to f32. All 254 bytes that hold a value decode to its bits, from memory and from a split file; the PLE host's rows over an F8 and an IQ4_NL fixture equal E4m3Rows and dequant_row on the rows the hash names. A qwen4exp header with an F8 table and its scale describes through PlanInputs::describe_in with both on the PLE site.
There was a problem hiding this comment.
Verdict: CLEAN: No reachable failure or proven quality defect was found in the changed code.
Checked
Duplicates: 16 new function, type and constant definitions checked; none duplicated. Dryer reported no candidate pairs.
Complexity: PleHost::new rises 17 → 23 through type and scale validation; those error paths were traced. roles::role rises 16 → 19 through a scale-name match arm; this is harmless table growth.
Silent failure: 5 sites followed. Three PLE size defaults reach named refusals. Skipped NaN lookup entries are rejected before consumption. Ignored fixture removal affects cleanup only.
Tests: Source mutation audit of all six new tests:
- Split-open: remove the private table at crates/gguf/src/lib.rs:703; opening fails.
- Engram rows: restore ggml-only sizing at crates/engram/src/rows.rs:114; opening fails.
- Exhaustive byte oracle: drop the sign or scale at crates/gguf/src/quant.rs:916; bit assertions fail.
- Split-reference decode: write only the final value at crates/gguf/src/quant.rs:939; row assertions fail.
- PLE host: replace the supplied scale with 1 at crates/gpu/src/arch/qwen3moe/body38.rs:608; value assertions fail.
- Placement: delete the scale arm at crates/model/src/arch/qwen35moe/roles.rs:170; classification fails.
Gates: No existing gate, test, clause, tolerance or pin was relaxed or removed. The body supplies FAIL-first results for split opening and scale classification.
Escape catalog: C1–C4 have no matching changes.
Adversarial checks: Short rows, NaN bytes, malformed scales and incompatible table shapes are refused before PLE upload. Failed decoding leaves committed hash history unchanged. The host decode/prefill path adds no per-token allocation, launch, device copy or synchronization; the lookup table is built at load.
Notes
Repository tests and hardware gates were not run here. An independent arithmetic check matched all 508 finite byte/scale cases at scales 1 and f32 bits 0x39510000.
The reported GPU runs omit the nvidia-smi card/driver line, so GPU evidence is incomplete.
Card check: needs-gpu. This pull request changes crates/gpu/src/arch/qwen3moe/body38.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. |
…wo tests, then_some, PleRows boxes its F8 table Co-Authored-By: Claude Opus 5.5 <[email protected]>
Qwen3.8의 PLE 테이블을 NVFP4 체크포인트에 들어 있는 F8 형식 그대로 읽어 쓰게 하는 작업이고, 기존 IQ4_NL 경로는 그대로입니다.
What and why
Part of #458, toward this line of its section 7: "Qwen3.8 served from the NVFP4 checkpoint on one DGX Spark, against a pinned reference".
This PR lets Qwen3.8's per-layer embedding (PLE) table come in F8_E4M3 rows with one scale for the whole tensor, beside the IQ4_NL rows the PLE host reads on main. NVIDIA's NVFP4 checkpoint of Qwen3.8-Flash-Next stores the table that way, with the scale as the BF16
0x3951(about 1.9932e-4). Here the scale sits in the GGUF asper_layer_token_embd.scale, one F32 value besideper_layer_token_embd.weight. Nothing writes a file with the new row type yet; preparing a split from the checkpoint is a later item of #458.What the PR adds:
gguf::F8E4M3_ROWS, a private row type with id 2000: one F8_E4M3 byte a value, and every value is multiplied by the one f32 of<stem>.scale. The id is in bloomery's own range, outside every ggml table.Split::openopens its shards with this type, and the newSplit::blocksizes it next to ggml's types. The strictGguf::openstill refuses it by the tensor's name.gguf::quant::E4m3Rowsdecodes such rows through a 256-entry table ofe4m3(byte) x scale, built once at load. E4M3 has no value for0x7Fand0xFF(they are NaN), so a span holding one is refused asQuantError::E4m3Nanwith the byte and its index, before any value is written.PleHostinbody38.rspicks the decode by the table's type: IQ4_NL rows throughdequant_row, F8 rows throughE4m3Rowsat the table's scale. The scale is read bytensor_scaleinweights.rs, which NVFP4 tensors already use and which is nowpub(crate), so a missing, multi-value or non-finite scale is refused the same way for both. Row bytes come fromSplit::block.SplitTableinengramsizes rows throughSplit::block, so the NVMe tier reads an F8 table as well.qwen35moeinroles.rsgivesper_layer_token_embd.scalethe PLE site's layer andRole::Unread. The plan then classifies a file that carries the scale and leaves the scalar in the file, where the load reads it by name.Existing paths: a GGUF without the private type opens, plans and decodes through the same code as on main. The IQ4_NL arm of the PLE decode is main's loop body inside a match arm. In the existing tests of
gguf,engram,modelandbody38.rs, only theuseline of thebody38.rstest module changes. No kernel or launch changes, and a file without the table's scale gets the same placement plan as on main.Release notes: Under the hood: Qwen3.8's PLE host reads its table in F8_E4M3 rows with one tensor scale, beside IQ4_NL rows.
Code shape
The review reads these first. A box left unticked needs one line of why.
tensor_scale, row sizing of a private type isSplit::blockfor bothSplitTableandPleHost, and the E4M3 decode isE4m3Rowsalone, built on the existingue4m3.body38.rsgains only the choice of decode by the table's type, androles.rsgains only the role of the table's scale.unsafe.cargo fmtandcargo clippyare clean on what I touched; the lint count did not go up.cargo fmtis applied on the changed crates; clippy runs in the t0 check below.Duplication found or removed (
path:line), or "none": none.What I ran
Head
f68ba68f7d94b3e5b08faec8341a581ec9662e84, baseb5ddb224ee9a4d4146f9ebbf74bedd685e42cfe4. A result from an earlier commit names that commit. Those commits differ from the head as follows:5e7adf75is on the same base. From it to the head, only test code incrates/ggufchanges (the test module ofquant.rsandcrates/gguf/tests/fixtures).24dee325is on an earlier main, and the main commits between that base and this one touch none of the changed files. From it to the head, the change differs only in test code incrates/ggufand in themodelpart (the scale's role arm inroles.rsand its test).The reference for the decode is
e4m3_reference()in the tests ofquant.rs. It takes the test module's f64ue4m3, which decodes a byte from the E4M3 definition and which the NVFP4 tests already use. It adds the sign bit and the two NaN bytes, multiplies by the scale and rounds once to f32. That gives 512 entries at the two scales: 508 values and 4 NaN. Each decoded value is compared with its f32 bits:0x39510000), on the heade4m3_reference()test quant::tests::e4m3_rows_decode_every_byte_to_the_reference ... ok.scale, decoded row by row, at24dee325e4m3_reference()test quant::tests::a_split_in_f8_rows_decodes_to_the_reference ... okAt both scales, 254 of 256 bytes decode to the reference's f32 bits;
0x7Fand0xFF, which the reference leaves as NaN, are refused by name.The role of the scale ran at
5e7adf75, withcargo test -p bloomery-model --lib an_f8_ple_table_and_its_scale_describe:test arch::qwen35moe::place::tests::an_f8_ple_table_and_its_scale_describe ... ok. The test describes a qwen4exp header with an F8 table and its scale, and finds both on the PLE site. With the scale's arm removed fromroles.rs, the same test fails withthe file describes: Unclassified { names: ["per_layer_token_embd.scale"] }.The runs below were made at
24dee325, except the last one:Split::openrefuses a one-shard split whose table is in F8 rows, withUnsupportedType { name: "per_layer_token_embd.weight", ty: Unknown(2000) }andtest result: FAILED. 0 passed; 1 failed. With the change,test private_tests::bloomerys_f8_rows_open_through_a_split ... ok.cargo test --release -p bloomery-gguf -p bloomery-decision: thegguflibrary endstest result: ok. 37 passed; 0 failedanddecisionendstest result: ok. 52 passed; 0 failed. Everycargo test --release -p bloomery-engramtarget endsokwith 0 failed.cargo test --release -p bloomery-engram --test engram -- --include-ignored --exact hw_engram_f8_rows_table_reads_rows_of_its_width:test hw_engram_f8_rows_table_reads_rows_of_its_width ... ok.BLOOMERY_ARCH=sm_120,bash tools/gate.sh --oxide -p bloomery-gpu --release --lib:test result: ok. 239 passed; 0 failed; 52 ignored. This includesple_rows_decode_by_the_tables_type, which checksPleHostover an F8 table againstE4m3Rows, over an IQ4_NL table againstdequant_row, and the refusal of an F8 table without its scale.BLOOMERY_BOX_LOCAL=1 just gate-gpu-nvfp4: every clause PASS,rc_nvfp4=0. Itstensor_scalerefusals are unchanged:want="lone.scale is not in the file"andwant="not a finite value"both PASS.BLOOMERY_ARCH=sm_121,bash tools/gate.sh --oxide -p bloomery-gpu --release --lib ple_rows_decode_by_the_tables_type:test arch::qwen3moe::body38::tests::ple_rows_decode_by_the_tables_type ... ok, thentest result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 290 filtered out.just contrib-check --tier t0on this head: TBD(t0 /^DONE tier=/)Not run on a DGX Spark: the full
bloomery-gpulibrary suite andgate-gpu-nvfp4. The change is host code with no kernel, so the GB10 run covers the PLE test alone.What I ran into
None of this blocks the PR. Nothing outside the change came up in these runs.
Hardware (if the change is for a machine)
The change is for DGX Spark, where #458 serves Qwen3.8. The new code runs on the host and adds no kernel. The GB10 run was on a DGX Spark in the CUDA 13.3.1 container. The GPU library and
gate_nvfp4ran on an RTX 5090 machine, and the host tests on a Linux machine.AI help
AI 코딩 에이전트가 코드를 작성한 후 설명을 썼고, 테스트를 마쳤습니다. diff 리뷰와 PR 초안 리뷰는 제가 직접 했습니다.