Fix the torch.Stream context manager reentrance#176568
Fix the torch.Stream context manager reentrance#176568guangyey wants to merge 4 commits intogh/guangyey/297/basefrom
Conversation
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/176568
Note: Links to docs will display an error until the docs builds have been completed. ✅ No FailuresAs of commit fad9944 with merge base 6c6cc6b ( This comment was automatically generated by Dr. CI and updates every 15 minutes. |
This PR needs a
|
|
@pytorchbot merge |
Merge failedReason: This PR needs a If not, please add the To add a label, you can comment to pytorchbot, for example For more information, see Details for Dev Infra teamRaised by workflow job |
This PR needs a
|
|
@pytorchbot merge |
Merge failedReason: This PR needs a If not, please add the To add a label, you can comment to pytorchbot, for example For more information, see Details for Dev Infra teamRaised by workflow job |
This PR needs a
|
|
@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 |
|
@pytorchbot cherry-pick --onto release/2.11 --fixes 'Bug fix for the reentrant behavior of the torch.Stream context manager.' -c critical |
# Motivation
This PR aims to fix `torch.Stream` as a context manager nested/reentrance scenario. `torch.cuda.stream` and `torch.xpu.stream` could support these usages.
The following scenario would be fixed with this PR:
```python
import torch
s0 = torch.Stream()
with s0, s0:
pass
```
```python
import torch
s0 = torch.Stream()
s1 = torch.Stream()
with s0, s1:
with s0, s1:
pass
```
# Addtional Context
Fix #176560
Pull Request resolved: #176568
Approved by: https://github.com/albanD
(cherry picked from commit d43570c)
Cherry picking #176568The cherry pick PR is at #176603 and it is linked with issue Bug fix for the reentrant behavior of the torch.Stream context manager.. The following tracker issues are updated: Details for Dev Infra teamRaised by workflow job |
Fix the torch.Stream context manager reentrance (#176568) # Motivation This PR aims to fix `torch.Stream` as a context manager nested/reentrance scenario. `torch.cuda.stream` and `torch.xpu.stream` could support these usages. The following scenario would be fixed with this PR: ```python import torch s0 = torch.Stream() with s0, s0: pass ``` ```python import torch s0 = torch.Stream() s1 = torch.Stream() with s0, s1: with s0, s1: pass ``` # Addtional Context Fix #176560 Pull Request resolved: #176568 Approved by: https://github.com/albanD (cherry picked from commit d43570c) Co-authored-by: Yu, Guangye <guangye.yu@intel.com>
Stack from ghstack (oldest at bottom):
Motivation
This PR aims to fix
torch.Streamas a context manager nested/reentrance scenario.torch.cuda.streamandtorch.xpu.streamcould support these usages.The following scenario would be fixed with this PR:
Addtional Context
Fix #176560