Skip to content

Allow disabling custom passes.#34769

Closed
csarofeen wants to merge 17 commits intopytorch:masterfrom
csarofeen:customPass
Closed

Allow disabling custom passes.#34769
csarofeen wants to merge 17 commits intopytorch:masterfrom
csarofeen:customPass

Conversation

@csarofeen
Copy link
Copy Markdown
Contributor

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.

@csarofeen csarofeen requested a review from apaszke as a code owner March 14, 2020 20:10
@facebook-github-bot facebook-github-bot added the oncall: jit Add this issue/PR to JIT oncall triage queue label Mar 14, 2020
@dr-ci
Copy link
Copy Markdown

dr-ci Bot commented Mar 14, 2020

💊 CircleCI build failures summary and remediations

As of commit 42c9cc5 (more details on the Dr. CI page):


None of the build failures appear to be your fault 💚


  • 1/1 broken upstream at merge base 76d5102 since Mar 27

    Please rebase on the viable/strict branch (expand for instructions)

    If your commit is newer than viable/strict, you can try basing on an older, stable commit:

    git fetch https://github.com/pytorch/pytorch viable/strict
    git rebase --onto FETCH_HEAD $(git merge-base origin/master HEAD)
    

    If your commit is older than viable/strict:

    git fetch https://github.com/pytorch/pytorch viable/strict
    git rebase FETCH_HEAD
    

    Check out the recency history of this "viable master" tracking branch.


🚧 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.

See how this bot performed.

This comment has been revised 70 times.

@csarofeen
Copy link
Copy Markdown
Contributor Author

Included the renaming from #33674

Copy link
Copy Markdown

@ZolotukhinM ZolotukhinM left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: a space is missing before '{'. Do you mind running clang-format on the PR?

Comment thread torch/csrc/jit/passes/pass_manager.h Outdated
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why does it have to be a struct rather than just a function?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread torch/csrc/jit/passes/pass_manager.cpp Outdated
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure I quite understand why what's the purpose of the flip here. Could you please elaborate on it?

Comment thread torch/csrc/jit/passes/pass_manager.cpp Outdated
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does this do?

Copy link
Copy Markdown

@ZolotukhinM ZolotukhinM left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mostly looks good, please find some comments inline.

Comment thread torch/csrc/jit/passes/pass_manager.h Outdated
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread torch/csrc/jit/passes/pass_manager.h Outdated
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we make isRegistered a static member of this class and add getters/setters for it instead of one function that does both?

Comment thread torch/csrc/jit/passes/pass_manager.h Outdated
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed.

Comment thread torch/csrc/jit/python/init.cpp Outdated
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You might want to expose RegisterCudaFuseGraph::clearPass as well.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread torch/csrc/jit/passes/pass_manager.h Outdated
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we allow registering both pre and post passes here?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

@csarofeen
Copy link
Copy Markdown
Contributor Author

Failures look unrelated to the pr

csarofeen added a commit to csarofeen/pytorch that referenced this pull request Mar 17, 2020
@csarofeen
Copy link
Copy Markdown
Contributor Author

csarofeen commented Mar 17, 2020

whoops, wrong PR, sorry.

@yf225 yf225 added the triaged This issue has been looked at a team member, and triaged and prioritized into an appropriate module label Mar 20, 2020
Copy link
Copy Markdown
Contributor

@facebook-github-bot facebook-github-bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ZolotukhinM has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

Copy link
Copy Markdown
Contributor

@facebook-github-bot facebook-github-bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ZolotukhinM has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

Copy link
Copy Markdown
Contributor

@facebook-github-bot facebook-github-bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ZolotukhinM has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

@ZolotukhinM
Copy link
Copy Markdown

@pytorchbot retest this please

Copy link
Copy Markdown
Contributor

@facebook-github-bot facebook-github-bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ZolotukhinM has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

Copy link
Copy Markdown
Contributor

@facebook-github-bot facebook-github-bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@soumith has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

@csarofeen
Copy link
Copy Markdown
Contributor Author

Merged as part of #34785

@soumith soumith closed this Apr 2, 2020
@csarofeen csarofeen deleted the customPass branch April 17, 2020 15:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

oncall: jit Add this issue/PR to JIT oncall triage queue open source triaged This issue has been looked at a team member, and triaged and prioritized into an appropriate module

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants