Repository navigation
hy4_flash: FP8 Engram CUDA kernels, contract gates, controls, and 5-SM limits (slice 2b of #4795) - #5087
hy4_flash: FP8 Engram CUDA kernels, contract gates, controls, and 5-SM limits (slice 2b of #4795)#5087GrgaPalcic wants to merge 12 commits into
Conversation
|
Thank you, @GrgaPalcic. The finite E4M3FN widening and packed-row F32 scale step match the existing decoder. The legacy Engram sources and default serving reach are unchanged, the production and control entries are separate, and this head merges cleanly. Ready for focused synthetic GB10 comparisons; no model checkpoint is needed for those. The reported four-kernel/eleven-control pass and fifteen launch records are retained. The FP64 bounds do not establish exact output bytes for the full RMS/gate pipeline, so those comparisons against the intended FP32 order and rounding seams remain before target qualification, including both gate outputs and masked rows. Whole-model qualification remains in the serving slice.
|
|
Pushed
|
|
Thank you, @GrgaPalcic. The shared warp helper keeps XOR 16,8,4,2,1, the serial eight-warp combine, both barriers and the separate BF16 control. The decoder and other operator bodies remain unchanged, and the merge is clean. The new-head four/eleven pass and fifteen records are retained. This remains suitable for focused synthetic GB10 comparisons. Source order is preserved, but no old/new output-byte comparison was supplied. The earlier exact RMS/gate checks still stand, including both outputs, masks and tails against the intended FP32 order and rounding seams. The bounded contract pass does not replace those comparisons; whole-model qualification stays with the later serving slice.
|
|
Thank you for moving the production warp reduction to the shared helper and updating the serving pin. The helper keeps the same reduction order, barriers and separate BF16 control path. The branch merges cleanly, and the retained four-kernel/eleven-control and fifteen-record evidence is credited. The remaining qualification is exact output comparison. The current FP64 bounds and planted controls do not prove the intended FP32 operation order and rounding seams for the complete pipeline. On the focused synthetic cell, please compare the production operators against the intended serial implementation byte for byte: embed decode, FP32 scale, RMSNorm and BF16 output; rank-0 FP32 bias; and both This is suitable for A/B rather than a request for another kernel rewrite. No model checkpoint applies to this kernel-only slice; whole-model token equality remains with the later serving work.
|
|
Updated
Verification receipts
|
…s for hy4_engram_fp8
80a532e to
870f7df
Compare
|
Thank you, @GrgaPalcic. The new serial reference is a substantial improvement. The FP32 traversal, reduction tree, RMS sequence, gate arithmetic and two BF16 rounding points match the production formulas. Poisoning every compared buffer and checking both gate outputs in one launch are also confirmed. The shared reduction keeps its order and cleanup, and this slice still has no serving-model caller. A few exactness and test-safety items remain before this can land:
Current main also has conflicts in No production arithmetic rewrite is indicated by these findings. The retained GB10 contract results are credited, but the new exact checks above remain unrun here.
|
…r control, old-reduce check, directed fixtures, and hex diagnostics
|
Updated
Live GB10 (
|
|
Thank you @GrgaPalcic. The device-side serial oracle, exact bias-NaN comparison, wrong-order control, freshly poisoned dual-output repeats, mask modes, directed fixtures, hexadecimal diagnostics, and old/local reduction equivalence are all present. The temporary-buffer drains also precede every relevant deferred free, and the final formatting commit brings the largest file under 600 lines without changing the arithmetic. The current registrations and registry pin are consistent. One test-oracle issue remains. Gate 4 does not invoke The wrong-order control already demonstrates the comparator's sensitivity on shapes. No production kernel rewrite is indicated by this remaining qualification gap, and no serving checkpoint run applies.
|
|
Updated Verified locally (
|
|
Thank you, @GrgaPalcic. The device-side serial oracle, exact bias-NaN checks, wrong-order control, poisoned dual-output repeats, masks, directed fixtures, cleanup drains and hexadecimal diagnostics are present. The last change also reaches the new stress oracle. The global Gate 4 call introduces a regression in existing kernels. CK and VIT hooks ignore the gate argument and unconditionally require a non-finite output. That assertion belongs to Gate 1's planted fixture. Gate 4 uses finite stress inputs, so otherwise-correct CK and VIT kernels now fail after valid numerical and replacement-byte checks. Please make the sums callback an explicit per-kernel opt-in, use the permitted family-local stress invocation, or make every affected hook gate-aware before retaining the global call. Then rerun the focused contract suite and affected existing coverage. No production arithmetic rewrite is indicated, and no model-checkpoint run applies.
|
…oracle in hy4_engram_fp8
|
Thanks @GrgaPalcic. Our re-check of We don't have this model's checkpoint on our machines, so this lands on your receipts. For this exact head, please post:
The branch conflicts with current main; we will rebase it for you, so there is nothing to do there.
|
|
Updated
Verified locally (
|
What this changes
Adds the W8A16 FP8 Engram CUDA kernels, launchers, contract gates, planted controls, and 5-SM launch limits for
tencent/Hy4-flash-FP8insidezig/src/families/hy4_flash/andzig/kernels/cuda/hy4_flash/(distincthy4_engram_fp8fatbin, zero collision withhy4_engram):zig/kernels/cuda/hy4_flash/engram_fp8.cuh+engram_fp8.cu: production__launch_bounds__(256)kernels (hy4_engram_fp8_embedfor 100-byte E4M3FN+FP32 row decode + per-head RMSNorm into BF16,hy4_engram_fp8_biasfor rank-0 BF16 bias into FP32 partials, andhy4_engram_fp8_gatefor post-allreduce unified RMSNorm, 4-stream signed-sqrt sigmoid gate, scales, mask, and residual add). Zero planted control symbols in the production fatbin.zig/kernels/cuda/contract_hy4_engram_fp8_controls.cuh(included fromcontract_controls_set.cu): 11 planted control kernels infatbin_contract_controlscovering non-finite drops, repeat drift, tail skips, and reduced-precision sums (fp16on embed,bf16on gate).zig/src/families/hy4_flash/engram_fp8_cuda.zig: host-compilable CUDA launchers (Ops,GateWeights,launchEmbed,launchBias,launchGate), registered inzig/src/families/hy4_flash/host_tests.zigandzig/build/cuda.zig.zig/tests/cuda/contract_hy4_engram_fp8.zig(registered incontract_family_sets.zigandcontract_limits.zig): full 5-gate CUDA contract coverage (engram_embed,engram_bias,engram_gate engram_out,engram_gate streams_out, plus all 11 planted controls).zig/src/core/contract/hy4_engram_fp8_records.zig(registered inregistry_joins.zig):nvcc 13.05-SM (sm_80, 86, 89, 120, 121) register/shared-memory/bound records (0spills on all 5 SMs).No served path, model load, or default is changed in this slice. Remaining work for #4795: paged sparse indexer, paged absorbed MLA + fused iHC/HC, router/rows/DFly2 glue CUDA kernel slices, served W8A16
TP=2/TP=4+DFly2CUDA Graphs with serial token-equality receipts, and CUDA SigLIP2--vision+ 3D M-RoPE.main(12535c348, after hy4_flash: host W8A16 FP8 weight map, TP=1/2/4 partition, and Engram FP8 row format (slice 1 of #4795) #4827, hy4_flash: W8A16 CUDA weight packing for qmmf projections and TP=1/2/4 FP8 experts (slice 2a of #4795) #4895, and hy4_flash: host vision config, patchify, bilinear taps, and 3D M-RoPE layout (slice 4a of #4795) #5022 merged); adds 1 commit (8dcfa587a)atc overlap --json: shared CUDA kernel/contract registration files (cuda_kernels.zig,kernels.zig,cuda.zig,contract_controls_set.cu,contract_limits.zig,contract_family_sets.zig,registry_joins.zig) have expected list-append overlaps with unrelated open CUDA kernel PRs; zero overlap on anyhy4_flashfile.Checks on this head
8dcfa587a4f5628084d472ec380b230bd26201d4(base12535c348897e1fef942310bbf930ccbb3b4d864)python3 tools/zig/lean_check.py, on the base and on this head:164on base (12535c348, inherited),164on head (8dcfa587a),0new (python3 tools/pr_check.py --base origin/main:0 error(s))0.17.0,-Dfixed-cpu, Linux x86_64):zig build -Dfixed-cpu test-hy4-flash-host --summary all:49pass,0fail,0skip (exit0)zig build -Dfixed-cpu test-kernel-contract --summary all:328pass,0fail,0skip (includingHy4 FP8 Engram CUDA: every launch is in the live registry and fits every SM; exit0)zig build -Dfixed-cpu compile-cuda-tests: exit0zig fmt --check build.zig zig && git diff --check: exit0sm_121, CUDA13.0.88,nvcc 13.0, Zig0.17.0,-Dsm=80,86,89,120,121):zig build fatbins kernel-contract-fatbins -Dnvcc=/usr/local/cuda/bin/nvcc -Dsm=80,86,89,120,121: exit0(0bytes stack/spill on all 3 kernels across all 5 SMs)./zig-out/bin/tf-cuda-test kernel-contract-limits zig-out/fatbin: all 15hy4_engram_fp85-SM records (embed,bias,gate×sm_80,86,89,120,121) reportedPASS ... (record current),0hy4_engram_fp8problems./zig-out/bin/tf-cuda-test kernel-contract hy4_engram_fp8(exit0):(filtered) SUMMARY 4 kernels: 4 pass gates 1-4, 0 fail, 0 known findings; 11 controls: 11 red as planted, 0 missed; 0 limit problems; gates 90 ms, limits 0 ms./zig-out/bin/tf-cuda-test kernel-contract(exit1due to pre-existing unrelatedmuse/ricursive/exl3_expertsnvcc 13.0limit records and 2 unrelated failures;0failures,0missed controls, and0limit problems inhy4_engram_fp8):SUMMARY 908 kernels: 906 pass gates 1-4, 2 fail, 12 known findings; 597 controls: 597 red as planted, 0 missed; 292 limit problems; gates 5071123 ms, limits 772270 msReceipt
n/a — kernel-only CUDA slice with full 5-gate device contract and 5-SM launch-limit qualification; does not reach serving or change any model load/default.
sm_121, CUDA13.0.88) device contract & 5-SM fatbin limits (sm_80,86,89,120,121); macOS/Windows host builds covered by CI12535c348, head8dcfa587a, Zig0.17.0, CUDA13.0.88(nvcc 13.0), NVIDIA GB10 (sm_121, Linux aarch64); targets officialtencent/Hy4-flash-FP8@003107fa248f5892064ab1c43af0a7003dd68c9bsm_121) CUDA contract + 5-SM (80,86,89,120,121) fatbin limit checks; did not run physical SM 80/86/89/120 GPUs (compiled and checked againstnvcc 13.0limits)tools/bench_concurrent.py --alone --serialortoken_shaagainst"draft": false: n/a (kernel-only slice; float64 contract exactness, non-finite class preservation, 5-run byte-identical repeatability, shape bounds, FP32 sum discrimination, and 11/11 red planted controls verified live onsm_121)tools/bench_openai.py: n/a (kernel-only slice)Checklist