Fix NaN in all 3 gated deltanet Helion references and submission#131
Merged
S1ro1 merged 2 commits intogpu-mode:mainfrom Mar 14, 2026
Merged
Fix NaN in all 3 gated deltanet Helion references and submission#131S1ro1 merged 2 commits intogpu-mode:mainfrom
S1ro1 merged 2 commits intogpu-mode:mainfrom
Conversation
The reference kernel computed exp(g_i - g_j) before applying the causal mask. When g values are very negative (cumulative sums of negative increments), the upper-triangle differences g_i - g_j overflow exp() to inf, and inf * 0 (causal mask) produces NaN. Fix: zero out g_diff in the upper triangle before calling exp(), so we never compute exp(large_positive). Apply the same fix in the submission kernel which had a similar issue with exp(-g) overflowing. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…t kernels Zero out g_diff outside the strict lower triangle before calling exp(), preventing inf * 0 = NaN when upper-triangle g differences overflow. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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.
Summary
exp(g_diff)overflow causinginf * 0 = NaNin all 3 gated deltanet Helion kernelsref_kernelinchunk_fwd_o:exp(g_i - g_j)was computed before applying the causal mask — zero outg_diffin the upper triangle beforeexp()_chunk_scaled_dot_kkt_fwd_eagerin all 3 kernels (chunk_fwd_o,chunk_fwd_h,recompute_w_u):exp(g_diff) * strict_loweroverflows in the upper triangle — zero outg_diffoutside the strict lower triangle beforeexp()submission.pyforchunk_fwd_o:exp(-g)overflows whengis very negative — restructure to computeexp(g_i - g_j)inline insteadRoot cause:
gis a cumulative sum of negative increments, so values get very negative. Differencesg_i - g_jin the upper triangle can be large positive, overflowingexp()toinf. Multiplyinginf * 0(from the mask) producesNaN.Test plan
torch.allclose(out, ref, rtol=1e-2, atol=1e-2)for all test shapes🤖 Generated with Claude Code