-
Notifications
You must be signed in to change notification settings - Fork 24.7k
Decomp for aten.dropout #106274
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
Decomp for aten.dropout #106274
Conversation
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/106274
Note: Links to docs will display an error until the docs builds have been completed. ✅ 2 Unrelated FailuresAs of commit 1bbb40a with merge base de8a91f ( BROKEN TRUNK - The following job failed but were present on the merge base:👉 Rebase onto the `viable/strict` branch to avoid these failures
UNSTABLE - The following job failed but was likely due to flakiness present on trunk and has been marked as unstable:
This comment was automatically generated by Dr. CI and updates every 15 minutes. |
5cfd131
to
ac13a72
Compare
ac13a72
to
edef9d8
Compare
I'm down, if you can get it to pass tests... |
edef9d8
to
7401fcc
Compare
7401fcc
to
42f0f77
Compare
42f0f77
to
ec9e960
Compare
torch/_decomp/decompositions.py
Outdated
if train and p != 0: | ||
return aten.native_dropout(input, p, train)[0] | ||
else: | ||
return input |
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 hope this is what the real op does (return the input directly), because this can cause some gnarly bugs if it isn't (especially because you are registering a regular decomp for this op)
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.
@bdhirsh I remember you mentioned that native_dropout
returns a clone in both train and eval branches. Is this 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.
both native_dropout_cpu and native_droput_cuda returns a
output = input.clone();
IIUC, this is different from returning the input direction. This is a difference instance of the tensor with different storage.
I need to update this to return input.clone()
1f9bf22
to
442d74c
Compare
@pytorchbot merge |
Merge startedYour change will be merged once all checks pass (ETA 0-4 Hours). Learn more about merging in the wiki. Questions? Feedback? Please reach out to the PyTorch DevX Team |
Merge failedReason: 1 mandatory check(s) failed. The first few are: Dig deeper by viewing the failures on hud |
442d74c
to
1bbb40a
Compare
@pytorchbot merge |
Merge startedYour change will be merged once all checks pass (ETA 0-4 Hours). Learn more about merging in the wiki. Questions? Feedback? Please reach out to the PyTorch DevX Team |
…108141) A previous PR #106274 decomposes `aten.dropout` and would create a `clone()` when `eval()` or `p=0`. This makes many SDPA-related models fail to match fused_attention pattern matchers. This PR adds new fused_attention pattern matchers with an additional clone to re-enable the SDPA op matching. Pull Request resolved: #108141 Approved by: https://github.com/jgong5, https://github.com/eellison
…108141) A previous PR #106274 decomposes `aten.dropout` and would create a `clone()` when `eval()` or `p=0`. This makes many SDPA-related models fail to match fused_attention pattern matchers. This PR adds new fused_attention pattern matchers with an additional clone to re-enable the SDPA op matching. Pull Request resolved: #108141 Approved by: https://github.com/jgong5, https://github.com/eellison
…ytorch#108141) A previous PR pytorch#106274 decomposes `aten.dropout` and would create a `clone()` when `eval()` or `p=0`. This makes many SDPA-related models fail to match fused_attention pattern matchers. This PR adds new fused_attention pattern matchers with an additional clone to re-enable the SDPA op matching. Pull Request resolved: pytorch#108141 Approved by: https://github.com/jgong5, https://github.com/eellison
…108141) (#108327) A previous PR #106274 decomposes `aten.dropout` and would create a `clone()` when `eval()` or `p=0`. This makes many SDPA-related models fail to match fused_attention pattern matchers. This PR adds new fused_attention pattern matchers with an additional clone to re-enable the SDPA op matching. Pull Request resolved: #108141 Approved by: https://github.com/jgong5, https://github.com/eellison
Summary: #106274 added a decomp for dropout such that for train mode we get `aten.native_dropout`, while for eval mode we get `aten.clone`. This commit makes it such that we get `aten.native_dropout` for both train and eval modes. For eval mode, we let the cloning happen in the aten op itself. The main motivation behind this change is QAT, which needs to swap between `aten.native_dropout(train=True)` and `aten.native_dropout(train=False)` in the graph. This was previously difficult to do since there was no dropout op to match and replace in eval mode. Test Plan: python test/test_ops.py Reviewers: SherlockNoMad, bdhirsh Subscribers: SherlockNoMad, bdhirsh, supriyar [ghstack-poisoned]
Summary: #106274 added a decomp for dropout such that for train mode we get `aten.native_dropout`, while for eval mode we get `aten.clone`. This commit makes it such that we get `aten.native_dropout` for both train and eval modes. For eval mode, we let the cloning happen in the aten op itself. The main motivation behind this change is QAT, which needs to swap between `aten.native_dropout(train=True)` and `aten.native_dropout(train=False)` in the graph. This was previously difficult to do since there was no dropout op to match and replace in eval mode. Test Plan: python test/test_ops.py Reviewers: SherlockNoMad, bdhirsh Subscribers: SherlockNoMad, bdhirsh, supriyar ghstack-source-id: c899961 Pull Request resolved: #109914
…s well" Summary: #106274 added a decomp for dropout such that for train mode we get `aten.native_dropout`, while for eval mode we get `aten.clone`. This commit makes it such that we get `aten.native_dropout` for both train and eval modes. For eval mode, we let the cloning happen in the aten op itself. The main motivation behind this change is QAT, which needs to swap between `aten.native_dropout(train=True)` and `aten.native_dropout(train=False)` in the graph. This was previously difficult to do since there was no dropout op to match and replace in eval mode. Test Plan: python test/test_ops.py Reviewers: SherlockNoMad, bdhirsh Subscribers: SherlockNoMad, bdhirsh, supriyar [ghstack-poisoned]
Summary: #106274 added a decomp for dropout such that for train mode we get `aten.native_dropout`, while for eval mode we get `aten.clone`. This commit makes it such that we get `aten.native_dropout` for both train and eval modes. For eval mode, we let the cloning happen in the aten op itself. The main motivation behind this change is QAT, which needs to swap between `aten.native_dropout(train=True)` and `aten.native_dropout(train=False)` in the graph. This was previously difficult to do since there was no dropout op to match and replace in eval mode. Test Plan: python test/test_ops.py Reviewers: SherlockNoMad, bdhirsh Subscribers: SherlockNoMad, bdhirsh, supriyar [ghstack-poisoned]
…s well" Summary: #106274 added a decomp for dropout such that for train mode we get `aten.native_dropout`, while for eval mode we get `aten.clone`. This commit makes it such that we get `aten.native_dropout` for both train and eval modes. For eval mode, we let the cloning happen in the aten op itself. The main motivation behind this change is QAT, which needs to swap between `aten.native_dropout(train=True)` and `aten.native_dropout(train=False)` in the graph. This was previously difficult to do since there was no dropout op to match and replace in eval mode. Test Plan: python test/test_ops.py Reviewers: SherlockNoMad, bdhirsh Subscribers: SherlockNoMad, bdhirsh, supriyar [ghstack-poisoned]
Summary: #106274 added a decomp for dropout such that for train mode we get `aten.native_dropout`, while for eval mode we get `aten.clone`. This commit makes it such that we get `aten.native_dropout` for both train and eval modes. For eval mode, we let the cloning happen in the aten op itself. The main motivation behind this change is QAT, which needs to swap between `aten.native_dropout(train=True)` and `aten.native_dropout(train=False)` in the graph. This was previously difficult to do since there was no dropout op to match and replace in eval mode. Test Plan: python test/test_ops.py Reviewers: SherlockNoMad, bdhirsh Subscribers: SherlockNoMad, bdhirsh, supriyar [ghstack-poisoned]
Summary: #106274 added a decomp for dropout such that for train mode we get `aten.native_dropout`, while for eval mode we get `aten.clone`. This commit makes it such that we get `aten.native_dropout` for both train and eval modes. For eval mode, we let the cloning happen in the aten op itself. The main motivation behind this change is QAT, which needs to swap between `aten.native_dropout(train=True)` and `aten.native_dropout(train=False)` in the graph. This was previously difficult to do since there was no dropout op to match and replace in eval mode. Test Plan: python test/test_ops.py Reviewers: SherlockNoMad, bdhirsh Subscribers: SherlockNoMad, bdhirsh, supriyar ghstack-source-id: c7635cf Pull Request resolved: #109914
Summary: #106274 added a decomp for dropout such that for train mode we get `aten.native_dropout`, while for eval mode we get `aten.clone`. This commit makes it such that we get `aten.native_dropout` for both train and eval modes. For eval mode, we let the cloning happen in the aten op itself. The main motivation behind this change is QAT, which needs to swap between `aten.native_dropout(train=True)` and `aten.native_dropout(train=False)` in the graph. This was previously difficult to do since there was no dropout op to match and replace in eval mode. Test Plan: python test/test_ops.py Reviewers: SherlockNoMad, bdhirsh Subscribers: SherlockNoMad, bdhirsh, supriyar ghstack-source-id: c7635cf Pull Request resolved: #109914
…s well" Summary: #106274 added a decomp for dropout such that for train mode we get `aten.native_dropout`, while for eval mode we get `aten.clone`. This commit makes it such that we get `aten.native_dropout` for both train and eval modes. For eval mode, we let the cloning happen in the aten op itself. The main motivation behind this change is QAT, which needs to swap between `aten.native_dropout(train=True)` and `aten.native_dropout(train=False)` in the graph. This was previously difficult to do since there was no dropout op to match and replace in eval mode. Test Plan: python test/test_ops.py Reviewers: SherlockNoMad, bdhirsh Subscribers: SherlockNoMad, bdhirsh, supriyar cc avikchaudhuri gmagogsfm zhxchen17 tugsbayasgalan angelayi suo ydwu4 [ghstack-poisoned]
Summary: #106274 added a decomp for dropout such that for train mode we get `aten.native_dropout`, while for eval mode we get `aten.clone`. This commit makes it such that we get `aten.native_dropout` for both train and eval modes. For eval mode, we let the cloning happen in the aten op itself. The main motivation behind this change is QAT, which needs to swap between `aten.native_dropout(train=True)` and `aten.native_dropout(train=False)` in the graph. This was previously difficult to do since there was no dropout op to match and replace in eval mode. Test Plan: python test/test_ops.py Reviewers: SherlockNoMad, bdhirsh Subscribers: SherlockNoMad, bdhirsh, supriyar cc avikchaudhuri gmagogsfm zhxchen17 tugsbayasgalan angelayi suo ydwu4 [ghstack-poisoned]
…s well" Summary: #106274 added a decomp for dropout such that for train mode we get `aten.native_dropout`, while for eval mode we get `aten.clone`. This commit makes it such that we get `aten.native_dropout` for both train and eval modes. For eval mode, we let the cloning happen in the aten op itself. The main motivation behind this change is QAT, which needs to swap between `aten.native_dropout(train=True)` and `aten.native_dropout(train=False)` in the graph. This was previously difficult to do since there was no dropout op to match and replace in eval mode. Test Plan: python test/test_ops.py Reviewers: SherlockNoMad, bdhirsh Subscribers: SherlockNoMad, bdhirsh, supriyar cc avikchaudhuri gmagogsfm zhxchen17 tugsbayasgalan angelayi suo ydwu4 [ghstack-poisoned]
Summary: #106274 added a decomp for dropout such that for train mode we get `aten.native_dropout`, while for eval mode we get `aten.clone`. This commit makes it such that we get `aten.native_dropout` for both train and eval modes. For eval mode, we let the cloning happen in the aten op itself. The main motivation behind this change is QAT, which needs to swap between `aten.native_dropout(train=True)` and `aten.native_dropout(train=False)` in the graph. This was previously difficult to do since there was no dropout op to match and replace in eval mode. Test Plan: python test/test_ops.py Reviewers: SherlockNoMad, bdhirsh Subscribers: SherlockNoMad, bdhirsh, supriyar cc avikchaudhuri gmagogsfm zhxchen17 tugsbayasgalan angelayi suo ydwu4 [ghstack-poisoned]
…s well" Summary: #106274 added a decomp for dropout such that for train mode we get `aten.native_dropout`, while for eval mode we get `aten.clone`. This commit makes it such that we get `aten.native_dropout` for both train and eval modes. For eval mode, we let the cloning happen in the aten op itself. The main motivation behind this change is QAT, which needs to swap between `aten.native_dropout(train=True)` and `aten.native_dropout(train=False)` in the graph. This was previously difficult to do since there was no dropout op to match and replace in eval mode. Test Plan: python test/test_ops.py Reviewers: SherlockNoMad, bdhirsh Subscribers: SherlockNoMad, bdhirsh, supriyar cc avikchaudhuri gmagogsfm zhxchen17 tugsbayasgalan angelayi suo ydwu4 [ghstack-poisoned]
Summary: #106274 added a decomp for dropout such that for train mode we get `aten.native_dropout`, while for eval mode we get `aten.clone`. This commit makes it such that we get `aten.native_dropout` for both train and eval modes. For eval mode, we let the cloning happen in the aten op itself. The main motivation behind this change is QAT, which needs to swap between `aten.native_dropout(train=True)` and `aten.native_dropout(train=False)` in the graph. This was previously difficult to do since there was no dropout op to match and replace in eval mode. Test Plan: python test/test_ops.py Reviewers: SherlockNoMad, bdhirsh Subscribers: SherlockNoMad, bdhirsh, supriyar cc avikchaudhuri gmagogsfm zhxchen17 tugsbayasgalan angelayi suo ydwu4 [ghstack-poisoned]
When exporting dropout with cpu tensor, we get following graph module
In addition, if we export with eval() mode, we will have an empty graph.
However, when exporting with cuda tensor, we got
and exporting under eval() mode will still have a dropout node in graph.
This PR make exporting with CPU tensor also produce aten.native_dropout.
cc @voznesenskym @penguinwu @EikanWang @jgong5 @Guobing-Chen @XiaobingSuper @zhuhaozhe @blzheng @Xia-Weiwen @wenzhe-nrv @jiayisunx @peterbell10 @ipiszy @ngimel @yf225 @chenyang78 @kadeng @muchulee8 @aakhundov