Repository navigation
[Fix] Keep momentum delta rule chunk masks stable for small mu - #1583
Open
arcusbuilds wants to merge 1 commit into
Open
arcusbuilds wants to merge 1 commit into
arcusbuilds wants to merge 1 commit into
Conversation
Signed-off-by: arcusbuilds <212402043+arcusbuilds@users.noreply.github.com>
zhiyuan1i
approved these changes
Oct 25, 2026
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
Fixes #1578. Chunk-mode MomentumDeltaNet drifted from the recurrent definition once μ ≲ 0.8 (error 0.97 at μ = 0.5, NaN at the μ = e^-2 clamp): the chunk reference built its in-chunk mask by subtracting two cumulative sums, which cancel in fp32. It now builds the mask from within-chunk decay matrices, so every exponent is ≤ 0 and nothing is subtracted. Only the PyTorch reference changes;
chunk_momentum_delta_ruleruns autograd through it, so training forward and backward are both fixed.Test plan
test_full_momentum_chunk_ref_decaying_gates(μ = 0.8, the 0.135 clamp, per-token gates; checks o, final S/M and all input grads againstrecurrent_momentum_delta_rule_ref): fails 3/3 on main, passes here.tests/ops/test_momentum_delta.py: 18/18 pass, plain and withFLA_CI_ENV=1.find_dependent_tests.py:test_gdn2.pystill running locally;test_dplr_tilelang.pynot run locally (tilelang not installed). Neither imports the momentum ops.Benchmark / NCU
chunk_momentum_delta_rulefwd+bwd, B2 T2048 H4 D64 bf16, chunk 64, same GPU, 3 alternating rounds: main 132.6 / 136.7 / 134.5 ms, this PR 133.1 / 139.9 / 131.0 ms. Neutral. No varlen run (the op doesn't supportcu_seqlens).Breaking changes
None. Outputs change only where the old path was wrong. The
β + 1e-6offset is dropped, so β is used exactly, as in the recurrent reference.Checklist