Repository navigation
Hy4-flash on CUDA: EXL3 routed-expert text path (lands #4004) - #4259
Merged
Merged
Conversation
This was referenced Nov 20, 2026
Owner
Author
|
First device run of this branch's CUDA generate tool on a GB10 (ReleaseFast, sm_121), with
The prompt was a This is a load-and-run check, not yet the token-for-token one: that needs #4004's exact 34 prompt ids, which we have asked @shantanugoel for on #4004.
|
exl3_weights reads split mul1 experts (trellis/suh/svh/mul1) and rejects affine or mixed markers; moe_exl3_cuda runs them on the shared EXL3 kernels with Hy4's sigmoid router, correction bias, top-16 and scaled combine. bf16_rows gathers 192-byte Engram rows with aligned O_DIRECT reads and a prefetch worker (Linux host tests). mla_weights exposes splitBf16.
tf_hy4_index_groups pools a closed group's four token keys through the FP32 value/gate projections with intra_group_ape, then key_norm. index_cuda caches token keys, pools and rotates closed groups, and scores and recalls with the draft's rotate and recall kernels. Against an FP64 oracle on layer 1 over 2,304 keys: recall of 511 of 575 groups identical on 4/4 rows, scores 6.2e-4 relative L2, draft rollback byte-exact.
hy4_engram mirrors engram.metal's rounding: lookup (optional stock FP8 round trip, per-head RMSNorm) and apply (key/query norms, signed-sqrt gate, per-stream scales), with the reference nn.RMSNorm epsilon (2^-23). On real layer-1 rows: strict BF16 4.9e-3 and stock FP8 4.3e-3 relative L2 vs the torch reference.
cuda_model loads the BF16 trunk and 512 mul1 experts per sparse layer (slab uploads, per-layer page release, TF_HY4_MEM_FLOOR_GIB guard) and runs embedding, four streams, 42 layers, hyper head and LM head on one sequence: causal keys to 2,048, the 512-key window on sliding layers. tf-hy4-cuda-generate prefills and decodes greedily. LibertAIDAI Hy4-flash-EXL3-4bpw on GB10: 85.38 GiB, 34-token prefill 884 ms, 98.6 ms/token; all 32 greedy tokens equal ExLlamaV3's.
openDirect took whatever row count the shard's header declared and rowOffset bounds-checked against it, so a table read for the wrong layer, or one repacked or truncated by another tool, loaded cleanly. The four released tables hold 164,994,380 / 164,999,008 / 165,004,086 / 165,008,942 rows: a wrong shard stays inside the count for almost every lookup and addresses rows silently, which is audible only as a small quality loss. The Metal path already derives the count from the config (engram_rows.zig, weights.zig); this gives the CUDA reader the same rule, as RowCountMismatch at load rather than BadTable mid-forward. The test fails with TestUnexpectedResult without the check (26 pass, 1 fail) and passes with it.
Owner
Author
|
Thank you @shantanugoel. This is merged into main with your commits under your own name, so you're credited as a TensorFold contributor. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Lands #4004 by @shantanugoel: Hy4-flash on CUDA, a text path and a whole-model greedy runner for EXL3 routed-expert checkpoints (routed experts as
mul1trellis, everything else BF16), the pieces that existed only on Metal so far.#4004 was stacked on #3941 (Hy4-flash on Metal) and began with #4003; both are on main now, so this branch is #4004's own eight commits rebased onto today's main, authored by @shantanugoel, with the conflicts against main's Hy4-flash code kept on both sides. The fork does not take maintainer pushes, hence this branch. #4004 closes when this lands.
The author's GB10 receipts are in #4004. We have not yet run the whole model on our side: no GB10 of ours holds an EXL3 Hy4-flash checkpoint yet.