Skip to content

Improve aten::backward handling#36750

Closed
smessmer wants to merge 4 commits intogh/smessmer/205/basefrom
gh/smessmer/205/head
Closed

Improve aten::backward handling#36750
smessmer wants to merge 4 commits intogh/smessmer/205/basefrom
gh/smessmer/205/head

Conversation

@smessmer
Copy link
Copy Markdown
Contributor

@smessmer smessmer commented Apr 16, 2020

Stack from ghstack:

  • It seems the JIT schema for aten::backward and the schema in native_functions.yaml diverged on whether the retain_graph/keep_graph parameter takes a bool or a bool?. Make them identical again.
  • Also remove the mutability annotation for the self parameter. This does not make sense together with AliasAnalysisKind::CONSERVATIVE and it triggered an assertion
  • After fixing the mutability annotation, we can fix that assertion so that it doesn't exclude aten::backward from its check anymore
  • Last but not least, remove the unboxed_only marker from aten::backward. This requires us to add a special case in register_c10_ops.cpp for it, because JIT still has its own implementation.

After this PR, we still have separate implementations for aten::backward for JIT (in register_prim_ops_fulljit.cpp) and for eager mode (in native_functions.yaml), but they share the same signature again.

Differential Revision: D21004102

- It seems the JIT schema for aten::backward and the schema in native_functions.yaml diverged on whether the retain_graph/keep_graph parameter takes a `bool` or a `bool?`. Make them identical again.
- Also remove the mutability annotation for the self parameter. This does not make sense together with AliasAnalysisKind::CONSERVATIVE and it triggered an assertion
- After fixing the mutability annotation, we can fix that assertion so that it doesn't exclude aten::backward from its check anymore
- Last but not least, remove the unboxed_only marker from aten::backward. This requires us to add a special case in register_c10_ops.cpp for it, because JIT still has its own implementation.

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

[ghstack-poisoned]
@smessmer smessmer requested review from albanD and apaszke as code owners April 16, 2020 20:58
@facebook-github-bot facebook-github-bot added the oncall: jit Add this issue/PR to JIT oncall triage queue label Apr 16, 2020
@dr-ci
Copy link
Copy Markdown

dr-ci Bot commented Apr 16, 2020

💊 Build failures summary and remediations

As of commit 3b2da0a (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 9 times.

- It seems the JIT schema for aten::backward and the schema in native_functions.yaml diverged on whether the retain_graph/keep_graph parameter takes a `bool` or a `bool?`. Make them identical again.
- Also remove the mutability annotation for the self parameter. This does not make sense together with AliasAnalysisKind::CONSERVATIVE and it triggered an assertion
- After fixing the mutability annotation, we can fix that assertion so that it doesn't exclude aten::backward from its check anymore
- Last but not least, remove the unboxed_only marker from aten::backward. This requires us to add a special case in register_c10_ops.cpp for it, because JIT still has its own implementation.

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

[ghstack-poisoned]
Copy link
Copy Markdown

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

LG mod tests :)

Maybe add a sentence summarizing the post-PR end state to the description? the changes make sense but a recap of the "improved" situation might be good

// create_graph=True so we use aliasAnalysisConservative for these two OPs
Operator(
"aten::backward(Tensor[](a!) tensors, Tensor?[]? grad_tensors=None, bool? retain_graph=None, bool create_graph=False) -> ()",
"aten::backward.TensorList(Tensor[] tensors, Tensor?[]? grad_tensors=None, bool? retain_graph=None, bool create_graph=False) -> ()",
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This was name duplicated before? It's serialization of calls to the unlucky variant that would break, right?

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.

yes but that serialization only happens for the lite interpreter where we don't have bc concerns for models doing autograd yet.

- It seems the JIT schema for aten::backward and the schema in native_functions.yaml diverged on whether the retain_graph/keep_graph parameter takes a `bool` or a `bool?`. Make them identical again.
- Also remove the mutability annotation for the self parameter. This does not make sense together with AliasAnalysisKind::CONSERVATIVE and it triggered an assertion
- After fixing the mutability annotation, we can fix that assertion so that it doesn't exclude aten::backward from its check anymore
- Last but not least, remove the unboxed_only marker from aten::backward. This requires us to add a special case in register_c10_ops.cpp for it, because JIT still has its own implementation.


After this PR, we still have separate implementations for aten::backward for JIT (in register_prim_ops_fulljit.cpp) and for eager mode (in native_functions.yaml), but they share the same signature again.

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

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

- It seems the JIT schema for aten::backward and the schema in native_functions.yaml diverged on whether the retain_graph/keep_graph parameter takes a `bool` or a `bool?`. Make them identical again.
- Also remove the mutability annotation for the self parameter. This does not make sense together with AliasAnalysisKind::CONSERVATIVE and it triggered an assertion
- After fixing the mutability annotation, we can fix that assertion so that it doesn't exclude aten::backward from its check anymore
- Last but not least, remove the unboxed_only marker from aten::backward. This requires us to add a special case in register_c10_ops.cpp for it, because JIT still has its own implementation.
ghstack-source-id: 102324462

Differential Revision: [D21004102](https://our.internmc.facebook.com/intern/diff/D21004102/)
- It seems the JIT schema for aten::backward and the schema in native_functions.yaml diverged on whether the retain_graph/keep_graph parameter takes a `bool` or a `bool?`. Make them identical again.
- Also remove the mutability annotation for the self parameter. This does not make sense together with AliasAnalysisKind::CONSERVATIVE and it triggered an assertion
- After fixing the mutability annotation, we can fix that assertion so that it doesn't exclude aten::backward from its check anymore
- Last but not least, remove the unboxed_only marker from aten::backward. This requires us to add a special case in register_c10_ops.cpp for it, because JIT still has its own implementation.


After this PR, we still have separate implementations for aten::backward for JIT (in register_prim_ops_fulljit.cpp) and for eager mode (in native_functions.yaml), but they share the same signature again.

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

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

- It seems the JIT schema for aten::backward and the schema in native_functions.yaml diverged on whether the retain_graph/keep_graph parameter takes a `bool` or a `bool?`. Make them identical again.
- Also remove the mutability annotation for the self parameter. This does not make sense together with AliasAnalysisKind::CONSERVATIVE and it triggered an assertion
- After fixing the mutability annotation, we can fix that assertion so that it doesn't exclude aten::backward from its check anymore
- Last but not least, remove the unboxed_only marker from aten::backward. This requires us to add a special case in register_c10_ops.cpp for it, because JIT still has its own implementation.
ghstack-source-id: 102351871

Differential Revision: [D21004102](https://our.internmc.facebook.com/intern/diff/D21004102/)
@facebook-github-bot
Copy link
Copy Markdown
Contributor

This pull request has been merged in 31f91d6.

@facebook-github-bot facebook-github-bot deleted the gh/smessmer/205/head branch April 20, 2020 14:17
laurentdupin pushed a commit to laurentdupin/pytorch that referenced this pull request Apr 24, 2026
Summary:
Pull Request resolved: pytorch#36750

- It seems the JIT schema for aten::backward and the schema in native_functions.yaml diverged on whether the retain_graph/keep_graph parameter takes a `bool` or a `bool?`. Make them identical again.
- Also remove the mutability annotation for the self parameter. This does not make sense together with AliasAnalysisKind::CONSERVATIVE and it triggered an assertion
- After fixing the mutability annotation, we can fix that assertion so that it doesn't exclude aten::backward from its check anymore
- Last but not least, remove the unboxed_only marker from aten::backward. This requires us to add a special case in register_c10_ops.cpp for it, because JIT still has its own implementation.
ghstack-source-id: 102351871

Test Plan: waitforsandcastle

Differential Revision: D21004102

fbshipit-source-id: 19bd1adbd8103c214d32e5126671a809adec581e
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.

4 participants