Allow disabling custom passes.#34769
Conversation
💊 CircleCI build failures summary and remediationsAs of commit 42c9cc5 (more details on the Dr. CI page): ✅ None of the build failures appear to be your fault 💚
🚧 1 upstream failure:These were probably caused by upstream breakages:
This comment was automatically generated by Dr. CI (expand for details).Follow this link to opt-out of these comments for your Pull Requests.Please report bugs/suggestions on the GitHub issue tracker. This comment has been revised 70 times. |
|
Included the renaming from #33674 |
ZolotukhinM
left a comment
There was a problem hiding this comment.
Thanks for adding this, I think it's a really useful feature to have! Could you please elaborate more on the implementation details? I feel it's a little hard to follow at them moment (or maybe harder than it could be). Maybe it is possible to simplify it a bit, or at least add some comments explaining why it is done this way?
There was a problem hiding this comment.
Nit: a space is missing before '{'. Do you mind running clang-format on the PR?
There was a problem hiding this comment.
Why does it have to be a struct rather than just a function?
There was a problem hiding this comment.
I don't believe it does, was keeping it consistent with how it was. I wasn't wasn't sure if it was a struct for any particular reason before.
struct TORCH_API RegisterPreFusionPass {
RegisterPreFusionPass(GraphPass p);
}
is where we started from. I couldn't see a technical reason for it immediately but assumed there was one. If you'd like I can try to remove the structs.
There was a problem hiding this comment.
I'm not sure I quite understand why what's the purpose of the flip here. Could you please elaborate on it?
ZolotukhinM
left a comment
There was a problem hiding this comment.
Mostly looks good, please find some comments inline.
There was a problem hiding this comment.
Similarly, can we make name a static member of the class? Also, a bit of bikeshedding: should it be called pass_id (when I first read the code and saw "name" I expected it to be a string)?
There was a problem hiding this comment.
name (now pass id) and isRegistered could be a member of the class, but that would require those deriving from the class to instantiate them in their .cpp file. There's two options here, either have additional small complexity in everyone using the pass manager (defining MyPassRegister::pass_id = 0 and MyPassRegister::is_registered = false, or have them as static vars in a function. I chose this way as now to use this register function you only have to modify your header file in a pretty concise manner.
I do prefer this way, but if you have a strong preference in having the instantiations in the .cpp and static member vars, I can do that.
There was a problem hiding this comment.
Can we make isRegistered a static member of this class and add getters/setters for it instead of one function that does both?
There was a problem hiding this comment.
I kept registerPass when added registerPostPass/registerPrePass to not break it for users who might have been using the old API. This PR changes its signature anyway, so we can remove registerPass altogether, no reason to keep it.
There was a problem hiding this comment.
You might want to expose RegisterCudaFuseGraph::clearPass as well.
There was a problem hiding this comment.
I need to fix merge conflicts in the big fuser PR. I'll do this then, so I can also test it. Let me know if you prefer it here.
There was a problem hiding this comment.
Could we allow registering both pre and post passes here?
There was a problem hiding this comment.
I couldn't think of an easy way to do this. One option could be another bool template parameter that marks post or pre. Any thoughts?
|
Failures look unrelated to the pr |
|
whoops, wrong PR, sorry. |
facebook-github-bot
left a comment
There was a problem hiding this comment.
@ZolotukhinM has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.
facebook-github-bot
left a comment
There was a problem hiding this comment.
@ZolotukhinM has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.
facebook-github-bot
left a comment
There was a problem hiding this comment.
@ZolotukhinM has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.
|
@pytorchbot retest this please |
facebook-github-bot
left a comment
There was a problem hiding this comment.
@ZolotukhinM has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.
facebook-github-bot
left a comment
There was a problem hiding this comment.
@soumith has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.
|
Merged as part of #34785 |
Right now there's no way to remove a custom pass once it has been added. This PR allows that to happen, and adds an abstract class that makes it easy to enable for passes.