-
Notifications
You must be signed in to change notification settings - Fork 31.1k
[modular] Remove ambiguity in all calls to parent class methods + fix dependency graph #40456
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
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
|
[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 |
| 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): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was not exhaustive enough so some models could be skipped from dependencies if we import simply their image_processor or such
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)