Repository navigation
hy4_flash: NVFP4 routed experts on CUDA at one rank (slice 2 of #3801) - #4934
Conversation
|
Thanks @atakann. This slice merges cleanly and leaves existing serving paths untouched. The wrapper keeps the stored codes and scales and uses the existing BF16/FP32 grouped kernels without TF32. The synthetic test checks FP64 bounds, but it never compares bytes across row counts; the shared report still says those bits are equal. Please add exact comparisons for gate-up and down across all listed widths, retaining the clamp checks, and show that the new comparison rejects a planted mismatch. The checkpoint test already has the separate 8/64-row comparisons, and your three layer receipts are useful.
|
|
Thanks @ashhart, you're right: the report claimed equal bits it never compared. In While doing it I found a second gap: the output buffers kept the previous run's values, so a run that left rows unwritten would still have passed. Both buffers are now filled with 0xFF (NaN) before every run, in the checkpoint test's 8 and 64-row runs too. On GB10 the synthetic test and layers 1, 2 and 40 pass again; the description has the details. |
|
Thanks @atakann. The synthetic test now compares both output buffers exactly across all listed row counts, retains the clamp and float64 checks, and detects the planted mismatch. Poisoning the buffers also closes the stale-output gap. Your passes at this head cover the synthetic case and all three checkpoint layers. The runtime wrapper is unchanged, existing serving paths remain untouched, and the branch merges cleanly. This slice is ready to land through the normal final-tree checks.
|
|
I checked this slice together with the other Hy4 packing PR. On zig build test-hy4-flash-host compile-cuda-tests -Dtarget=aarch64-linux-gnu -Dfixed-cpu -j2 --summary allThe combined tree passed all 31 Hy4 host tests on the M5 Max, and the CUDA test runner cross-compiled for ARM64 Linux in the same 18-step build. This checks build compatibility of the FP8 and NVFP4 slices. The combined device run remains unverified. Igor Lessio - AIFLOW LABS |
…rt#3801) moe_nvfp4_cuda.zig packs the build's ModelOpt per-expert tensors (gate and up [intermediate, latent], down [latent, intermediate]) for core's grouped NVFP4 kernels (BF16 activations, W4A16) and runs them on grouped.zig's plan with Hy4's SwiGLU clamp; the router, its top-k and the weighted sum are the EXL3 path's. A tensor stored wider than the layer is refused, never sliced. tf-cuda-test hy4-nvfp4-experts: 8 experts, 4 picks a row, 1 to 300 rows (the one-block and the wide plans), every pair's gate-up and fp32 down FP64-bounded with the clamp crossed; a wider stored gate refused.
…t hy4-nvfp4-experts-ckpt) One layer's 512 experts of atakans/Hy4-flash-NVFP4 load and pack; 64 rows of 16 picks run, the first 8 rows' 128 pairs are FP64-bounded and equal to the same rows in an 8-row run. Layer 1 passes on GB10.
…the widest run, poison the outputs before each run, and a planted flip shows the comparison finds it The synthetic test runs 300 rows first; the gate-up and fp32 down of the 1, 5, 64, 255 and 256-row runs must equal the same rows of that run byte for byte, with the FP64 bounds and the clamp check kept. Before every run the gate-up and down buffers are filled with 0xFF (NaN), so a row a run leaves unwritten fails instead of showing the last run's values; the checkpoint test's 8 and 64-row runs get the same. A planted control flips one bit in a 5-row copy of the gate-up and checks that the comparison reports that byte. On GB10: the synthetic test and layers 1, 2 and 40 pass.
713e7d5 to
347863d
Compare
|
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. |
What this changes
Slice 2 of #3801, on top of #4110 (merged): the build's NVFP4 routed experts run on CUDA at one rank. No serving path yet; the loader and the engine are the next slices.
moe_nvfp4_cuda.zigpacks the ModelOpt per-expert tensors of the build (gate and up[intermediate, latent], down[latent, intermediate]) for core's grouped NVFP4 kernels (BF16 activations, W4A16) and runs them ongrouped.zig's plan with Hy4's SwiGLU clamp. The router, its top-k and the weighted sum are the EXL3 path's. A tensor stored wider than the layer is refused, never sliced.tf-cuda-test hy4-nvfp4-experts: 8 experts, 4 picks a row, 1 to 300 rows (the one-block and the wide plans); every pair's gate-up and fp32 down is FP64-bounded with the clamp crossed, and a wider stored gate is refused. The 300-row run goes first; the gate-up and down bytes of the 1, 5, 64, 255 and 256-row runs must equal the same rows of it exactly. Both output buffers are filled with 0xFF (NaN) before every run, so a row a run leaves unwritten fails instead of showing the last run's values. A planted control flips one bit in a 5-row copy of the gate-up and checks that the comparison reports that byte.tf-cuda-test hy4-nvfp4-experts-ckpt <ckpt> <layer>: one layer's 512 experts of atakans/Hy4-flash-NVFP4 load and pack; 64 rows of 16 picks run, and the first 8 rows' 128 pairs are FP64-bounded and equal to the same rows in an 8-row run (outputs poisoned before both runs).Other families are unchanged: the only shared lines are the runner's registrations in
zig/build/cuda.zig,zig/tests/cuda/main.zigandmain_usage.zig.Checks
On one GB10 (sm_121, Zig 0.17.0, nvcc 13.3, ReleaseSafe), at
713e7d5a9:hy4-nvfp4-expertshy4-nvfp4-experts-ckpt, layer 1hy4-nvfp4-experts-ckpt, layer 2hy4-nvfp4-experts-ckpt, layer 40On the real weights the clamp is not crossed (0 of 196,608 gate-up columns), so the synthetic test is the one that covers it.
zig fmt --checkon the three files;tools/zig/lean_check.pyagainst main: 165 problems, 165 on the base, 0 new.atc overlap: the shared files are the runner registration lines above; the report is incomplete (pull request and time limits), and the conflicts it lists are older pull requests' with main.