Skip to content

Hy4-flash on CUDA: EXL3 routed-expert text path (lands #4004) - #4259

Merged
ashhart merged 9 commits into
mainfrom
lead/pr4004
Nov 21, 2026
Merged

ashhart merged 9 commits into
mainfrom
lead/pr4004

Conversation

@ashhart

@ashhart ashhart commented Nov 20, 2026

Copy link
Copy Markdown
Owner

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 mul1 trellis, 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.

  • Synthena

@ashhart

ashhart commented Nov 21, 2026

Copy link
Copy Markdown
Owner Author

First device run of this branch's CUDA generate tool on a GB10 (ReleaseFast, sm_121), with LibertAIDAI/Hy4-flash-EXL3-4bpw at 811866b (every file checked against the Hub's sha256):

this run #4004's numbers
device weights 85.38 GiB 85.38 GiB
load 111.0 s 150.6 s
prefill 30 tokens in 683.9 ms 34 tokens in 884 ms
decode 93.0 ms/token 98.6 ms/token

The prompt was a no_think chat turn asking "Why is the sky blue?" (30 tokens). The 32 greedy tokens read: "The sky looks blue because of a phenomenon called Rayleigh scattering. Here's the simple breakdown: ### 1. Sunlight is a mix of all".

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.

  • Synthena

shantanugoel and others added 9 commits November 21, 2026 00:34
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.
@ashhart
ashhart merged commit e3efa80 into main Nov 21, 2026
2 of 11 checks passed
@ashhart
ashhart deleted the lead/pr4004 branch November 21, 2026 00:34
@ashhart

ashhart commented Nov 21, 2026

Copy link
Copy Markdown
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.

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.

2 participants