-
Notifications
You must be signed in to change notification settings - Fork 26.3k
Make lazy codegen honor per-operator-headers flag #74450
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
CI Flow Status⚛️ CI FlowRuleset - Version:
|
🔗 Helpful links
💊 CI failures summary and remediationsAs of commit 4425d38 (more details on the Dr. CI page): 💚 💚 Looks good so far! There are no failures yet. 💚 💚 This comment was automatically generated by Dr. CI (expand for details).Please report bugs/suggestions to the (internal) Dr. CI Users group. |
|
This pull request was exported from Phabricator. Differential Revision: D35002666 |
.jenkins/pytorch/test.sh
Outdated
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.
mostly just wondering - were the cpp tests no running in CI before this? And any reason to only enable them for cuda builds on CI? (once the XLA plugin is ready, I'm guessing we want it to run on XLA too?)
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.
correct, it was an oversight, but not a big deal since we mostly looked at the lazy_tensor_staging CI, and also this test was running in sandcastle. But it did confuse me for a while when I was trying to find the output of the expanded test suite in my later diff!
also note, this change is supposed to be landed first in #74449
I'm not sure why the rebase didn't work as intended, but this diff should only be adding the per-operator-headers stuff, and i'll land the other one first and make sure this one is clean.
caffe2/CMakeLists.txt
Outdated
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.
hmm I might just be misunderstanding. But why does the actual codegen need to know if we're building the per-operator flag or not?
I think the way it works today is that the codegen will always emit the per-operator headers. The codegen templates files themselves include an IFDEF like this:
#ifndef AT_PER_OPERATOR_HEADERS
#include <ATen/Operators.h>
#else
${operator_headers}
#endif
That way the conditional code just lives directly in the C++ template file, instead of needing to clutter up the codegen with it. Example template:
| #ifndef AT_PER_OPERATOR_HEADERS |
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 think I didn't realize this logic existed, but it is still not enough since I also had to fix this (see below)
'ops_headers': '#include <ATen/Functions.h>' if not per_operator_headers else '',
Perhaps we could move ATen/Functions.h into the template ifdef and then things would have been OK.
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 think the way it works today is that the codegen will always emit the per-operator headers. The codegen templates files themselves include an IFDEF like this:
I think this isn't quite correct, the RegisterFunctionalization template is a nice thing to emulate but it is not how RegisterDispatchKey works currently. RegisterDispatchKey currently has its per_operator_headers thing hardcoded to False in gen_backend_stubs.py (probably since that is presumed only used out of tree), and RegisterDispatchKey.cpp doesn't have the nice #ifndef that you pointed out in RegisterFunctionalization.
I was starting to mess with this, and I am kind of wondering if it's ok to land as-is and then update how it works. I mainly don't want to add any more delay to landing the TS backend since that is blocking other stuff downstream.
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.
ok yep, I definitely don't want to hold up the PR on this if landing this PR is actively blocking other things.
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.
you're also totally right - it looks like we do something similar for RegisterDispatchKey.cpp (plumbing this flag into the codegen), e.g. here:
Line 144 in 37c5f11
| set(GEN_PER_OPERATOR_FLAG) |
|
This pull request was exported from Phabricator. Differential Revision: D35002666 |
78c0cfc to
d41bc9c
Compare
Summary: Pull Request resolved: pytorch#74450 - per-operator-headers is a strict build mode where compulation units aren't allowed to depend on bulk headers like ATen/Functions.h, but must instead depend only on the specific operator headers used. (In other configurations, the reverse is required). Test Plan: CI to make sure nothing breaks for existing backends, and rebased next diff manual test to make sure it actually helps Reviewed By: ezyang Differential Revision: D35002666 fbshipit-source-id: 37d1142e165a1f326df2f463c261c5058c244d10
d41bc9c to
4425d38
Compare
|
This pull request was exported from Phabricator. Differential Revision: D35002666 |
Summary: Pull Request resolved: #74450 - per-operator-headers is a strict build mode where compulation units aren't allowed to depend on bulk headers like ATen/Functions.h, but must instead depend only on the specific operator headers used. (In other configurations, the reverse is required). Test Plan: CI to make sure nothing breaks for existing backends, and rebased next diff manual test to make sure it actually helps Reviewed By: ezyang, bdhirsh Differential Revision: D35002666 fbshipit-source-id: 712445f8d146cf026759444fbd42a20705be9bef
|
Hey @wconstab. |
Summary: Pull Request resolved: #74450 - per-operator-headers is a strict build mode where compulation units aren't allowed to depend on bulk headers like ATen/Functions.h, but must instead depend only on the specific operator headers used. (In other configurations, the reverse is required). Test Plan: CI to make sure nothing breaks for existing backends, and rebased next diff manual test to make sure it actually helps Reviewed By: ezyang, bdhirsh Differential Revision: D35002666 fbshipit-source-id: 712445f8d146cf026759444fbd42a20705be9bef (cherry picked from commit f13e552)
Summary:
to depend on bulk headers like ATen/Functions.h, but must instead depend only on the
specific operator headers used. (In other configurations, the reverse is required).
Test Plan: CI to make sure nothing breaks for existing backends, and rebased next diff manual test to make sure it actually helps
Differential Revision: D35002666