Skip to content

hy4_flash: the NVFP4 build's quantization block and weight map, with recipe and receipts (slice 1 of #3801) - #4110

Merged
ashhart merged 4 commits into
ashhart:mainfrom
atakann:hy4-flash-host
Nov 24, 2026
Merged

ashhart merged 4 commits into
ashhart:mainfrom
atakann:hy4-flash-host

Conversation

@atakann

@atakann atakann commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

What this changes

Slice 1 of #3801, reworked onto main's hy4_flash family now that #3941 and #4259 landed it. This branch no longer carries its own config, Engram or template code; it adds only what the ModelOpt NVFP4 build needs on the host, next to main's affine and EXL3 maps:

  • nvfp4_weights.zig: checkQuant reads hf_quant_config.json and takes ModelOpt NVFP4 in groups of 16 with no KV cache quantization; anything else is UnsupportedHy4Quant. check names every text and drafter tensor of the build with its stored type and shape: NVFP4 routed experts (one tensor per expert), shared experts and dense MLP; e4m3 Engram rows with one BF16 scale a row; BF16 elsewhere, with the release's f32 tensors (the head, hc_*, the indexer's projections and APE, the sinks).
  • nvfp4_weights_test.zig with nvfp4_header.txt: 344 entries of atakans/Hy4-flash-NVFP4's own safetensors headers (30f201ac), every kind of tensor at layers 0, 1, 2 and 41, experts 0 and 511 of two layers, the whole drafter. The map must ask for each of them as stored, and for 253,728 tensors in all, the build's count outside the vision tower's blocks. A changed tensor is refused by name; FP8, group 32, an FP8 KV cache and a misspelled block are refused.
  • As asked in Hy4-flash on two DGX Sparks: a native CUDA family #3801 (answer 2), the build recipe and its quality receipts: tools/hy4_flash/nvfp4.py and engram_fp8.py rebuild the checkpoint from Tencent's BF16 release with ModelOpt 0.48.0, and docs/receipts/hy4-flash-nvfp4/ holds the steps and these scores (two GB10s, tensor parallel 2, thinking off, temperature 0):
Engine GPQA Diamond (198) IFEval (541)
TensorFold prototype (atakann/TensorFold hy4-flash) 72.2 % 84.7 %
vLLM with vllm-project/vllm#68387 72.7 % 83.5 %

No kernels and no serving: the loader does not read NVFP4 yet, so other families' tokens and main's Hy4 paths are unchanged. The next slice is the NVFP4 routed experts on CUDA at one rank, against a tiny checkpoint.

Checks

The earlier shape of this branch is kept at atakann/TensorFold:hy4-flash-host-v1.

@AIFlowML

Copy link
Copy Markdown
Contributor

On M5 Max with Zig 0.17.0, a clean trial merge of da66ba6d into 124052c97 passed all 23 tests with zig build test-hy4-flash-host -Dcpu=apple_m1 -j5 --summary all.

For the #3941 overlap, the trial merge of the two heads conflicts in config.zig and engram.zig. There is also a build registration collision: both modules register test-hy4-flash-host, and even zig build --help panics. Renaming the incoming target to test-hy4-flash-nvfp4-host in scratch let both targets appear in --help. The two source conflicts still need to be resolved.

For the Engram rebase, I took this PR's compressed-token fixture to #3941's current 523acfc3 and checked all 72 layer/position cases through its Layer.hashNormalized. All rows matched after adding the per-head offsets to the expected IDs, and its host target passed 17/17 with that cross-check. That gives the two PRs a shared set of hash cases to keep when the Engram code is reconciled.

Igor Lessio - AIFLOW LABS

@atakann

atakann commented Nov 20, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for the trial merge and the cross-check. I renamed the step to test-hy4-flash-nvfp4-host (4272307), so both can register. Good to know the Engram hash cases agree with #3941's once the per-head offsets are added; I'll keep them as the shared set when the two packages meet.

@AIFlowML

Copy link
Copy Markdown
Contributor

Thanks for the rename. With #3941 merged at 767d3d75), I verified that trial-merging 4272307letszig build --helplist bothtest-hy4-flash-nvfp4-hostandtest-hy4-flash-host. The exact NVFP4 head passed 23/23 tests. The only remaining trial-merge conflicts are the two overlapping source files, config.zigandengram.zig`.

I reran the shared Engram fixture against the merged Metal code. All 72 layer/position cases still match after accounting for the per-head offsets, and the Metal host target with the added fixture passed 17/17.

Igor Lessio - AIFLOW LABS

@atakann

atakann commented Nov 21, 2026

Copy link
Copy Markdown
Contributor Author

@ashhart, #3941 and #4259 put Hy4-flash on main, so this branch now conflicts with main's family in config.zig and engram.zig. Before I rework it, which shape do you want? My proposal: drop this package's own config and Engram, and bring only the NVFP4 build onto main's family: the ModelOpt NVFP4 routed experts through core src/cuda/experts.zig, the weight map for that layout, and the GPQA Diamond and IFEval receipts. I can run the whole model on two GB10s at TP=2 with the NVFP4 checkpoint.

@atakann atakann changed the title hy4_flash: host-only family package for the NVFP4 build (slice 1 of #3801) hy4_flash: the NVFP4 build's quantization block and weight map, with recipe and receipts (slice 1 of #3801) Nov 22, 2026
@atakann

atakann commented Nov 22, 2026

Copy link
Copy Markdown
Contributor Author

@ashhart, slice 2 is ready on top of this branch: the build's NVFP4 routed experts on CUDA at one rank, packed for core's grouped NVFP4 kernels, with tf-cuda-test hy4-nvfp4-experts passing on GB10 (every pair FP64-bounded under Hy4's SwiGLU clamp). I'll open it as its own pull request once this one lands.

@atakann

atakann commented Nov 23, 2026

Copy link
Copy Markdown
Contributor Author

@ashhart, a short ping on this one. CI is green on 22d8e6840 and the branch merges cleanly into main. Slice 2 (the build's NVFP4 routed experts on CUDA at one rank, tested on GB10) is ready and waits for this slice to land.

@ashhart

ashhart commented Nov 24, 2026

Copy link
Copy Markdown
Owner

Thank you, @atakann, and I'm sorry for the change of course: we asked for this build in #3801, and you delivered it with a full recipe and receipts.

Since then we've tightened TensorFold's rule. We serve a checkpoint only in the precision its publisher released, with every output bit matching our serial reference, and we no longer take post-training conversions, even behind a switch. Your NVFP4 build is converted from Tencent's BF16 release (the recipe's own report shows about 9.5% expert weight error), so we won't add a map or recipe for it to the repo.

Hy4-flash itself is very welcome. Main already has a host map for Tencent's official FP8 release, and the remaining slices from #3801 (the CUDA family, plain decode first, then DFly) would be great on that build. The GPQA Diamond and IFEval receipts were careful work, and your later slices can reuse the same approach.

  • Synthena

@ashhart ashhart closed this Nov 24, 2026
@atakann

atakann commented Nov 24, 2026

Copy link
Copy Markdown
Contributor Author

Thanks @ashhart, understood. The official FP8 release is about 220 GB, which does not fit my two GB10s with room to run, so I can't build and test the CUDA slices on it. The NVFP4 build stays available on Hugging Face and in vLLM (#68387) for anyone who wants it on two Sparks.

@ashhart ashhart reopened this Nov 24, 2026
@ashhart

ashhart commented Nov 24, 2026

Copy link
Copy Markdown
Owner

@atakann, I owe you an apology: I closed this too quickly and on the wrong reading of our rule.

TensorFold's exactness rule is about our own code: whatever checkpoint is loaded, we reproduce it bit for bit and never add rounding or tolerances of our own. Which build someone chooses to serve, whether the publisher's FP8, your NVFP4 build or another quantization, is their choice, and main already loads several community builds. Your PR only reads your NVFP4 build exactly as stored, so it fits that rule. I've reopened it.

From our review: this slice, which adds no serving path yet (the typed weight map, the sampled header test, the recipe and the quality notes) is ready to land once it's combined with current main, which we'll do on our side. The quality scores describe the build itself; they aren't token-equality evidence for later runtime slices, which will each need their own exact checks. Sorry again for the back and forth.

  • Synthena

@atakann

atakann commented Nov 24, 2026

Copy link
Copy Markdown
Contributor Author

Thanks @ashhart, no problem, and thanks for reopening. Slice 2 (the NVFP4 routed experts on CUDA at one rank) is ready on top of this branch; I'll open it once this one lands, with its own token-equality checks on GB10.

ashhart and others added 4 commits November 24, 2026 18:12
…its recipe and quality receipts (slice 1 of ashhart#3801)

nvfp4_weights.zig reads hf_quant_config.json (ModelOpt NVFP4, groups of 16, no KV cache quantization; anything
else is UnsupportedHy4Quant) and names every text and drafter tensor of the build with its stored type and shape:
NVFP4 routed experts, shared experts and dense MLP, e4m3 Engram rows with a BF16 scale a row, the rest as Tencent
released it. The host test checks the map against 344 entries of atakans/Hy4-flash-NVFP4's own safetensors headers
and the full count of 253,728 tensors outside the vision tower's blocks.

tools/hy4_flash/nvfp4.py and engram_fp8.py rebuild the checkpoint; docs/receipts/hy4-flash-nvfp4/ holds the build
steps and GPQA Diamond and IFEval on two GB10s.
@ashhart
ashhart merged commit 9a38b1f into ashhart:main Nov 24, 2026
@ashhart

ashhart commented Nov 24, 2026

Copy link
Copy Markdown
Owner

Thank you @atakann. This is merged into main with your commits under your own name, so you're listed as a TensorFold contributor. It ships in the next release, credited to you in the changelog and the release notes.

@ashhart

ashhart commented Nov 24, 2026

Copy link
Copy Markdown
Owner

Merged. Thank you, @atakann, for the weight map, the sampled header test and the build recipe, and for your patience with my back and forth earlier today. The CUDA family slices from #3801 are welcome next.

  • Synthena

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants