add fp64 gradcheck for geglu activation and gate+up paths - #31
Open
tejasexpress wants to merge 1 commit into
Open
add fp64 gradcheck for geglu activation and gate+up paths #31tejasexpress wants to merge 1 commit into
tejasexpress wants to merge 1 commit into
Conversation
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.
dev doesn't exist on the repo right now, only main, so this targets main.
What this changes
fixes #11 .. adds
torch.autograd.gradcheckat fp64 for both geglu paths :=ForgeGEGLUFunction(activation-only, separate gate/up) andForgePackedGEGLUFunction(gate+up fused). runs through the Triton kernel, similar approach as RoPE's fp64 gradcheck. small shapes (2,3,8) and both approximate="tanh" and "none".Numbers
n/a, no math changed
Correctness
uv run ruff check .pytestsuites passAnything a reviewer should know
using preserve_inputs=True in both new tests. With the default False,
gradcheck fails with "backward is not reentrant" becaus geglu_backward writes
the gradient into the same storage it saved for backward (dgate = gate
when preserve_inputs=False), so calling .backward() twice on the same
graph reads back corrupted values on the second call. that's the
default geglu() uses, so retain_graph=True + two backward calls would
silently give wrong gradients. didn't do anything abt it here, out of scope for
#11 , can open a separate issue if wanted.
tested on Colab Tesla T4