Commit 5d0f639
Make
Many extensions (including pybind helpers) call `Tensor.__dlpack__()` without a stream argument. Before pytorch#150217, `stream=None` behaved like “no cross-stream sync” and was safe inside CUDA Graph capture. After pytorch#150217, `stream=None` maps to the legacy default stream, adding a cross-stream wait that invalidates capture when running on a non-default stream.
See this example
```
import torch
s = torch.cuda.Stream()
x = torch.randn(8, device="cuda")
g = torch.cuda.CUDAGraph()
with torch.cuda.stream(s):
with torch.cuda.graph(g):
_ = x + 1
cap = x.__dlpack__()
_ = torch.utils.dlpack.from_dlpack(cap)
```
This PR partially reverts pytorch#150217 that stream=None defaults to no sync.
Pull Request resolved: pytorch#163242
Approved by: https://github.com/ngimelTensor.__dlpack__(stream=None) capture-safe during CUDA Graph capture (pytorch#163242)1 parent 9d0d98a commit 5d0f639
1 file changed
+7
-4
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1699 | 1699 | | |
1700 | 1700 | | |
1701 | 1701 | | |
1702 | | - | |
| 1702 | + | |
1703 | 1703 | | |
1704 | 1704 | | |
1705 | 1705 | | |
| |||
1717 | 1717 | | |
1718 | 1718 | | |
1719 | 1719 | | |
1720 | | - | |
| 1720 | + | |
1721 | 1721 | | |
1722 | | - | |
| 1722 | + | |
| 1723 | + | |
| 1724 | + | |
| 1725 | + | |
1723 | 1726 | | |
1724 | 1727 | | |
1725 | 1728 | | |
| |||
1797 | 1800 | | |
1798 | 1801 | | |
1799 | 1802 | | |
1800 | | - | |
| 1803 | + | |
1801 | 1804 | | |
1802 | 1805 | | |
1803 | 1806 | | |
| |||
0 commit comments