Repository navigation
fix: guard save_for_backward on grad_bias not bias in fused linear CE forward - #1157
Merged
Merged
Conversation
… forward When input_requires_grad is False, fused_linear_cross_entropy_forward sets grad_bias to None regardless of whether bias is provided. The save_for_backward call was checking `bias is not None` instead of `grad_bias is not None`, causing an AttributeError when bias is provided but grad_bias is None. Fixes linkedin#1156
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 a bug in
LigerFusedLinearCrossEntropyFunction.forwardwherectx.save_for_backwardchecksbias is not Noneinstead ofgrad_bias is not Nonebefore calling.detach().When
input_requires_grad=False,fused_linear_cross_entropy_forwardsetsgrad_bias = Noneregardless of whetherbiasis provided. The stale check then callsNone.detach()and raisesAttributeError.Fixes #1156
Details
One-line fix in
src/liger_kernel/ops/fused_linear_cross_entropy.py:Before:
grad_bias.detach() if bias is not None else None,After:
grad_bias.detach() if grad_bias is not None else None,Testing Done
make testto ensure correctnessmake checkstyleto ensure code stylemake test-convergenceto ensure convergence