Repository navigation
gguf, gpu, placement: MXFP8 weights (E4M3 blocks of 32 with an E8M0 scale) in a gemv and the F32 tile, bloomery's own types named with rows - #521
Conversation
There was a problem hiding this comment.
Verdict: CLEAN: No must-fix finding remains; verification evidence needs completion.
Non-blocking
⚠ Complete the verification artifacts: crates/gpu/src/q8f32.rs:645 changes the shared Q8_0 walk. The supplied PTX comparison starts at an earlier PR head, so it does not prove the move/add class against the PR base.
Run bash tools/ptx-compare.sh 146c13027d5311ee804f7094730b0a6f009f617f gate_e2e --features gpu and attach its output. Include the raw nvidia-smi line, model paths, and literal gate/A/B commands with output, as CONTRIBUTING.md requires. This makes existing-kernel changes traceable.
Checked
Duplicates: the common ByteBlocks walk serves both formats. Dryer's gemm/dense pair decides different admission sets.
Complexity: diagnostics flag two new gate functions, dispatch growth and added format-table arms; complexity alone is not a finding.
Silent failure: MXFP8 launch validation rejects unsupported column counts before the kernel's early-return path.
Tests, static mutation check: gate_mxfp8 initializes outputs to NaN, so omitting an output store fails its written-output check. It also checks host-rule bits and f64 error bands.
Gates: dense-admission and unsafe-count updates carry dated PIN reasons.
Escape catalog: C1–C4 do not match changed recipes or tool lines.
Notes
Repository tests and GPU gates were not rerun during validation.
Card check: needs-gpu. This pull request changes crates/gpu-gates/Cargo.toml, crates/gpu-gates/src/bin/gate_load_v41.rs, crates/gpu-gates/src/bin/gate_mxfp8.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)
…cale) in a gemv and the F32 tile, bloomery's own types named with rows gguf: GgmlType names bloomery's own value types, F8E4M3_ROWS (2000, main's private split entry) and MXFP8 (2001, 33 bytes a 32 values: the E8M0 scale byte, then 32 F8_E4M3 bytes), with rows in qtype::OWN_ROWS beside ggml's QROWS, so every exhaustive table decides them and blck_size, type_size and dequant_row answer without id guards; Split::block and the split's private table go. A strict Gguf::open still refuses them and Split::open opens them. dequant_row decodes MXFP8 as e4m3(q) x 2^(e - 127); an E8M0 0xFF and an E4M3 NaN byte are refused by name before any value is written. The host matmul has no MXFP8 kernel and refuses the type by name. gpu: q8f32's Q8_0 lane walk is generic over ByteBlocks (one byte a value, a block scale lookup); the Q8_0 entries keep their names and paths, and mxfp8_gemv and mxfp8_gemv_mcol are the same walk with the E4M3 value and the E8M0 scale. The card holds MXFP8 in two planes (DevWeight::Mxfp8): value bytes as words and scale bytes four to a word, so a row is a multiple of 128 values. The F32 tile stages its rows through TileRows; mxfp8_tile_gemm decodes MXFP8 rows into shared memory as it stages them, bit for bit the F32 tile over the decoded rows. site::gemv and site::gemm launch an MXFP8 site, and site::resident_gemv runs one column of a resident weight by its form. Weights::join_rows joins MXFP8 parts as it joins Q8_0 ones (join_byte_rows). placement: CardFormat::Mxfp8Planes and kernels::dense's SiteEntry::Mxfp8 (f32 activations); no routed, GEMM-route, head or embed row, and a routed MXFP8 stack stays off the card. glm5next: body::gemv calls site::resident_gemv, so the projections it runs take MXFP8 when the file holds it. gate_mxfp8 holds the gemv at 1 to 8 columns and the tile at 64 bit for bit to the host rule and within the derived band at three projection shapes, the Q8_0 site gemv and the F32 tile bit for bit to their rules, a joined MXFP8 weight, and the load's refusals by name; --bench-kernels prices the gemv beside Q8_0. The three new entries are pinned at 0/0 in the three ptx-shapes tables; the unsafe ratchet moves for their blocks (PIN lines).
0be9b34 to
77e271d
Compare
There was a problem hiding this comment.
Since the last review: the verification-artifact request is answered. The PR body supplies the requested PTX comparison, card and driver lines, model paths, and gate/A/B commands with results.
Verdict: CLEAN: The rebase resolution adjusts the unsafe-ratchet totals to match the source and changes no runtime code.
Checked
Duplicates: 0 new items in the interdiff. Dryer's gemm/dense pair was read; the functions decide different admission sets.
Complexity: no function changes in the interdiff.
Silent failure: 0 new runtime sites in the interdiff. The reviewed MXFP8 maximum uses a nonempty 32-byte block, so its default is unreachable.
Tests: no test changes in the interdiff. Static mutation check: dropping an MXFP8 output store leaves a NaN sentinel and fails gate_mxfp8's written-output check.
Gates: tools/unsafe-ratchet.txt:348 has a dated reason. Independent counts equal the pins: base 1960/214/10, head 1974/222/10. The base's two alignment-test blocks remain included.
Adversarial check: the counter adjustment leaves no allowance above the counted source.
Escape catalog: C1–C4 match no interdiff line.
Notes
Tests and GPU gates were not rerun during this review.
Card check: gpu-evidence. This pull request changes crates/gpu-gates/Cargo.toml, crates/gpu-gates/src/bin/gate_load_v41.rs, crates/gpu-gates/src/bin/gate_mxfp8.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. |
MXFP8 형식(E4M3 값 32개와 E8M0 스케일 하나)의 가중치를 카드의 dense gemv와 prompt GEMM으로 돌리고, bloomery 자체 타입(F8 rows, MXFP8)을 GgmlType의 이름 있는 변형으로 만드는 작업입니다.
Part of #458, section 7 (weight formats).
What and why
NVIDIA's FP4-Local checkpoints (GLM-5.3-Flash-FP4-Local, Qwen3.8-Flash-Next-FP4-Local) ship their attention and dense projections as MXFP8: F8_E4M3 values with one E8M0 scale byte per 32 values along K (OCP MX). ggml has no MXFP8 type, and a Q8_0 repack is lossy (E4M3 spans about 2^17.8 inside a block, int8 2^7), so the exact path is a kernel that reads the blocks as they are.
What the PR adds:
GgmlType::MXFP8(id 2001, 33 bytes a 32 values: the E8M0 byte, then 32 E4M3 bytes) andGgmlType::F8E4M3_ROWS(id 2000, which main holds as a private table entry) as named variants with rows in a newqtype::OWN_ROWS, beside ggml'sQROWS. Every exhaustive table decides them as it decides ggml's types, soblck_size,type_sizeanddequant_rowanswer withoutUnknown(id)guards, andSplit::blockand the split's private table go.QROWSstays ggml's table and nothing else;OWN_ROWSispub(crate). A strictGguf::openstill refuses both, andSplit::openstill opens them.dequant_rowdecodes MXFP8 ase4m3(q) x 2^(e - 127). Three inputs are refused by name before any value is written: an E8M00xFF(NaN), an E4M3 NaN byte, and a block whose scale times one of its values would leave f32's range. The card load (mxfp8_planes) runs the same check per row.q8f32.rs: the Q8_0 lane walk becomes generic over aByteBlockstrait (one byte a value, a block scale lookup), withQ8_0BytesandMxfp8Bytes. The Q8_0 entries keep their names and code paths;mxfp8_gemvandmxfp8_gemv_mcolare the same walk with the E4M3 value and E8M0 scale.mxfp8_gemv_mcolwrites its output asy[c * n_rows + r]and takes no row or column stride. The card holds an MXFP8 weight in two planes (CardFormat::Mxfp8Planes,DevWeight::Mxfp8): the value bytes as words, and the scale bytes four to a word, so a row is a multiple of 128 values.f32tile.rs: the F32 tile stages its rows through aTileRowstrait;mxfp8_tile_gemmdecodes MXFP8 rows into shared memory as it stages them, so the prompt GEMM is the F32 tile over the decoded rows, bit for bit.placement:kernels::densemaps MXFP8 toSiteEntry::Mxfp8(f32 activations); no routed, GEMM-route, head or embed row. Qwen3 resolves uploaded MXFP8 attention projections to that dense site. A routed MXFP8 stack stays off the card (of_routed), and the host tier refuses the type by name (activation_format).site::resident_gemv: a one-column gemv of a resident weight by the site type of its resident form. GLM re-exports it asbody::gemv, so the KDA and latent projections that go through it (qkv,f_a,g_a,beta,f_b,g_b, the KDA and latent outputs, the latentstackandq_b) run MXFP8 when the file holds it, with no GLM arm. The latentk_b/v_bheads and the prompt GEMMs keep their Q8_0 calls.Weights::join_rowsjoins MXFP8 parts the way it joins Q8_0 ones (join_byte_rows, one function for both), so a model that joins its Q/K/V or latent rows at load (GLM'sBody::derive) keeps MXFP8 rows resident.Existing paths: a Q8_0 site launches the same entries (
q8_0_gemv,q8_0_gemv_mcol) with the same bits. The gate below holds the Q8_0 site gemv and the F32 tile bit for bit against their host rules, and the comparison section measures the Q8_0 path against main. The pinned-pairs tests ofkernels.rskeep every pair; the dense pairs gain(MXFP8, Mxfp8). A file with F8 rows opens and decodes as before (private_tests::bloomerys_own_types_open_through_a_split,ple_rows_decode_by_the_tables_type).Release notes: Under the hood: MXFP8 weights (OCP MX, E4M3 with an E8M0 scale per 32 values) run as dense gemv and prompt GEMM sites on the card.
Comparison with the reference
Reference: the host rules
runtime::hc_gated::card::q8_dotandf32_dot, plain host f32 loops that call no GPU code, in the byte order the kernels promise, plus an f64 band for each output. The gategate_mxfp8writes synthetic MXFP8 tensors at GLM-5.3-Flash'sattn_q_b(16,384 x 1,536),attn_output(4,096 x 16,384) andssm_f_b(8,192 x 128) shapes, plus 8 x 128 tensors whose scales are E8M0 0, 1 and 254, into a GGUF, loads them throughWeights::load_whereand compares every output. The 64-column case runs throughsite::gemm, the dense route table. The gate ran on a DGX Spark GB10 (driver 595.84,sm_121) at 1535fdcc, which a rebase onto current main turned into this PR's head 0be9b34 with an equal range-diff. The Q8_0 rows were measured on 0be9b34.Existing Q8_0 path, main 146c130 against head 0be9b34, on a DGX Spark GB10 (driver 595.84,
sm_121): two sittings, each on one lease, with the run order main, head, head, main, main, head, head, main, so each sitting has four runs a side and the pooled rows have eight. Both sides ran the samegenerate_qwen3moe(qwen4exp fixture) orgenerate_glm5next(GLM fixture,--place gate) command line,--tokens <512-id prompt> -n 64 --ctx 768 --time --warm 4 --logits. The GGUF header of each fixture shows Q8_0 tensors (50 in the Qwen fixture, 52 in GLM's first shard). The repository's depth script could not read the drive counters of a bind-mounted fixture directory in the node container, so a script with the same command line ran the binaries. Decode is the p50 step rate over 59 kept steps. Prefill is one 512-token pass. GLM runs showed slow outliers on both sides (59.91 and 54.21 tok/s), so the GLM rows use medians.gate_mxfp8clauses (gemv at 1 to 8 columns, tile at 64, scales E0, E1 and E254, refusals)All 16 runs of each fixture print the same 64 token ids and the same final logits digest on both sides (qwen4exp fnv64
62de1ee7c0808c87, GLM57f4f0dc7c85c2d6).Result: the Q8_0 path stays inside run noise: qwen4exp decode -0.29 % and prefill -0.37 %, GLM decode median -0.21 % and prefill median -0.01 %, with the same tokens and logits. Direct effect of the new kernel: on a GB10 the one-column
attn_q_bMXFP8 gemv reads 253.8 GB/s, 1.02 of the 249.4 GB/s read ceiling (Q8_0 253.6 GB/s). On an RTX 5090 it reads 1447.2 GB/s, 85.3 % of the 1696.7 GB/s ceiling (Q8_0 1523.6 GB/s). Those two were measured at earlier heads (RTX 5090 b2419d44, GB10 76364a0f) and not repeated here. The end-to-end number this opens is decode of the two FP4-Local checkpoints with their MXFP8 attention weights on the card, which this PR does not measure.Code shape
ByteBlocks; the tile is the F32 tile overTileRows; bloomery's own types are rows, not id guards. The gate takes its oracles fromruntime::hc_gated::card.site::resident_gemvasbody::gemv; the other GLM change is a plan test.Split::blockand the split's private table are removed. The unused row and column strides ofmxfp8_gemv_mcoland theByteBlocks,Q8_0Bytes,Mxfp8BytesandOWN_ROWSpublic surface with no outside caller are removed or narrowed topub(crate).Duplication found or removed: the
Unknown(2000)id guards of main (weights.rstensor_scale,body38.rs) became the named variant.Mxfp8Weight::dimensionsowns the plane checks for both the GEMV and tile launchers.What I ran
Head 0be9b34 on base 146c130, unless a line names another head. Raw
nvidia-smilines and model paths are listed in the last part of this section.PTX comparison against base 146c130
On an RTX 5090 (driver 595.99.02, compute capability 12.0), at head 0be9b34:
The script exits 3 whenever an entry changes. The three added entries are the MXFP8 kernels and nothing is removed. The nine changed entries are the Q8_0 and F32 tile entries that now share the byte-block walk. The script prints a register or spill difference when one exists, and it prints none for these nine, so their resource rows equal the base's. Their PTX text still differs: the scale load and the convert are split, and a few address adds and one
mul.f32operand order moved, so these are not identical-PTX moves. The Q8_0 A/B in the comparison section and the GLM owning gate below cover that difference at run time.gate_mxfp8and the GLM owning gateOn a DGX Spark GB10 (driver 595.84,
sm_121), at 1535fdcc (the same tree as 0be9b34 before the rebase onto current main, range-diff=):Sample lines of those 73 (all PASS):
The GLM owning gate, same node and head:
BLOOMERY_MODEL=glm5next BLOOMERY_TIER=fixture bash tools/box.sh "bash tools/gpu-gate.sh gate_glm5next_e2e --only main --step-sets short"Its decode graph has 172 nodes, and graph and eager tokens
[24743, 143121, 123778, 45905, 153205]and logits match bit for bit.FAIL-first for the gate: replacing the MXFP8 arm of
site::gemmwith a refusal still left the previous gate at 73 PASS, which was the gap. The fixed gate exits 1 on that change withblk.3.attn_q_b.weight is MXFP8: it has a gemv (site::kgemv) and no wide GEMM. Reversing the four FMAs of the production walk fails thebitsclauses at every shape while everybandclause passes. A pre-fix tree accepted2^61 + 1columns whose products wrap, and the addedcolumn-overflowclause fails on it.Q8_0 A/B against main
Both sides ran on the GB10 below, in two sittings of one lease each, order main head head main main head head main. Each sitting ran this on the node through the repository's lease, card and witness scripts (
tools/ref/lease.sh,tools/ref/card.py,tools/box.shin local mode, fixture tier). The per-arm command lines were:Per sitting and side (4 runs each; decode is the p50 step rate, prefill one 512-token pass):
The GLM sittings hold slow outlier arms on both sides (head 59.91 tok/s in sitting 1; main 54.21 and head 70.95 in sitting 2), kept in the table, so the pooled rows in the comparison section use medians. Every other GLM arm is 86.2 to 86.7 tok/s on both sides. All 16 runs of each fixture print the same 64 token ids and the same final logits digest on both sides.
Other checks
mxfp8_gemv_mcolpin to 8 in the three tables makestools/ptx-spill-check.shprint four violation lines, for examplegenerate_ds41 mxfp8_gemv_mcol spill=0 pinned=8 BELOW. With the committed pins no violation line names an MXFP8 entry. The three MXFP8 entries are pinned at spill 0 and local 0 (sm_121andsm_86, cc 12.1 tables).cargo test -p bloomery-placement --lib(150 passed),cargo test -p bloomery-model --lib mxfp8(1 passed),cargo test -p bloomery-gguf --lib own_types(1 passed) andcargo fmt --all --check.cargo oxide test --arch sm_121 -- -p bloomery-gpu --release --lib -- mxfp8 site:: q8f32::, 9 passed and 0 failed, at 091ce3a5 (the tree before thetoo_many_argumentsallows were removed; the carry diff touches no code).Hardware and model paths
Raw
nvidia-smioutput of the GB10 runs (gate and owning gate, node at 1535fdcc):Clocks around the second A/B sitting on the same card (
name, driver, SM clock, memory clock, power, temperature), idle before and loaded after, with no other compute process:Raw
nvidia-smi --query-gpu=name,driver_version,compute_capline of the RTX 5090 PTX comparison (the 1696.7 and 1447.2 GB/s bandwidth rows were measured at b2419d44 on an RTX 5090 with the same driver, 595.99.02):Model paths.
gate_mxfp8uses no model file: it writes synthetic MXFP8 tensors into a temporarymxfp8.ggufand deletes it. The GLM owning gate and the A/B use fixtures:/models/fixtures/glm5next/glm53-fixture-00001-of-00003.gguf(shard 1 of 3; 52 Q8_0 tensors, fromoutput.weight (4096, 154880)toblk.3.ffn_gate_shexp.weight)./models/fixtures/qwen38/qwen38-fixture-00001-of-00001.gguf(50 Q8_0 tensors, fromoutput.weight (2560, 248320)toblk.3.hc_ffn_up.weight).What I ran into
This does not block the PR. The earlier 6-token run of the unchanged main binary on the GLM fixture produced two token sequences, which blocked a same-output claim. With a 512-token prompt and 64 generated tokens, all 16 runs of main and head agree, so I no longer see a mismatch on this fixture. I did not find the cause of the earlier difference.
AI help
AI 코딩 에이전트가 코드를 작성한 후 설명을 썼고, 테스트를 마쳤습니다. diff 리뷰와 PR 초안 리뷰는 제가 직접 했습니다.