Repository navigation
relu^2 keeps a NaN: grouped experts, ck experts and Nemotron's pocket - #1628
Merged
Merged
Conversation
This was referenced Oct 30, 2026
BobClawblaw
force-pushed
the
relu2-nan
branch
from
October 30, 2026 11:52
661d8d8 to
587e10c
Compare
…n NVFP4 block holding one gets a NaN scale (max_nan, not fmaxf)
Owner
|
Thank you @BobClawblaw. This is in TensorFold 1.2.0, released today: https://github.com/ashhart/TensorFold/releases/tag/v1.2.0 It landed with your commits under your own name, so you're listed as a TensorFold contributor, and it's credited to you in the release notes and the changelog. |
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.
What this changes
relu^2 keeps a NaN. Three relu^2 sites used
fmaxf(v, 0), which turns a NaN sum into 0, so a NaN in the experts orthe pocket vanished instead of reaching the output. They now use
v < 0 ? 0 : v:experts.cuh: relu^2 in the grouped experts' up epilogue (MLX affine, ggml, NVFP4 relu^2 forms);ck_experts.cu: relu^2 up, and the NVFP4 quantizer's block maximum (max_nan, so a block holding a NaN gets a NaNe4m3 scale, 0x7F, as the decode path's bf16 rows and separate quantizer already did);
nemotron_ops.cu: the pocket's relu at its two sites.Finite inputs give the same bits. First of five stacked PRs for #1549 (Nemotron 3.5 Transcribe).
Receipt
experts.cuh, 4 inck_experts.cu, 3 innemotron_ops.cu), with thesame register counts; every Qwen and Gemma kernel is identical code.
identical replies on every model:
ck_experts)1.682/1.683 → 1.683/1.678 s; Lightning MLX 3.2k 0.410/0.410 → 0.409/0.410 s, 13k 1.786/1.782 → 1.792/1.789 s.
zig build test,tf-cuda-test checkpointandpocketpass; the full kernel contract is in #.pocket has no published checkpoint to A/B, so the pocket contract (next PR) covers it.
Overlap
atc overlaplists #1445 and #1446 as conflicting, in the shared registration lists (registry.zig,cuda_kernels.zig,kernels.zig,kernel-contract.md,tests/cuda/main.zig); whichever lands second rebases.