Skip to content

Conversation

smessmer
Copy link
Contributor

@smessmer smessmer commented Apr 21, 2020

Stack from ghstack:

c10 takes a Stack* in boxed functions while JIT took Stack&.
c10 doesn't return anything while JIT returns an int which is always zero.

This changes JIT to follow the c10 behavior.

Differential Revision: D20567950

c10 takes a Stack* in boxed functions while JIT took Stack&.
c10 doesn't return anything while JIT returns an int which is always zero.

This changes JIT to follow the c10 behavior.

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

[ghstack-poisoned]
@facebook-github-bot facebook-github-bot added the oncall: jit Add this issue/PR to JIT oncall triage queue label Apr 21, 2020
c10 takes a Stack* in boxed functions while JIT took Stack&.
c10 doesn't return anything while JIT returns an int which is always zero.

This changes JIT to follow the c10 behavior.

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

[ghstack-poisoned]
@dr-ci
Copy link

dr-ci bot commented Apr 21, 2020

💊 CI failures summary and remediations

As of commit 14ea12a (more details on the Dr. CI page):



🕵️ 1 new failure recognized by patterns

The following CI failures do not appear to be due to upstream breakages:

See CircleCI build pytorch_linux_xenial_py3_6_gcc5_4_build (1/1)

Step: "(Optional) Merge target branch" (full log | diagnosis details | 🔁 rerun)

Automatic merge failed; fix conflicts and then commit the result.
 
  git checkout -b <new-branch-name> 
 
HEAD is now at 14ea12a630 Update on "Unify boxed function signature between jit and c10" 
+ git reset --hard 14ea12a630d67c6641a4bf4870ba7186640f8a71 
HEAD is now at 14ea12a630 Update on "Unify boxed function signature between jit and c10" 
+ git merge --allow-unrelated-histories --no-edit --no-ff 0235676f8a3c7a6e64b250151faec21037bdd402 
Auto-merging torch/csrc/jit/runtime/register_prim_ops_fulljit.cpp 
CONFLICT (content): Merge conflict in torch/csrc/jit/runtime/register_prim_ops_fulljit.cpp 
Auto-merging torch/csrc/jit/runtime/register_prim_ops.cpp 
Automatic merge failed; fix conflicts and then commit the result. 

🚧 1 ongoing upstream failure:

These were probably caused by upstream breakages that are not fixed 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 or post in the (internal) Dr. CI Users group.

See how this bot performed.

This comment has been revised 59 times.

@smessmer smessmer requested a review from bhosmer April 21, 2020 23:29
c10 takes a Stack* in boxed functions while JIT took Stack&.
c10 doesn't return anything while JIT returns an int which is always zero.

This changes JIT to follow the c10 behavior.

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

[ghstack-poisoned]
smessmer added a commit that referenced this pull request Apr 21, 2020
Pull Request resolved: #37034

c10 takes a Stack* in boxed functions while JIT took Stack&.
c10 doesn't return anything while JIT returns an int which is always zero.

This changes JIT to follow the c10 behavior.
ghstack-source-id: 102624730

Differential Revision: [D20567950](https://our.internmc.facebook.com/intern/diff/D20567950/)
c10 takes a Stack* in boxed functions while JIT took Stack&.
c10 doesn't return anything while JIT returns an int which is always zero.

This changes JIT to follow the c10 behavior.

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

[ghstack-poisoned]
smessmer added a commit that referenced this pull request Apr 22, 2020
Pull Request resolved: #37034

c10 takes a Stack* in boxed functions while JIT took Stack&.
c10 doesn't return anything while JIT returns an int which is always zero.

This changes JIT to follow the c10 behavior.
ghstack-source-id: 102643121

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

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

LGTM

@@ -29,9 +29,15 @@ using Operation = std::function<int(Stack&)>;
static inline IValue& peek(Stack& stack, size_t i, size_t N) {
return *(stack.end() - N + i);
}
static inline IValue& peek(Stack* stack, size_t i, size_t N) {
return peek(*stack, i, N);
}
Copy link

Choose a reason for hiding this comment

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

Given the switch from Stack& to Stack*, why do we still need the old Stack& overloads? Will probably find out further down the PR, but leaving this here just in case not :P

Copy link
Contributor Author

Choose a reason for hiding this comment

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

because otherwise we'd have to change even more code. They probably should die at some point though.

@@ -72,11 +87,14 @@ template <typename... Types>
static inline void pop(Stack& stack, Types&... args) {
size_t i = 0;
constexpr size_t N = sizeof...(args);
int result[N] = {
(void)std::initializer_list<int>{
Copy link

Choose a reason for hiding this comment

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

This change isn't strictly necessary, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

true, this is something I cleaned up on the way

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@bhosmer lol remember the msvc issue where we had to land exactly this to fix it? I should have landed this sooner and we would have had to do a lot less debugging there...

Copy link

Choose a reason for hiding this comment

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

ugh yeah as you were describing the fix I was thinking of this change and wondering where it had gone 😝

c10 takes a Stack* in boxed functions while JIT took Stack&.
c10 doesn't return anything while JIT returns an int which is always zero.

This changes JIT to follow the c10 behavior.

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

[ghstack-poisoned]
smessmer added a commit that referenced this pull request Apr 24, 2020
Pull Request resolved: #37034

c10 takes a Stack* in boxed functions while JIT took Stack&.
c10 doesn't return anything while JIT returns an int which is always zero.

This changes JIT to follow the c10 behavior.
ghstack-source-id: 102855159

Differential Revision: [D20567950](https://our.internmc.facebook.com/intern/diff/D20567950/)
c10 takes a Stack* in boxed functions while JIT took Stack&.
c10 doesn't return anything while JIT returns an int which is always zero.

This changes JIT to follow the c10 behavior.

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

[ghstack-poisoned]
c10 takes a Stack* in boxed functions while JIT took Stack&.
c10 doesn't return anything while JIT returns an int which is always zero.

This changes JIT to follow the c10 behavior.

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

[ghstack-poisoned]
c10 takes a Stack* in boxed functions while JIT took Stack&.
c10 doesn't return anything while JIT returns an int which is always zero.

This changes JIT to follow the c10 behavior.

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

[ghstack-poisoned]
smessmer added a commit that referenced this pull request Apr 25, 2020
Pull Request resolved: #37034

c10 takes a Stack* in boxed functions while JIT took Stack&.
c10 doesn't return anything while JIT returns an int which is always zero.

This changes JIT to follow the c10 behavior.
ghstack-source-id: 102896394

Differential Revision: [D20567950](https://our.internmc.facebook.com/intern/diff/D20567950/)
c10 takes a Stack* in boxed functions while JIT took Stack&.
c10 doesn't return anything while JIT returns an int which is always zero.

This changes JIT to follow the c10 behavior.

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

[ghstack-poisoned]
c10 takes a Stack* in boxed functions while JIT took Stack&.
c10 doesn't return anything while JIT returns an int which is always zero.

This changes JIT to follow the c10 behavior.

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

[ghstack-poisoned]
smessmer added a commit that referenced this pull request Apr 27, 2020
Pull Request resolved: #37034

c10 takes a Stack* in boxed functions while JIT took Stack&.
c10 doesn't return anything while JIT returns an int which is always zero.

This changes JIT to follow the c10 behavior.
ghstack-source-id: 102934643

Differential Revision: [D20567950](https://our.internmc.facebook.com/intern/diff/D20567950/)
c10 takes a Stack* in boxed functions while JIT took Stack&.
c10 doesn't return anything while JIT returns an int which is always zero.

This changes JIT to follow the c10 behavior.

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

[ghstack-poisoned]
c10 takes a Stack* in boxed functions while JIT took Stack&.
c10 doesn't return anything while JIT returns an int which is always zero.

This changes JIT to follow the c10 behavior.

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

[ghstack-poisoned]
smessmer added a commit that referenced this pull request Jun 29, 2020
Pull Request resolved: #37034

c10 takes a Stack* in boxed functions while JIT took Stack&.
c10 doesn't return anything while JIT returns an int which is always zero.

This changes JIT to follow the c10 behavior.
ghstack-source-id: 106815351

Differential Revision: [D20567950](https://our.internmc.facebook.com/intern/diff/D20567950/)
c10 takes a Stack* in boxed functions while JIT took Stack&.
c10 doesn't return anything while JIT returns an int which is always zero.

This changes JIT to follow the c10 behavior.

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

[ghstack-poisoned]
smessmer added a commit that referenced this pull request Jun 29, 2020
Pull Request resolved: #37034

c10 takes a Stack* in boxed functions while JIT took Stack&.
c10 doesn't return anything while JIT returns an int which is always zero.

This changes JIT to follow the c10 behavior.
ghstack-source-id: 106834069

Differential Revision: [D20567950](https://our.internmc.facebook.com/intern/diff/D20567950/)
facebook-github-bot pushed a commit that referenced this pull request Jun 30, 2020
Summary:
Pull Request resolved: #37034

c10 takes a Stack* in boxed functions while JIT took Stack&.
c10 doesn't return anything while JIT returns an int which is always zero.

This changes JIT to follow the c10 behavior.
ghstack-source-id: 106834069

Test Plan: unit tests

Differential Revision: D20567950

fbshipit-source-id: 1a7aea291023afc52ae706957e9a5ca576fbb53b
@facebook-github-bot facebook-github-bot deleted the gh/smessmer/209/head branch July 3, 2020 14:17
@bddppq
Copy link
Contributor

bddppq commented Jul 10, 2020

Our project has registered custom jit operators (outside of the pytorch tree), and this diff breaks them because the Operation signature has been changed.
Is it that directly registering jit operator considered jit internal details and so not much backward compatibility guarantee going forward? From quickly browsing some projects that adds custom op, they seem to directly register jit operator as well (and this change actually also breaks them)

@smessmer
Copy link
Contributor Author

smessmer commented Jul 10, 2020

The torch::jit::RegisterOperators API is only meant for internal prim ops and not public API. The public operator registration API was torch::RegisterOperators and we just started building a new pybind-style one to replace torch::RegisterOperators (see documentation). Does one of those work for your use case? Note that you'd have to write your operators in an unboxed way, e.g. Tensor my_add(Tensor a, Tensor b) {...} instead of in a boxed way like void my_add(vector<IValue>* args).

@smessmer
Copy link
Contributor Author

Btw, are you certain those projects break? I think TVM will likely break because they need access to the JIT node and that changed, but I think the TRTorch project shouldn't break. The way they're calling still works, just throws a deprecation warning now.

@bddppq
Copy link
Contributor

bddppq commented Jul 10, 2020

The reason we chose to directly register jit operator is that our custom op's kernel needs to access the attribute of its associated jit node (similar to the torch_tvm use case linked in my last comment).

@bddppq
Copy link
Contributor

bddppq commented Jul 10, 2020

Btw, are you certain those projects break? I think TVM will likely break because they need access to the JIT node and that changed, but I think the TRTorch project shouldn't break. The way they're calling still works, just throws a deprecation warning now.

I have not tried actually building them, maybe you are right that TRTorch doesn't break.

@smessmer
Copy link
Contributor Author

hm yes, in that case you need torch::jit::RegisterOperators. Note that the whole jit Node class isn't part of the public API and could change. It's ok to use it but you'll likely have to adapt your code from time to time.

vdantu pushed a commit to vdantu/glow that referenced this pull request Jul 12, 2020
Summary:
Pull Request resolved: pytorch/pytorch#37034

c10 takes a Stack* in boxed functions while JIT took Stack&.
c10 doesn't return anything while JIT returns an int which is always zero.

This changes JIT to follow the c10 behavior.
ghstack-source-id: 106834069

Differential Revision: D20567950

fbshipit-source-id: 1a7aea291023afc52ae706957e9a5ca576fbb53b
geoffberry pushed a commit to geoffberry/glow that referenced this pull request Nov 8, 2020
Summary:
Pull Request resolved: pytorch/pytorch#37034

c10 takes a Stack* in boxed functions while JIT took Stack&.
c10 doesn't return anything while JIT returns an int which is always zero.

This changes JIT to follow the c10 behavior.
ghstack-source-id: 106834069

Differential Revision: D20567950

fbshipit-source-id: 1a7aea291023afc52ae706957e9a5ca576fbb53b
jjsjann123 pushed a commit to jjsjann123/nvfuser that referenced this pull request Oct 29, 2022
Summary:
Pull Request resolved: pytorch/pytorch#37034

c10 takes a Stack* in boxed functions while JIT took Stack&.
c10 doesn't return anything while JIT returns an int which is always zero.

This changes JIT to follow the c10 behavior.
ghstack-source-id: 106834069

Test Plan: unit tests

Differential Revision: D20567950

fbshipit-source-id: 1a7aea291023afc52ae706957e9a5ca576fbb53b
jjsjann123 pushed a commit to jjsjann123/nvfuser that referenced this pull request Nov 10, 2022
Summary:
Pull Request resolved: pytorch/pytorch#37034

c10 takes a Stack* in boxed functions while JIT took Stack&.
c10 doesn't return anything while JIT returns an int which is always zero.

This changes JIT to follow the c10 behavior.
ghstack-source-id: 106834069

Test Plan: unit tests

Differential Revision: D20567950

fbshipit-source-id: 1a7aea291023afc52ae706957e9a5ca576fbb53b
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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants