fix: reject swiglu_limit=0.0 - #15
Open
aryagxr wants to merge 1 commit into
Open
Conversation
Signed-off-by: Arya Gopikrishnan <aryagxr@gmail.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
Addresses bugbot on #11: zero
swiglu_limitenables clamping and zeros expert activationsProblem
swiglu_limit=0.0was allowed by the python validation but the CUDA path treats any provided limit as "enable clamping". With a limit of 0, the up projection gets clamped to zero, and as a result expert activations are wiped instead of running normal SwiGLUChanges
swiglu_limitto beNoneor strictly positive in all six fused wrappers inmok/ops.py. Reject whenswiglu_limit <= 0swiglu_limit=0.0rejection case to each matching failure loop intests/test_ops.pyValidation
python3 -m py_compile mok/ops.py tests/test_ops.py— passedgit diff --check— passedswiglu_limit <= 0checks inmok/ops.pyand 6 matching rejection cases intests/test_ops.pyNote
Low Risk
Input validation-only change with no CUDA or numerical path edits; callers passing zero will now fail fast instead of producing wrong activations.
Overview
Tightens
swiglu_limitvalidation on all six fused MoE entry points inmok/ops.py(MXFP8/BF16 forward, recompute, and backward).Noneis still allowed; any numeric value must now be strictly positive (<= 0raisesValueError), replacing the previous rule that allowed zero.This blocks a silent correctness bug: the CUDA path treats a set limit as “enable clamping,” so
swiglu_limit=0.0clamps the up projection to zero and wipes routed expert activations instead of running normal SwiGLU.Tests add a
swiglu_limit: 0.0failure case to each operator’s existing validation loop intests/test_ops.py.Reviewed by Cursor Bugbot for commit a8fd5bc. Bugbot is set up for automated code reviews on this repo. Configure here.