Fix incorrect module name when monkey_patch applied to instantiated model#629
Merged
vaibhavjindal merged 1 commit intomainfrom Mar 26, 2025
Merged
Fix incorrect module name when monkey_patch applied to instantiated model#629vaibhavjindal merged 1 commit intomainfrom
vaibhavjindal merged 1 commit intomainfrom
Conversation
shivam15s
approved these changes
Mar 26, 2025
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.
Fix incorrect module name when monkey_patch applied to instantiated model.
Summary
Fixes: #625.
This PR sets the
module.__class__.__name__correctly which allows theexprto correctly show the names of the liger modules.Results
Upon running the code as mentioned here, here is the output after this change:
Note
This output is not exactly equal to what you will get if you apply monkey patch before instantiating the model. For example, consider the following code:
This code generates the following output:
Notice that the mlp layer is a bit different in this case as compared to when monkey-patch was done on the instantiated model. Here, the mlp layer does not contain the
(act_fn): SiLU()in the output. This is a known limitation for this approach as we are just changing the__class__.__name__and not the internal working of the__expr__method.Testing Done
pre merge tests
make testto ensure correctnessmake checkstyleto ensure code stylemake test-convergenceto ensure convergence