fix: restore cross-entropy state in revert_liger_kernel helpers - #1389
Open
atirna wants to merge 2 commits into
Open
fix: restore cross-entropy state in revert_liger_kernel helpers#1389atirna wants to merge 2 commits into
atirna wants to merge 2 commits into
Conversation
Add revert_liger_cross_entropy_patches() to undo global nn.functional.cross_entropy and module-level CrossEntropyLoss swaps after convergence-test reverts. Fixes linkedin#542 Co-authored-by: Cursor <[email protected]>
Assert nn.CrossEntropyLoss restoration and use the saved torch baseline so the test stays valid even if earlier cases left F.cross_entropy patched. Co-authored-by: Cursor <[email protected]>
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
revert_liger_kernel_to_*now clears Liger cross-entropy monkey patches so convergence tests don't compare two Liger-patched baselines after the first case.Fixes #542
Details
revert_liger_cross_entropy_patches()to restoretorch.nn.functional.cross_entropy, reloadtorch.nn(coversnn.CrossEntropyLossswaps), and drop module-levelCrossEntropyLossbindings when they point atLigerCrossEntropyLossrevert_liger_kernel_to_*helper intest/utils.pytest_revert_liger_cross_entropy_patchesfor apply → revert → compare on both patch pathsTesting Done
ruff check/ruff formatonmonkey_patch.py,test/utils.py,test/transformers/test_monkey_patch.py91b6aba(glm-5.3)make test(needs CUDA/triton; leaving to CI)make test-convergence(needs CUDA; leaving to CI)Made with Cursor