Skip to content
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

Remove use_c10_dispatcher: unboxed_only #36838

Closed
wants to merge 4 commits into from

Conversation

smessmer
Copy link
Contributor

@smessmer smessmer commented Apr 17, 2020

Stack from ghstack:

All ops now do unboxing after dispatch, i.e. c10 handles unboxing and c10 registers a wrapper for the op to JIT
The last op that manually registered its own wrapper to JIT in register_aten_ops.cpp was migrated.

Since there are no ops using use_c10_dispatcher: unboxed_only anymore, we can delete the feature.

Also:

  • Rename some files to more accurately describe what they're doing now:
    • OpsAlreadyMovedToC10.h/cpp -> ATenOpList.h/cpp
    • register_aten_ops.cpp -> generated_unboxing_wrappers.cpp
    • gen_jit_dispatch.py -> gen_unboxing_wrappers.py

Differential Revision: D21100081

NOTE FOR REVIEWERS: This PR has internal Facebook specific changes or comments, please review them on Phabricator!

All ops now do unboxing after dispatch, i.e. c10 handles unboxing and c10 registers a wrapper for the op to JIT
The last op that manually registered its own wrapper to JIT in register_aten_ops.cpp was migrated.

Since there are no ops using use_c10_dispatcher: unboxed_only anymore, we can delete the feature.

Also:
- Rename some files to more accurately describe what they're doing now:
  - OpsAlreadyMovedToC10.h/cpp -> ATenOpList.h/cpp
  - register_aten_ops.cpp -> generated_unboxing_wrappers.cpp
  - gen_jit_dispatch.py -> gen_unboxing_wrappers.cpp

Differential Revision: [D21100081](https://our.internmc.facebook.com/intern/diff/D21100081/)

**NOTE FOR REVIEWERS**: This PR has internal Facebook specific changes or comments, please review them on [Phabricator](https://our.internmc.facebook.com/intern/diff/D21100081/)!

[ghstack-poisoned]
@smessmer smessmer requested a review from apaszke as a code owner April 17, 2020 22:28
@facebook-github-bot facebook-github-bot added the oncall: jit Add this issue/PR to JIT oncall triage queue label Apr 17, 2020
smessmer added a commit that referenced this pull request Apr 17, 2020
All ops now do unboxing after dispatch, i.e. c10 handles unboxing and c10 registers a wrapper for the op to JIT
The last op that manually registered its own wrapper to JIT in register_aten_ops.cpp was migrated.

Since there are no ops using use_c10_dispatcher: unboxed_only anymore, we can delete the feature.

Also:
- Rename some files to more accurately describe what they're doing now:
  - OpsAlreadyMovedToC10.h/cpp -> ATenOpList.h/cpp
  - register_aten_ops.cpp -> generated_unboxing_wrappers.cpp
  - gen_jit_dispatch.py -> gen_unboxing_wrappers.cpp

Differential Revision: [D21100081](https://our.internmc.facebook.com/intern/diff/D21100081/)

**NOTE FOR REVIEWERS**: This PR has internal Facebook specific changes or comments, please review them on [Phabricator](https://our.internmc.facebook.com/intern/diff/D21100081/)!

ghstack-source-id: 102407222
Pull Request resolved: #36838
@smessmer smessmer requested a review from bhosmer April 17, 2020 22:34
@dr-ci
Copy link

dr-ci bot commented Apr 17, 2020

💊 Build failures summary and remediations

As of commit dd12431 (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).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 10 times.

@smessmer smessmer requested review from EscapeZero and ezyang and removed request for EscapeZero April 18, 2020 00:28
@ezyang
Copy link
Contributor

ezyang commented Apr 20, 2020

Do we still need impl_UNBOXED?

@smessmer
Copy link
Contributor Author

smessmer commented Apr 20, 2020

Do we still need impl_UNBOXED?

Yes, to get rid of that, we first need to fix all the gaps in #32366.

The new default (after this PR but without fixing those gaps) is 'with_codegenerated_unboxing_wrappers', i.e. if an op doesn't explicitly specify 'use_c10_dispatcher: full', it will get a codegenerated unboxing wrapper. The registration then still needs to use impl_UNBOXED so it doesn't generate a templated unboxing wrapper for it.

namespace at {

// list of ATen ops that come from native_functions.yaml
CAFFE2_API bool is_aten_op(const c10::OperatorName& opName);
Copy link
Contributor

Choose a reason for hiding this comment

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

This new name doesn't seem very descriptive. (A better question to ask, perhaps: why do I care if it is_aten_op? Why isn't this the same thing as just checking the namespace?)

Copy link
Contributor

Choose a reason for hiding this comment

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

Agreed, the implications of this name aren't that clear unless you're pretty deep into what's going on. Judging by its use here, I'd suggest maybe inverting the sense and making it is_custom_op instead.

Copy link
Contributor Author

@smessmer smessmer Apr 20, 2020

Choose a reason for hiding this comment

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

checking the namespace is a good idea, we should move towards doing that instead. I added a TODO. It likely doesn't work just yet because we might have internal "custom" ops that use the aten namespace. For now, I renamed it to is_custom_op.

Copy link
Contributor

Choose a reason for hiding this comment

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

@smessmer when I get everything onto the new API, we will be able to guarantee that custom ops don't use the aten namespace.

But I am kind of curious what the downstream usage of this is, because the way I'm likely going to make the internal "Custom" ops (you're talking about the JIT ops right?) live in a centralized location is by hardcoding their registrations in TypeDefault.cpp ala #36925

See also #36926

Copy link
Contributor

@ezyang ezyang left a comment

Choose a reason for hiding this comment

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

This seems like a strict improvement (so I will approve) but I don't see why you need the is_aten_op predicate anymore.

Copy link
Contributor

@bhosmer bhosmer left a comment

Choose a reason for hiding this comment

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

If @ezyang is right and is_aten_op can be replaced by a simple namespace check at the remaining callsites, that definitely seems better. Otherwise I'd vote for renaming per inline comment.

Also, not for this PR but in general I'd mildly prefer having the unboxed_only removal and the renaming be separate diffs, esp given that the file renaming ripples into the build scripts and so on.

namespace at {

// list of ATen ops that come from native_functions.yaml
CAFFE2_API bool is_aten_op(const c10::OperatorName& opName);
Copy link
Contributor

Choose a reason for hiding this comment

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

Agreed, the implications of this name aren't that clear unless you're pretty deep into what's going on. Judging by its use here, I'd suggest maybe inverting the sense and making it is_custom_op instead.

@@ -169,16 +169,11 @@ class RegistrationListener final : public c10::OpRegistrationListener {
// TODO Find a better way to handle this.
return;
}
if (at::is_aten_op_and_unboxing_is_already_handled_by_c10(
op.schema().operator_name())) {
if (at::is_aten_op(op.schema().operator_name())) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Aside: in a world where the listener setup is no longer needed (because the JIT knows how to do c10 registry lookups directly), where will this conditional creation of a testing wrapper wind up?

Copy link
Contributor Author

@smessmer smessmer Apr 20, 2020

Choose a reason for hiding this comment

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

Excellent question. I guess it would have to be in the call path which sucks. Moving this to do a namespace check instead might solve the issue.

All ops now do unboxing after dispatch, i.e. c10 handles unboxing and c10 registers a wrapper for the op to JIT
The last op that manually registered its own wrapper to JIT in register_aten_ops.cpp was migrated.

Since there are no ops using use_c10_dispatcher: unboxed_only anymore, we can delete the feature.

Also:
- Rename some files to more accurately describe what they're doing now:
  - OpsAlreadyMovedToC10.h/cpp -> ATenOpList.h/cpp
  - register_aten_ops.cpp -> generated_unboxing_wrappers.cpp
  - gen_jit_dispatch.py -> gen_unboxing_wrappers.cpp

Differential Revision: [D21100081](https://our.internmc.facebook.com/intern/diff/D21100081/)

**NOTE FOR REVIEWERS**: This PR has internal Facebook specific changes or comments, please review them on [Phabricator](https://our.internmc.facebook.com/intern/diff/D21100081/)!

[ghstack-poisoned]
All ops now do unboxing after dispatch, i.e. c10 handles unboxing and c10 registers a wrapper for the op to JIT
The last op that manually registered its own wrapper to JIT in register_aten_ops.cpp was migrated.

Since there are no ops using use_c10_dispatcher: unboxed_only anymore, we can delete the feature.

Also:
- Rename some files to more accurately describe what they're doing now:
  - OpsAlreadyMovedToC10.h/cpp -> ATenOpList.h/cpp
  - register_aten_ops.cpp -> generated_unboxing_wrappers.cpp
  - gen_jit_dispatch.py -> gen_unboxing_wrappers.cpp

Differential Revision: [D21100081](https://our.internmc.facebook.com/intern/diff/D21100081/)

**NOTE FOR REVIEWERS**: This PR has internal Facebook specific changes or comments, please review them on [Phabricator](https://our.internmc.facebook.com/intern/diff/D21100081/)!

[ghstack-poisoned]
All ops now do unboxing after dispatch, i.e. c10 handles unboxing and c10 registers a wrapper for the op to JIT
The last op that manually registered its own wrapper to JIT in register_aten_ops.cpp was migrated.

Since there are no ops using use_c10_dispatcher: unboxed_only anymore, we can delete the feature.

Also:
- Rename some files to more accurately describe what they're doing now:
  - OpsAlreadyMovedToC10.h/cpp -> ATenOpList.h/cpp
  - register_aten_ops.cpp -> generated_unboxing_wrappers.cpp
  - gen_jit_dispatch.py -> gen_unboxing_wrappers.cpp

Differential Revision: [D21100081](https://our.internmc.facebook.com/intern/diff/D21100081/)

**NOTE FOR REVIEWERS**: This PR has internal Facebook specific changes or comments, please review them on [Phabricator](https://our.internmc.facebook.com/intern/diff/D21100081/)!

[ghstack-poisoned]
@facebook-github-bot
Copy link
Contributor

This pull request has been merged in 6d13a33.

@facebook-github-bot facebook-github-bot deleted the gh/smessmer/206/head branch April 25, 2020 14:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Merged oncall: jit Add this issue/PR to JIT oncall triage queue
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants