-
Notifications
You must be signed in to change notification settings - Fork 25.7k
Allow to register custom passes both before and after fusion. #33261
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
It was requested in #33114. [ghstack-poisoned]
💊 CircleCI build failures summary and remediationsAs of commit 07e5925: None of the build failures appear to be your fault.
Detailed failure analysisOne may explore the probable reasons each build failed interactively on the Dr. CI website. ❄️ 1 failure recognized as flakyThe following build failures have been detected as flaky and may not be your fault:
|
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.
Code looks good. Before we go forward this I would like to figure out if we even need a getCustomPostFusionPasses run. The original justification was This is done last to give internal optimization passes priority. Do we have an actual user who would want to do this (or an idea of such a user)? If we can avoid bifurcating the system, we should.
|
Thanks for taking a look! I'm now also thinking of moving pre-fusion passes closer to the fusion - probably right before it. That would allow us to use this mechanism for registering non-standard fusers if we need it. I'll check with the issue author if that would work for them. @bwasti, do you remember the motivation to move custom passes after the fusion? |
|
From an offline discussion with @bwasti: the reason of the move was that we had passes that needed to be run after BMM/QuantFusion/etc. IMHO it seems a bit arbitrary that we have these two places for registering a pass, and probably in future we might want to add a pass at some other location - at that point I think we would need a more flexible mechanism for specifying when to run the pass. But for now I think having these two places should be good enough - that supports the users that we know about, and it doesn't require too much complexity in the code. @eellison, @bwasti, does it sound reasonable? |
|
One suggestion I can make here is to make the registration take the pass and the priority. Then run the passes based on the priorities. You can give builtin passes large enough priority gaps, e.g., |
…on." It was requested in #33114. [ghstack-poisoned]
| RegisterPostFusionPass(Pass p); | ||
| }; | ||
|
|
||
| using RegisterPass = RegisterPostFusionPass; |
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.
I know we have like a total of 5 (five) users of this API but I wonder if it would be better to have a compiler error than a user error as we had previously.
To enumerate, we could:
RegisterPass = RegisterPostFusionPassRegisterPass = RegisterPreFusionPass- Either of the above two, and add a deprecation message to
RegisterPass - Not set an alias for
RegisterPass, so that users get a compile time error.
Any thoughts here ? It doesn't matter that much, especially if this is a temporary pass manager solution (although I wouldn't count on it being temporary).
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.
I don't think there is a need to compile error on this, since we can preserve the existing behavior exactly. Adding a deprecate warning is also a bit sketchy as we don't have any specific plans to actually deprecate it.
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.
What we did last time is silently change semantics. I think compile time errors are generally preferable.
|
@ZolotukhinM merged this pull request in e1a8958. |
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.
There are many things happening between the pre- and post- phases in here, so maybe we shouldn't say that it's the fusion that delimits those? Presumably we will be putting even more things in there in the future. Why not call them CustomPrePasses and CustomPostPasses?
Fair point, I can change the names. |
|
…h#33261) Summary: Pull Request resolved: pytorch#33261 It was requested in pytorch#33114. Test Plan: Imported from OSS Differential Revision: D19910600 Pulled By: ZolotukhinM fbshipit-source-id: 827f1744b97f386065a21d1ba5d82c1f90edbe46
Stack from ghstack:
It was requested in #33114.
Differential Revision: D19910600