Repository navigation
Conversation
|
Thanks, @ElderOrb. Serving ModelOpt NVFP4 and FP8 Qwen3.5 checkpoints on HIP through the BF16 rocBLAS path is in scope. A few things first:
We have no AMD GPU, so please post your own main-against-branch numbers, naming the gfx target, along with drafted replies equal to |
54ade02 to
5b32fc7
Compare
655c707 to
bba2f2b
Compare
|
@ElderOrb thanks, keeping the codes as stored is a much better design: the NVFP4 weights are now the checkpoint's, the E4M3 → BF16 table is exact, the NaN and zero-global refusals are in, and admission goes through
We have no AMD GPU, so please post main-against-branch numbers, naming the gfx target. |
dc497a5 to
62823de
Compare
|
Rebased and reworked since your note; the body above describes the current state. Summary of what changed:
Still open, and in the body: the |
|
Thanks @ElderOrb, this is a much better shape. The codes and E4M3 tables stay as stored, one product kernel serves On your FP8 question: the exact route, please. Widen the bare E4M3 values (exact in BF16), sum in f32, and apply the What's left, smallest first:
We have no AMD GPU, so your numbers are the receipt for this one. Main is closed for a release right now, but none of |
cb32ea6 to
6b1b659
Compare
3. Contract on the record toolchain — gfx1151Both ends measured with the toolchain the records were produced on:
Sorting both logs' FAIL lines and diffing them (
One correction to what I posted earlier: the 540 figure came from a local 4. Test counts — gfx1151
The two failures are The lower total than the earlier number I quoted (10048) is the CUDA tests: this box has no |
|
Thank you @ElderOrb for the test counts and the record-toolchain correction. The earlier items are still open: the FP8 16-row path needs the tile's per-chunk partial and a one-row against 17-row test for both formats. We also still need the four-chip records, the gfx1151 contract and test counts, the refreshed body, the rocBLAS gate decision, a squashed series and one MLX reply equality against main. This head also conflicts with current main in zig/src/core/quant/quant.zig, so please rebase when you post the fix.
|
8. One MLX checkpoint's greedy reply: equal on
|
| prompt | main |
this head |
|---|---|---|
| "Write the integers from 1 to 20 in order, separated by single spaces, and nothing else." | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 — 51 tokens, finish_reason: stop |
byte-identical, 51 tokens, stop |
| "Explain in about 150 words why the sky appears blue, then list the three primary colours. Do not use markdown." | 111 tokens, 597 characters | byte-identical, 111 tokens |
Both replies compared with -ceq over the whole string, not a token window; completion counts and finish_reason agree, so nothing diverged and the head did not cut short.
The second reply, from the head, in full:
The sky appears blue because sunlight, which is white, contains all visible colors. When sunlight reaches the Earth's atmosphere, it interacts with gas molecules like nitrogen and oxygen. These molecules absorb the longer wavelengths of red and orange light while scattering the shorter wavelengths of blue and violet light in all directions. This scattering process, known as Rayleigh scattering, is most effective for shorter wavelengths. Consequently, when you look up, your eyes receive the scattered blue light, making the sky appear blue.
The three primary colours are red, green, and blue.
main produced the same text.
One note on the build: lighton_ocr.hip:182 still refuses M_SQRT1_2 on this toolchain, so a local 0.70710678f shim went into both trees to compile. That file is identical in both and is not touched by this PR; the 2B path does not reach it.
On the conflict: this head applies to 61fe90343 with a three-way apply, all 37 files clean, and GitHub reports mergeable: true, mergeable_state: clean. The overlap you saw is real in the sense that main added pub const gptq beside our nvfp4 doc line, but the hunks do not collide. I will still rebase onto 61fe90343 when I squash, since the series has to be rewritten anyway.
|
I ran the same Linux x86_64 host check with Zig 0.17.0 on zig build test-qwen35 test-qwen35-hip-host hip-host-test check-native-hip-host \
-Dhip=true -Dfixed-cpu -j5 --summary allThe PR head passed 257 tests with four skips, and main passed 260 with four skips. Git merges the two cleanly, but the combined tree fails to compile at The head also contains the requested FP8 and NVFP4 one-row versus 17-row cases at K=192, and the FP8 small tile resets its partial inside the 64-code loop. Those GPU cases still need a device receipt for the rebased head from Retested the updated head Igor Lessio - AIFLOW LABS |
6aac7db to
e57bc11
Compare
Merge into main: fixed in the branchThank you - that is exactly the break, and it was mine to fix. The branch is now rebased onto What I ran on that head, on this box (Windows,
One caveat on that device run, since you asked for a receipt rather than a claim: the suite's last group (nemotron) ends in Also for the record on the merge itself: after the rebase, Igor - thanks for running the trial merge twice and pinning the line; that is the kind of report that makes this cheap. |
Follow-up: the
|
| case | rows 1 | rows 17 |
|---|---|---|
| nvfp4 96x192 | 0.000 | 0.000 |
| fp8 96x192 | 0.004 | 0.008 |
and the same run prints the 64x64, 160x128 and 48x96 tile cases, all inside their bound.
Two more numbers from the same head, since the body now carries them:
zig build -Dhip=true test: 769/772 steps, 10344/10594 (247 skipped, 3 failed) here, againstmain's 769/772 steps, 10322/10572 (247 skipped, 3 failed) on the same host. Same three failures, both files untouched by this PR.hip-kernel-contract-limits: 847FAILlines on both trees, 207 / 212 / 212 / 216 per chip,Compare-Objectreports no difference;PASS292 here against 268 onmain, the +24 being the ModelOpt rows.tools/zig/lean_check.py: 168 problems on both, no difference;engine.zigis 590 lines againstmain's 575, and the merge's is 590 as well.
The head is e57bc1132, one commit on b7298b4ea.
Rebased, and CI is green
What I re-ran on this base: The device numbers in the body (tests, contract limits, |
|
The rebased With that one hunk resolved, all 21 build steps passed on M5 Max with Zig 0.17.0, including the HIP native build check. The host targets passed 171 tests with two skips: zig build test-qwen35-hip-host test-native-hip-host test-draft-hip-host \
test-qwen-hip-formats-host check-native-hip-host -Dhip=true -Dcpu=apple_m1 -j4 --summary allThis verifies the combined admission and format paths at host level. The gfx1151 device receipts are separate. Igor Lessio - AIFLOW LABS |
5a756b0 to
8a8bec6
Compare
Ready for review: all checks greenHead The Re-ran on this base: The device receipts in the body are still the ones from @ashhart - open for a look whenever you have a slot. Every point from your last review is addressed and nothing is outstanding on my side. |
|
/atc exchange 499dad70edb8224aaedcb30875f061f11946e3a56e6edd167a00adfab831583d |
Rebased onto current
|
|
Thanks @ElderOrb for the ModelOpt kernels, the row-invariance checks, and the repeated rebases. Two host loading cases still need fixes:
These are host loader fixes; the existing kernel and output receipts do not exercise either trigger.
|
A ModelOpt checkpoint writes NVFP4 as E2M1 codes with a 16-element-block scale and one global scale, and FP8 as E4M3 codes with one scale, neither of which the shared formats name. This reads both as they are stored and decodes them on the device, so a converted checkpoint serves without being re-quantized to MLX's layout. NVFP4 keeps its E2M1 code through the BF16 dot2 product, which is exact for the format's levels; FP8 decodes in flight and is exact in f32. Both run through one 64 x 64 tile that stages a column chunk once and serves 64 rows, with a 16-row block for a decode round summing as the tile does. The host projection is the family's own union of the shared formats, `quant.nvfp4.Host` and a stored FP8, so core's format vocabulary keeps the three formats both engines read. A routed expert stack stays core's: a global scale an expert, so NVFP4 stacks are refused. A ModelOpt checkpoint's bf16 layers read dense. Scale handling carries the review's asks: FP8 scales ModelOpt does not write are refused, as is a weight holding an E4M3 NaN code, and each refusal names the tensor and the reason through core's `Why` buffer rather than an uninitialised name. A decode round on the product ran the 16-row block, which distributes its threads over all sixteen rows while writing only a.m of them, so fifteen sixteenths of the work is discarded at m = 1. The same header gains four entry points, tf_nvfp4_col1 to tf_nvfp4_col4, over one nvfp4_columns<ROWS, DEPTH>: a thread owns one output column, reads that column's whole K span, and holds ROWS accumulators. The launch picks the entry point whose ROWS matches a.m exactly, so no row is padded and a row's offset stays constant. They are separate entry points rather than a branch on a.m because the contract records resources an entry point, and a branch would make every variant carry the widest one's registers. nvfp4_columns prefetches DEPTH chunks into registers and fetches the next before the group loop consumes the held one. On gfx1151 at a 5120 x 5120 layer, m = 1: 0.0969 ms against 0.2516 ms reading each chunk in place, 2.6x, and 0.0580 ms for the prefetched form that follows the guard - 282.5 GB/s, 17.5x the single-chunk form. A guard clause that returns early measured 2.6x slower at 22 VGPRs against 33, so the prefetch sits after the guard rather than replacing it. Against the product on the same host, m = 1: attention 5120 x 1024 14.86x, gate/up 5120 x 17408 4.96x, down 17408 x 5120 7.79x, lm_head 5120 x 151936 5.22x. At m = 2: 13.71x, 4.86x, 8.85x, 4.90x. Row variants at 5120 x 5120: m = 1 9.81x, m = 2 9.92x, m = 3 7.33x, m = 4 7.03x, every one bit-identical to the tile. A K that is not a multiple of 64 keeps its tail on tf_nvfp4_gemm. build/hip.zig's headers list becomes hip_headers.zig, which walks every .hpp under zig/kernels/hip instead of naming them. The list it replaces had gone three headers out of date - quant/nvfp4.hpp, nvfp4_tiles.hpp and fp8_tiles.hpp were missing - so an edit to one left the .hsaco that includes it stale, and the four new symbols then failed to resolve in affine_tiles although they were compiled. A walked list cannot be left out of, and hip.zig loses ten lines to it. The product records name the tile's measured LDS on the four served chips. `hip-kernel-contract-limits` on gfx1030, gfx1100, gfx1151 and gfx1201 after the 64 x 64 tile and the 16-row decode block: the tile stages a column chunk in LDS, so NVFP4 holds 16384 bytes (was 11264) and FP8 18432 (was 12288), and FP8's scale and accumulator registers moved with it. The four column entry points' records, measured on the same run (VGPRs / SGPRs / LDS bytes): - tf_nvfp4_gemm: 138/38/16384, 144/38/16384, 144/38/16384, 143/36/16384. - tf_fp8_gemm: 58/49/18432, 56/49/18432, 56/49/18432, 58/48/18432. - tf_nvfp4_col1: 130/22/0, 138/22/0, 138/22/0, 138/23/0. - tf_nvfp4_col2: 164/26/0, 165/26/0, 165/26/0, 164/28/0. - tf_nvfp4_col3: 148/31/0, 145/30/0, 145/30/0, 147/34/0. - tf_nvfp4_col4: 121/32/0, 141/32/0, 141/32/0, 144/38/0. All 24 ModelOpt lines read "record current" on all four chips, and the run's problem count is the same as before this branch: 799 on the base and 799 here, every line of them predating it. Main's prompt tail names the shared handle's dense tag (prompt_tail.zig:63); the handle is optional here, so it asks the projection's format instead.
A single-format ModelOpt FP8 checkpoint declares quant_algo FP8 and carries no config_groups, so the config check fell through to the NVFP4 branch and refused it before the FP8 tensor reader ran. admit and admitRecipes now take one rule through singleFormat: NVFP4 checked as ModelOpt writes it, plain FP8 accepted per tensor. Sharing the one rule keeps the two entry points from drifting, and every other algorithm is still refused by name; the grouped FP8 formats are named MXFP8 and FP8_PB_WO and stay refusals by module. The Qwen-shaped MTP head always splits the fused mtp.fc, but the FP8 split returned UnevenSplit. It now cuts the codes into two contiguous halves along K, keeps every row in order, and shares the projection's one F32 scale between them. Tests: both entry points admit one ModelOpt FP8 config fixture, an INT4_AWQ fixture is still refused by name, and an FP8 fused FC beside the pre-FC norms checks both halves' shapes, code bytes and the shared scale. zig build test: 6528 passed, 168 skipped, 0 failed.
|
Thanks @ElderOrb. The plain-FP8 config admission and fused MTP FC split now address both loader asks, including the new fixtures and shared scale. One build dependency still needs restoring: the Merged with current main, two HIP engine modules go over 600 lines; we'll split those on our side when we integrate, keeping the current admission behavior.
|
|
Both host loader cases are fixed, in 1. Single-format ModelOpt FP8. 2. The FP8 fused Locally |
|
Thanks @ElderOrb. The plain-FP8 admission and fused MTP FC split remain fixed, including their fixtures and shared scale. The later dependency request is still open: the header scan selects only The current merge is clean. The two module splits remain ours, preserving the existing admission behavior.
|
Serves NVIDIA's ModelOpt NVFP4 and FP8 checkpoints on the HIP engine without widening a weight.
What the checkpoint holds, and what the engine keeps
For a projection of N outputs from K inputs ModelOpt writes
weightU8 e2m1 codes [N, K/2] (input 2i in the low nibble),weight_scaleE4M3 [N, K/16] andweight_scale_2, one global scale. An FP8 layer writes E4M3 codes [N, K] and one f32 scale a projection.The host keeps exactly those tensors, and the device keeps that layout too - as
quant.mlxdoes - so an upload is a copy. The one transform is at read: an E4M3 group scale widens to BF16, exactly (three mantissa bits fit seven). A F32 block table is refused (ModelOpt writes E4M3, and the kernel reads a 16-bit table), and a stack of experts is refused because its experts carry a global scale each.The preflight counts what the device holds rather than the stored files:
table.deviceByteskeeps U8 and E4M3 code tensors as stored and counts only an E4M3 group table at two bytes a value.Kernels
quant/nvfp4_tiles.hppserves a prompt throughtf_nvfp4_gemm: a 64 x 64 tile stages a column chunk once and serves 64 rows, a thread a 4 x 4 block of output elements (acc[4][4],ty = tid & 15,tx = tid >> 4, 256 threads), a group's 16 inputs folded in f32 with the group's own E4M3 scale, the one global applied to the sum once, the nibble through an e2m1 bit table.A decode round takes
tf_nvfp4_col1..tf_nvfp4_col4instead (launches/nvfp4.zig:78, chosen ata.m <= 4with@rem(a.k, 64) == 0, gridceil(n / 256)): a thread a column andROWS(1..4) of that column, summed in the same per-group order, reading codes and scales straight through registers (hold[2][8], no LDS at all), so a decode row's bits are the tile's bits and the row's work is not padded out to sixteen rows.tf_nvfp4_smallremains the 16-row LDS block for a round wider than four rows.quant/fp8_tiles.hppis its sibling for FP8,tf_fp8_gemm: each E4M3 code turns into the exact f32 it names, all of K sums in f32, and the projection's one scale multiplies the result once, as CUDA'sqmmf.cureduce does. A short row keeps each chunk's partial in f32 and adds it once, so a row that crosses a chunk carries the rounding the 64-row tile does and the result stays row-invariant.Both serve bf16 activations only, since the engine refuses an fp16 build for a ModelOpt checkpoint; one kernel serves a prompt's rows and a round's, so a row's bits never depend on its round.
Why dedicated kernels rather than the shared GEMM and stream tiles: both step along K in 32-code chunks (
kGemmK = 32,nch = a.k >> 5, a chunk's scale indexq >> gshift), and NVFP4's group is 16, so a chunk holds two scales:a.group / kGemmKis 0 and the shift would have to be negative.tiles/stream.hppandtiles/dot2_tiles.hipkeep only their MLX code.The engine
A ModelOpt checkpoint's own bf16 layers (an
lm_head, an unquantized linear, the MTP head) read as.denseon the row-invariant dense kernels rather than through rocBLAS, so the engine keeps main'se.plain()gate and opens no rocBLAS for them. The vision tower never calls rocBLAS either (no blas reference inzig/src/vision/qwen_hip.zig), so the engine carries notowerfield.A ModelOpt checkpoint carries its own refusals: an fp16 build and more than one rank are refused by name, and graphs stay off. A ModelOpt checkpoint with routed experts is refused by name too, before its shards are read. A refusal names the tensor and the reason through core's
Whybuffer.The format tag
core.quant.Formatno longer names NVFP4 or FP8: it andDecoderare the three formats both engines read. A projection still has to carry them, soquant.Projectiongains optionalnvfp4andfp8fields beside a nullablehandle, andformat()/decoder()return optionals. The family's host projection is its own union, withrows,bytes,read,halves,sliceRowsandsliceColsover it; its device projection is a union ofquant.Device,quant.nvfp4.Deviceand its FP8 tensors.Kernel contract
hip_records_nvfp4.zigholds every entry point's resources fromhip-kernel-contract-limits, in gfx1030, gfx1100, gfx1151, gfx1201 order (VGPRs / SGPRs / LDS bytes):tf_nvfp4_gemm: 138/38/16384, 144/38/16384, 144/38/16384, 143/36/16384.tf_fp8_gemm: 58/49/18432, 56/49/18432, 56/49/18432, 58/48/18432.tf_nvfp4_col1: 130/22/0, 138/22/0, 138/22/0, 138/23/0.tf_nvfp4_col2: 164/26/0, 165/26/0, 165/26/0, 164/28/0.tf_nvfp4_col3: 148/31/0, 145/30/0, 145/30/0, 147/34/0.tf_nvfp4_col4: 121/32/0, 141/32/0, 141/32/0, 144/38/0.Bound 256, wave32, no scratch, and every ModelOpt line reads "record current" on all four chips when the contract is taken with the toolchain the records were made on. The tile stages a column chunk in LDS, which is why the product kernels moved from the pre-tile numbers (NVFP4 11264, FP8 12288); the col entry points carry no LDS because a column's codes and scales stay in registers.
Re-run to confirm, on this head:
zig build hip-kernel-contract-limits -Dhip=true -Dhipcc=<hipcc>compiles the contract for gfx1030, gfx1100, gfx1151 and gfx1201 and audits every chip's records. 77 of 79 build steps complete; the audit's run step then exits 1 on the inherited failures below.I re-ran it here, and the result depends on which compiler takes the contract, so it is worth stating exactly:
HIP version: 7.2.26024-f6f897bd3d,AMD clang version 22.0.0git- all six ModelOpt lines read "record current" on all four chips, as the records above were written that way.HIP version: 7.16.26385-7da43026e4,AMD clang version 24.0.0git- all six read "record" against different numbers:tf_nvfp4_gemm118/33 on gfx1030, 111/33, 111/34, 111/32, where the records hold 138/38, 144/38, 144/38, 143/36. FP8 reads 56/53 on every chip against a recorded 58/49, 56/49, 56/49, 58/48. A newer clang allocates registers differently; the kernel source is unchanged between the two runs.So the records are current for the compiler they name, and a future toolchain bump will move them. That is why every record carries the compiler in the body above rather than only the numbers.
hip-kernel-contract-limitsonb7298b4eaand one57bc1132with the same toolchain, and every one of the 847FAILlines appears in both, all in kernels this PR does not touch (RMS norm, mamba, and their neighbours); per chip the counts are 207 / 212 / 212 / 216 on both sides, andCompare-Objectover the sortedFAILlines reports no difference either way. The PR's only effect on the audit is the 24 new ModelOpt lines, and all 24 pass. (An earlier revision of this body said 540; that was the same audit under a clang 24 toolchain, where the inherited count moves - the base-against-head run above, on the toolchain the records name, is the one that shows what this PR changes.)lighton_ocr.hip:182, which refusesM_SQRT1_2on this toolchain. That file is byte-identical tomainand is not touched by this PR. A local shim for that one constant (0.70710678f, the same float asM_SQRT1_2) lets the build reach 77/79, which is where the numbers above were read; the shim is not part of this PR.The same run compiles every group for the four chips, which is the gfx1100 and gfx1201 build.
tests/hip/contract_nvfp4.zigcarries a test type for both and the runner builds it; on gfx1151 (Radeon 8060S):All ten ModelOpt lines pass on the current head. The two known findings are the bf16 prompt tiles' NaN classes, which predate this branch. The run's 189 other
limits livelines are other kernels' recorded resources against this host's hipcc (a different ROCm version from the one that recorded them); none of them is a ModelOpt launch, and none is touched here.Testing
zig build -Dhip=true teston gfx1151, this head onb7298b4ea: 769/772 steps, 10344/10594 tests (247 skipped, 3 failed).mainatb7298b4ea, same command on the same host: 769/772 steps, 10322/10572 tests (247 skipped, 3 failed), so the branch adds 22 tests and skips none. The three failures are the same three on both trees, and neither file is touched here:flashnext/hip/tables.zig's two pool tests (lines 483 and 517) cannot pass off Linux, becausehost_pages.zig:109returnscold() == falseunconditionally whenbuiltin.os.tag != .linux, so the pool is never woken; andfamilies/nemotron/hip/embedding.zig:106cannot map its temporary table on Windows,std.Io.ThreadedreturningAccessDeniedfrom the page-file mapping. Both files are byte-identical to the base commit. An earlier run of this command reported 3977/4100 tests because that build carried no CUDA suites; with the CUDA toolchain on the path the same tree builds them too.8a8bec665once0264367; the one conflict wasnative.zig'sserved(...), where main now passes the drafter (served(e, d, streams, capacity, readouts)) so admission counts its scratch: that call is kept as main has it, with this branch's ModelOpt format names on top. The rebase also brings inaec48047e/17a554e16, which fix the walk-away race this branch's last CI run hit inrequest_admission_http_test.zig:503(a file this branch does not touch); on that runzig-bwas green andzig-windows/zig-macos-dev-toolswere cancelled behind the one failing host step. On that base I re-ran the host targets (test-qwen35,test-qwen35-hip-host,test-native-hip-host,check-native-hip-host, all with-Dhip=true -Dfixed-cpu),zig fmt --checkon the changed files, and the lean check above: all pass. The device numbers above (tests, contract limits,hip-kernel-test) are the ones measured ate57bc1132onb7298b4ea; the card is serving another model right now, so I did not displace it for a re-measure.tools/zig/lean_check.pyreads 165 problems on this head and 165 onmainatce0264367, the same set:Compare-Objectover the sorted lines reports no difference, so the branch adds none. That matters for the 600-line rule:engine.zigis 590 lines againstmain's 575, and the merge's is 590 too sincemainis this head's parent. The shared handle's optionality moved one line,prompt_tail.zig:63, top.format() == .dense.quant.nvfp4.referenceandquant.fp8.e4m3in f64 against the bound each kernel's chain derives, print the worst error, and check a row against the format reference alone at one, three and five rows.hip/kernel_tests/fp8.zig:119andnvfp4.zig:150then compare one row with the same row inside a round of seventeen at K = 192, so the round crosses the sixteen-row threshold and the two sides take different paths; the row's outputs must be equal bit for bit, which is what pins the short path's per-chunk sum to the tile's.unfit, the exact widen, halves and slices), the preflight count, the FP8 and F32 refusals, the ModelOpt MoE refusal, that a ModelOpt checkpoint's dense layers land on.densethrough a realCheckpoint.open, that an E4M3 NaN code is refused by name, and that a ModelOpt checkpoint offers its NVFP4 formats toqwen3_5alone.Served: the checkpoint loads and answers
nvidia/Qwen3.8-27B-NVFP4at revision482ca0f3(19 files, 20.44 GB, the three shards checked against their LFS oids) serves throughzig build native-hipon gfx1151 (Radeon 8060S),zig 0.17.0, TheRock's ROCm SDK withHIP version: 7.2.26024-f6f897bd3dandAMD clang version 22.0.0git(targetx86_64-pc-windows-msvc):A greedy request answers correctly and repeats bit for bit across runs (the same
token_sha256twice). TheMIXED_PRECISIONheader gives the loader no trouble: format is read from the tensors,weight_scale_2for NVFP4 andweight_scalefor FP8, and the checkpoint's 208 FP8 and 193 NVFP4 layers both load.Decode is 2.0 tok/s and TTFT 4.75 s at 8192 context, one stream at a time, drafting on. That is 20.63 GiB of weights read per token at 2.0 tok/s, about 44 GB/s.
The card's ceiling, measured by a pure
read_onlypass over 2 GiB and confirmed byhipInfo(512-bit bus, 800 MHz memory clock): 240 GB/s. A 5120 x 5120 NVFP4 layer's 16.38 MB of codes fit in the 32 MB MALL, where the same read runs at 732 GB/s.So decode reaches about 18% of the floor. The prompt path is a 64 x 64 tile and was timed directly at that shape:
Rows = 1 is not in that table because decode does not take the tile: it takes
tf_nvfp4_col1(see Kernels). Those kernels were not timed in isolation - the SDK has norocprof/omniperf- so their rate is only observable end to end, which is the 44 GB/s above. The two are not comparable directly: the tile's 22.7 GB/s atm = 1is a path decode no longer runs, and the ~2x it would suggest cannot be separated from the x86 harness in this SDK. What is measurable is that decode reaches 18% of the card while the prompt tile reaches 5%.Two candidates I measured on the tile and ruled out:
xs[16][64](sixteen threads share a row): padding the stride to 68 changes nothing but 1.09x, outputs bit-identical.kE2m1Bf16declared__device__rather than__constant__: moving it to constant memory is 1.00x - the cache already absorbs it. Unrolling the 16-deep accumulator chain into four gives 1.13x, also bit-identical.Together those explain 1.23x of the tile's gap. The rest is launch geometry: a 64 x 64 tile at
m = 1would be 80 blocks of 256 threads on a card that holds 40,960 threads, withnvfp4_smallspreading its threads over all sixteen rows ofxswhile writing onlyrow < a.m- fifteen sixteenths of the work discarded. That is exactly whattf_nvfp4_col1stops doing: its grid isceil(n / 256), a thread owns a column, and no row is padded out to sixteen.This is a kernel-optimization gap, not a correctness one - every contract gate and the 17-row tests pass, and the bit-for-bit determinism holds. I would rather report this honestly and improve the decode path further in a follow-up than tune it inside this PR, whose subject is that these checkpoints serve as stored.
Memory: a separate patch, and what the numbers mean
The working-set arm is not in this branch. The numbers below were taken with a small local patch applied on top of this head. That patch is now its own pull request, #3866: it touches
core/checkpoint*, the loader every family and every backend shares, so it does not belong in a PR about the NVFP4 format. Nothing in this branch's diff changes loading memory; without the patch this branch behaves exactly asmaindoes.The finding, so the second PR has a record: on Windows the reader had no way to drop a step's shard pages.
safetensors.zig:265gatesreleaseonbuiltin.os.tag != .linux, andcheckpoint_drop.zig,checkpoint_file_cache.zigandshard.zig'smadviseare Linux-only too, somodel.zig:66's "nock.release()between layers" held for a reason that did not apply. The pages stayed in the process's working set, which is what made a load look like it needed far more memory than it does.The patch adds
platform/working_set.zig(reached assys.working_set, beside the other Win32 declarations) as the Windows arm, called fromCheckpoint.release/releaseExceptand fromqwen3_5/weights/checkpoint.zig'sreleaseafter a layer's files are walked: oneSetProcessWorkingSetSize(GetCurrentProcess(), -1, -1)per step, not per tensor, since Windows has no per-range advice. It removes pages from the working set and leaves them on the standby list, so a later read is a soft fault, not disk.Measured on the card with that patch compiled in (2 s sampling, gfx1151, the 8192-token server, external trimmer off so only the build's own
releaseacts):main(no trim arm on Windows)The private bytes do not move (peak 0.76 GB either way), so the 18.47 GB was mapped shard pages, not the process's own allocations. The standby list holds the pages the trim dropped instead of the working set holding them, so a later read is a soft fault: the load takes 259.8 s against 259.3 s, within noise.
At
--parallel 8 --context 32768the same arm holds: peak working set 2.86 GB, lowest free RAM 14.06 GB, standby growing to 16.56 GB as the shards are read once and kept. No disk read repeats.A 27B checkpoint now loads on a 32 GiB Windows side.
Concurrency and drafting, measured
All rows below are the same greedy prompt, the same 64
max_tokens,temperature: 0,--context 8192,--snapshot-dir none, so every reply is directly comparable and every row'stoken_sha256is the same hash.At
--parallel 2:e02735d4c9b7e02735d4c9b7"draft": false, 2 runse02735d4c9b7e02735d4c9b7Three things this settles:
accepted=41/67 rounds=23againstaccepted=0/0 rounds=63."draft": falsereply and the drafted reply hash identically, which is the contracttokens.zig:124states ("drafted and"draft": falsereplies must match"). The format's row-invariance is what makes that hold.At
--parallel 8 --context 32768, the same shape:bf993d6b8399eache02735d4c9b7eachEvery concurrent reply is bit-identical, so the format and the row-invariant products hold under a shared round. What does not hold is throughput: eight streams reach 3.4 tok/s together, 1.6x a single stream rather than 8x, and each stream's TTFT degrades from 4.75 s to 9.5-37.6 s as the eight prefills queue behind each other (the log's
queued=field lands at 4.3-4.7 s a request). Drafting collapses under the load too:accepted=83/131solo againstaccepted=5/12concurrent.Prompt cache, measured
--prompt-cache-gib 4,--parallel 1, a 3162-token prompt, 16 tokens out, same prompt three times:d6fb55f2cf55d6fb55f2cf55d6fb55f2cf55Prefill drops 48x and decode does not move (1.8 tok/s either way), which is the expected split: the cache restores the prompt's rows, not the round. The reply's bits are identical cold and resumed, so a restored prefix gives the same answer as one read from the start.
That is the same memory floor as the single-stream section: at 2.0 tok/s the card reads about 44 GB/s of the 240 GB/s it can sustain, so several streams have headroom to share and still only add up to 1.6x. A decode path that reached even a third of the floor would make these tables look very different, which is why the follow-up is the kernels and not this PR.
Not measured: one MLX checkpoint's reply on
mainagainst this branch. It cannot be measured for a ModelOpt checkpoint, sincemainrefuses the format by name and never loads it - which is the point of the PR.