2c5c793085
[Easy] Add more check for elapsedTime of torch.xxx.Event and torch.Event ( #151404 )
...
As the title stated
**Changes:**
- Add **record**, **query** and **enable_timing** check
- Add related tests
Pull Request resolved: https://github.com/pytorch/pytorch/pull/151404
Approved by: https://github.com/albanD
2025-04-25 20:15:04 +00:00
67f75244ea
Revert "[Easy] Add more check for elapsedTime of torch.xxx.Event and torch.Event ( #151404 )"
...
This reverts commit c91acad73a11825c366c51fb1e91d7e1a47d3f9e.
Reverted https://github.com/pytorch/pytorch/pull/151404 on behalf of https://github.com/ZainRizvi due to Sorry but this is breaking internally. @albanD can you please help it get relanded? To validate the fixes internally, you can follow the instructions here: https://fburl.com/fixing-ghfirst-reverts ([comment](https://github.com/pytorch/pytorch/pull/151404#issuecomment-2830829368 ))
2025-04-25 16:08:27 +00:00
33c75cae0a
Add torch.accelerator.device_index as accelerator's device switch context ( #148864 )
...
# Motivation
We propose adding support for the Python with statement on `torch.accelerator.device_index` to enable device switching functionality. This enhancement would simplify writing device-agnostic code and provide benefits across all accelerators. Its device-specific counterparts include [`torch.cuda.device`](00199acdb8/torch/cuda/__init__.py (L482)
) and [`torch.cuda._DeviceGuard`](00199acdb8/torch/cuda/__init__.py (L469)
).
**Design Philosophy**
It accepts either an `Int` or `None` as input. When `None` is passed, no device switch is performed. Supporting `None` is important for compatibility, as it's possible to encounter `None` values from `torch.device.index`.
Therefore, with this PR, we can do like this
```python
src = 0
dst = 1
# Set src to current device
torch.accelerator.set_device_index(src)
with torch.accelerator.device_index(dst):
# Inside with statement, we set dst to current device
assert torch.accelerator.get_device_index() == dst
# Here the current device should be src
assert torch.accelerator.get_device_index() == src
```
Pull Request resolved: https://github.com/pytorch/pytorch/pull/148864
Approved by: https://github.com/albanD
2025-04-25 09:45:25 +00:00
c91acad73a
[Easy] Add more check for elapsedTime of torch.xxx.Event and torch.Event ( #151404 )
...
As the title stated
**Changes:**
- Add **record**, **query** and **enable_timing** check
- Add related tests
Pull Request resolved: https://github.com/pytorch/pytorch/pull/151404
Approved by: https://github.com/albanD
2025-04-24 01:28:09 +00:00
9374064483
Revert "[Easy] Add more check for elapsedTime of torch.xxx.Event and torch.Event ( #151404 )"
...
This reverts commit 783be8f93248ca3af24b968bdf84188f5a3257d1.
Reverted https://github.com/pytorch/pytorch/pull/151404 on behalf of https://github.com/malfet due to suspected of breaking linux builds and breaks internal tests as well ([comment](https://github.com/pytorch/pytorch/pull/151404#issuecomment-2819041756 ))
2025-04-21 17:11:53 +00:00
48761e9737
Revert "[Easy] Fix the function signature of torch.Event ( #151221 )"
...
This reverts commit 92baeecbdd3fb717880485e529df4efb02627c9d.
Reverted https://github.com/pytorch/pytorch/pull/151221 on behalf of https://github.com/malfet due to This broke rocm tests, see 92baeecbdd (40818271233-box)
([comment](https://github.com/pytorch/pytorch/pull/151221#issuecomment-2816883409 ))
2025-04-19 22:06:24 +00:00
92baeecbdd
[Easy] Fix the function signature of torch.Event ( #151221 )
...
As the title stated.
The difference between declaration and implemention.
declaration:
d5a19e4525/torch/_C/__init__.pyi.in (L157-L162)
Implementation:
d5a19e4525/torch/csrc/Event.cpp (L30-L32)
**Question**: Which one should we choose?
- Change enable_timing to False to be consistent with torch.cuda.Event
- Change enable_timing to True to avoid BC-break
Pull Request resolved: https://github.com/pytorch/pytorch/pull/151221
Approved by: https://github.com/albanD
ghstack dependencies: #151226
2025-04-19 11:56:37 +00:00
783be8f932
[Easy] Add more check for elapsedTime of torch.xxx.Event and torch.Event ( #151404 )
...
As the title stated
**Changes:**
- Add **record**, **query** and **enable_timing** check
- Add related tests
Pull Request resolved: https://github.com/pytorch/pytorch/pull/151404
Approved by: https://github.com/albanD
2025-04-18 15:26:13 +00:00
1ce7969e81
Revert "[Easy] Add more check for elapsedTime of torch.xxx.Event and torch.Event ( #151404 )"
...
This reverts commit 90c5b86cd8fcbbe6ee7c46ad17a05767f884794b.
Reverted https://github.com/pytorch/pytorch/pull/151404 on behalf of https://github.com/clee2000 due to broke a cpp extension test? test_cpp_extensions_stream_and_event.py::TestCppExtensionStreamAndEvent::test_stream_event [GH job link](https://github.com/pytorch/pytorch/actions/runs/14519277500/job/40736981315 ) [HUD commit link](90c5b86cd8
), bad TD ([comment](https://github.com/pytorch/pytorch/pull/151404#issuecomment-2813649667 ))
2025-04-17 17:45:41 +00:00
90c5b86cd8
[Easy] Add more check for elapsedTime of torch.xxx.Event and torch.Event ( #151404 )
...
As the title stated
**Changes:**
- Add **record**, **query** and **enable_timing** check
- Add related tests
Pull Request resolved: https://github.com/pytorch/pytorch/pull/151404
Approved by: https://github.com/albanD
2025-04-17 15:30:12 +00:00
9092dd2e82
[CI] Disable some tests that are failing in periodic ( #150059 )
...
Disabling some tests to restore periodic
nogpu avx512 timeout:
59f14d19ae (38492953496-box)
profiler failure: 7ae0ce6360 (38461255009-box)
test_accelerator failure:
87bfd66c3c (39476723746-box)
origin: 146098
test_overrides failure:
bf752c36da (39484562957-box)
origin: 146098
inductor cpu repro:
bb9c426024 (38447525659-box)
functorch eager transforms:
8f858e226b (39488068620-box)
f2cea01f71 (39555064878)
b5281a4a18 (39599355600)
either 148288 or 148261?
2ec9aceaeb/1
Pull Request resolved: https://github.com/pytorch/pytorch/pull/150059
Approved by: https://github.com/ZainRizvi , https://github.com/atalman , https://github.com/malfet
2025-03-28 20:31:32 +00:00
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
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
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
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
1b3f8b7589
Revert "[RELAND] Add UTs for accelerator device-agnostic runtime APIs ( #133572 )"
...
This reverts commit 209119424922b135fef39aba1f25da3b67f5879a.
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
cd50bd8477
Revert "[BE][accelerator] formalize API name {current,set}_device_{idx => index}
( #140542 )"
...
This reverts commit fb02b40d27737213e0547dec0e30977dfc50f2f3.
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
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
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
a1c6cf7e9f
Revert "Add UTs for accelerator device-agnostic runtime APIs ( #133572 )"
...
This reverts commit 952514f0c8d8ff2e1719e0ca82b0d178a5c5ff45.
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
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