[modular] Remove ambiguity in all calls to parent class methods + fix dependency graph#40456
Merged
Cyrilvallez merged 12 commits intomainfrom Aug 27, 2025
Merged
[modular] Remove ambiguity in all calls to parent class methods + fix dependency graph#40456Cyrilvallez merged 12 commits intomainfrom
Cyrilvallez merged 12 commits intomainfrom
Conversation
|
The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update. |
a5ecc7c to
47e878e
Compare
cyyever
reviewed
Aug 27, 2025
Contributor
|
[For maintainers] Suggested jobs to run (before merge) run-slow: aimv2, aria, colqwen2, d_fine, deepseek_v2, deepseek_v3, deepseek_vl_hybrid, diffllama, doge, dpt, eomt, ernie4_5_moe, evolla, gemma3, gemma3n, glm4v |
Cyrilvallez
commented
Aug 27, 2025
| for node in ast.walk(tree): | ||
| if isinstance(node, (ast.Import, ast.ImportFrom)): | ||
| module = node.module if isinstance(node, ast.ImportFrom) else None | ||
| if module and (".modeling_" in module or "transformers.models" in module): |
Member
Author
There was a problem hiding this comment.
This was not exhaustive enough so some models could be skipped from dependencies if we import simply their image_processor or such
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.
What does this PR do?
A lot of modular files had wrong calls to parent's method (in order to skip unravelling the definition), making then non-pythonic files. This is now fixed, and the converter is much more robust on this.
Here are the new rules to make this process much more pythonic, such that modular files are correct python files:
super), let's call the method from the actual class we would like the method to be usedLlamaMLP, and we want to callnn.Module.__init__(...), no need to re-addnn.Moduleas a new base, as it's already part of the MRO (LlamaMLPis ann.Module, so it's the grand-parent)super()to keep Python's best practices when the class called is one of the direct parents of the generated codeOverall, those rules are much more natural and pythonic, and clear the ambiguity that exists currently.
Also, fix a bug in how we were creating the dependency graphs (some models could be skipped due to non-exhaustive match)