Yu, Guangye
719938c77f
Generalize pin memory logic for accelerator when non blocking copy happened ( #143783 )
...
# Motivation
fix https://github.com/pytorch/pytorch/issues/143641
Generalize pin memory logic for accelerator when non-blocking copy happened. Each accelerator has its implementation on `empty_strided`. The accelerator which doesn't have pin memory mechanism could ignore or mimic when pin_out is True.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/143783
Approved by: https://github.com/EikanWang , https://github.com/albanD
ghstack dependencies: #144959
2025-01-23 03:43:05 +00:00
Yu, Guangye
6de110b862
Support with statement on torch.Stream ( #140138 )
...
# Motivation
We propose to support Python with statement on `torch.Stream`. This is a benefit for all accelerators when writing device-agnostic code. The device-specific stream will also be supported because they are generally derived from `torch.Stream`.
With this PR, we can do like this
```python
s1= torch.Stream()
# Set s1 to the current stream
torch.accelerator.set_stream(s1)
with torch.Stream() as s2:
# Inside with statement, we set s2 to the current stream
assert torch.accelerator.current_stream() == s2
# Here the current stream should be s1
assert torch.accelerator.current_stream() == s1
```
Pull Request resolved: https://github.com/pytorch/pytorch/pull/140138
Approved by: https://github.com/albanD
2025-01-10 02:05:19 +00:00
Dmitry Rogozhkin
7314cf44ae
torch/accelerator: fix device type comparison ( #143541 )
...
This was failing without the fix:
```
python -c 'import torch; d=torch.device("xpu:0"); torch.accelerator.current_stream(d)'
```
with:
```
ValueError: xpu doesn't match the current accelerator xpu.
```
CC: @guangyey, @EikanWang
Pull Request resolved: https://github.com/pytorch/pytorch/pull/143541
Approved by: https://github.com/guangyey , https://github.com/albanD
2024-12-23 10:54:53 +00:00
Yu, Guangye
45ac4ebf15
[RELAND] Add UTs for accelerator device-agnostic runtime APIs ( #133572 )
...
# Motivation
This PR intends to add UTs for accelerator device-agnostic APIs.
# Additional Context
This PR is relanded. It is reverted because `torch.Event` doesn't support mps backend. We have fixed it in https://github.com/pytorch/pytorch/pull/142468 . The previous commit is 952514f0c8
Pull Request resolved: https://github.com/pytorch/pytorch/pull/133572
Approved by: https://github.com/EikanWang , https://github.com/albanD
ghstack dependencies: #143171
2024-12-16 02:18:41 +00:00
PyTorch MergeBot
1b3f8b7589
Revert "[RELAND] Add UTs for accelerator device-agnostic runtime APIs ( #133572 )"
...
This reverts commit 2091194249 .
Reverted https://github.com/pytorch/pytorch/pull/133572 on behalf of https://github.com/huydhn due to Sorry for reverting your change but the new test is still very flaky on MacOS even when it does not segfault anymore ([comment](https://github.com/pytorch/pytorch/pull/133572#issuecomment-2537256522 ))
2024-12-11 21:47:18 +00:00
PyTorch MergeBot
cd50bd8477
Revert "[BE][accelerator] formalize API name {current,set}_device_{idx => index} ( #140542 )"
...
This reverts commit fb02b40d27 .
Reverted https://github.com/pytorch/pytorch/pull/140542 on behalf of https://github.com/huydhn due to Sorry for reverting your change, but I need to revert this in order to revert https://github.com/pytorch/pytorch/pull/133572#issuecomment-2537204202 due to a conflict ([comment](https://github.com/pytorch/pytorch/pull/140542#issuecomment-2537253665 ))
2024-12-11 21:44:23 +00:00
Xuehai Pan
fb02b40d27
[BE][accelerator] formalize API name {current,set}_device_{idx => index} ( #140542 )
...
Pull Request resolved: https://github.com/pytorch/pytorch/pull/140542
Approved by: https://github.com/guangyey , https://github.com/albanD
2024-12-11 17:57:56 +00:00
Yu, Guangye
2091194249
[RELAND] Add UTs for accelerator device-agnostic runtime APIs ( #133572 )
...
# Motivation
This PR intends to add UTs for accelerator device-agnostic APIs.
# Additional Context
This PR is relanded. It is reverted because `torch.Event` doesn't support mps backend. We have fixed it in https://github.com/pytorch/pytorch/pull/142468 . The previous commit is 952514f0c8
Pull Request resolved: https://github.com/pytorch/pytorch/pull/133572
Approved by: https://github.com/EikanWang , https://github.com/albanD
ghstack dependencies: #142468
2024-12-11 02:04:52 +00:00
PyTorch MergeBot
a1c6cf7e9f
Revert "Add UTs for accelerator device-agnostic runtime APIs ( #133572 )"
...
This reverts commit 952514f0c8 .
Reverted https://github.com/pytorch/pytorch/pull/133572 on behalf of https://github.com/malfet due to Sorry for reverting your PR, but it segfaults on MacOS ([comment](https://github.com/pytorch/pytorch/pull/133572#issuecomment-2530354401 ))
2024-12-10 04:42:55 +00:00
Yu, Guangye
952514f0c8
Add UTs for accelerator device-agnostic runtime APIs ( #133572 )
...
Pull Request resolved: https://github.com/pytorch/pytorch/pull/133572
Approved by: https://github.com/EikanWang , https://github.com/albanD
2024-12-07 13:14:10 +00:00