b0556110e5
Remove unsafe PyTorchError constructor ( #154961 )
...
Use libfmt in call sites of PyTorchError.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/154961
Approved by: https://github.com/albanD
2025-07-11 18:22:53 +00:00
b0be30dd79
[19/N] Fix extra warnings brought by clang-tidy-17 ( #144448 )
...
Apply more clang-tidy fixes. There was a bug introduced by #144014 due to incorrect namespace concatenation which is reverted here.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/144448
Approved by: https://github.com/albanD
2025-01-09 15:58:05 +00:00
d0070ca07e
[18/N] Fix extra warnings brought by clang-tidy-17 ( #144014 )
...
Fixes #ISSUE_NUMBER
Pull Request resolved: https://github.com/pytorch/pytorch/pull/144014
Approved by: https://github.com/Skylion007 , https://github.com/albanD
2025-01-08 17:21:55 +00:00
f42cff4e29
[17/N] Fix extra warnings brought by clang-tidy-17 ( #143804 )
...
Fixes #ISSUE_NUMBER
Pull Request resolved: https://github.com/pytorch/pytorch/pull/143804
Approved by: https://github.com/Skylion007
2024-12-25 19:54:42 +00:00
1feae27ed6
[16/N] Fix extra warnings brought by clang-tidy-17 ( #143714 )
...
Fixes #ISSUE_NUMBER
Pull Request resolved: https://github.com/pytorch/pytorch/pull/143714
Approved by: https://github.com/Skylion007 , https://github.com/albanD
2024-12-24 03:29:38 +00:00
f47aac6bc2
Make Context to be Device-agnostic Step by Step (3/N) ( #137578 )
...
Detailed Descriptions:
- Using unified Device-agnostic API to create new generator for accelerator.
- Add deprecated info for GeneratorForPrivateuseone
Pull Request resolved: https://github.com/pytorch/pytorch/pull/137578
Approved by: https://github.com/cyyever , https://github.com/ezyang
2024-12-18 15:12:19 +00:00
075905b7bd
[14/N] Fix extra warnings brought by clang-tidy-17 ( #141644 )
...
Fixes #ISSUE_NUMBER
Pull Request resolved: https://github.com/pytorch/pytorch/pull/141644
Approved by: https://github.com/ezyang
Co-authored-by: Eli Uriegas <1700823+seemethere@users.noreply.github.com >
2024-12-13 06:22:13 +00:00
2f0fe82f6d
Revert "[14/N] Fix extra warnings brought by clang-tidy-17 ( #141644 )"
...
This reverts commit 24a5a2ef258d2b482ded674cdb9555afaf081402.
Reverted https://github.com/pytorch/pytorch/pull/141644 on behalf of https://github.com/clee2000 due to failing internally D67112938 ([comment](https://github.com/pytorch/pytorch/pull/141644#issuecomment-2539602023 ))
2024-12-12 17:43:36 +00:00
24a5a2ef25
[14/N] Fix extra warnings brought by clang-tidy-17 ( #141644 )
...
Fixes #ISSUE_NUMBER
Pull Request resolved: https://github.com/pytorch/pytorch/pull/141644
Approved by: https://github.com/ezyang
2024-12-11 18:40:42 +00:00
2f082e1e56
[13/N] Fix extra warnings brought by clang-tidy-17 ( #140897 )
...
Fixes #ISSUE_NUMBER
Pull Request resolved: https://github.com/pytorch/pytorch/pull/140897
Approved by: https://github.com/ezyang
2024-11-27 00:35:19 +00:00
0f1a88cfba
Make Context to be Device-agnostic Step by Step (2/N) ( #136526 )
...
----
- add new method(getDefaultGenerator, getNewGenerator) into AcceleratorHooksInterface
Pull Request resolved: https://github.com/pytorch/pytorch/pull/136526
Approved by: https://github.com/ezyang , https://github.com/EikanWang
2024-11-18 18:21:17 +00:00
80d0356b11
Revert "Make Context to be Device-agnostic Step by Step (2/N) ( #136526 )"
...
This reverts commit c03324de2dfbbf0006818c86b88c92a3378f46b7.
Reverted https://github.com/pytorch/pytorch/pull/136526 on behalf of https://github.com/ZainRizvi due to This fails to build internally. See D65604944 for more details ([comment](https://github.com/pytorch/pytorch/pull/136526#issuecomment-2465790157 ))
2024-11-08 21:40:10 +00:00
c03324de2d
Make Context to be Device-agnostic Step by Step (2/N) ( #136526 )
...
----
- add new method(getDefaultGenerator, getNewGenerator) into AcceleratorHooksInterface
Pull Request resolved: https://github.com/pytorch/pytorch/pull/136526
Approved by: https://github.com/ezyang , https://github.com/EikanWang
2024-11-07 06:28:47 +00:00
fb36daac9f
[7/N] Fix extra warnings brought by clang-tidy-17 ( #138972 )
...
Fix extra warnings brought by clang-tidy-17
Pull Request resolved: https://github.com/pytorch/pytorch/pull/138972
Approved by: https://github.com/Skylion007
2024-10-26 19:09:47 +00:00
10f16cc7da
Revert "Make Context to be Device-agnostic Step by Step (2/N) ( #136526 )"
...
This reverts commit 8aacbee8e0d6c03096f2ce94b70e2a8fab17ee81.
Reverted https://github.com/pytorch/pytorch/pull/136526 on behalf of https://github.com/wdvr due to this one has failing internal tests, not related to a landrace with #138398 - reverting this one ([comment](https://github.com/pytorch/pytorch/pull/136526#issuecomment-2430460176 ))
2024-10-22 22:53:56 +00:00
af0bc75460
Remove deprecated alias macro(1/3) ( #137556 )
...
**Detailed Descriptions:**
- Remove AT_ERROR Macro
Pull Request resolved: https://github.com/pytorch/pytorch/pull/137556
Approved by: https://github.com/ezyang
2024-10-21 17:32:32 +00:00
8aacbee8e0
Make Context to be Device-agnostic Step by Step (2/N) ( #136526 )
...
----
- add new method(getDefaultGenerator, getNewGenerator) into AcceleratorHooksInterface
Pull Request resolved: https://github.com/pytorch/pytorch/pull/136526
Approved by: https://github.com/ezyang , https://github.com/EikanWang
ghstack dependencies: #138323
2024-10-21 13:51:54 +00:00
9af4e0d2aa
Revert "Make Context to be Device-agnostic Step by Step (2/N) ( #136526 )"
...
This reverts commit a6eb0205225fce7ba7a75d200566613b84aff4e9.
Reverted https://github.com/pytorch/pytorch/pull/136526 on behalf of https://github.com/clee2000 due to breaking internal tests related to MITA, @ezyang has a forward fix? ([comment](https://github.com/pytorch/pytorch/pull/136519#issuecomment-2414588302 ))
2024-10-15 17:19:15 +00:00
a6eb020522
Make Context to be Device-agnostic Step by Step (2/N) ( #136526 )
...
----
- add new method(getDefaultGenerator, getNewGenerator) into AcceleratorHooksInterface
Pull Request resolved: https://github.com/pytorch/pytorch/pull/136526
Approved by: https://github.com/ezyang , https://github.com/EikanWang
2024-10-15 01:53:28 +00:00
33e5921e6b
Revert "Make Context to be Device-agnostic Step by Step (2/N) ( #136526 )"
...
This reverts commit 72ad1b8c6c7c364c1974b82a914876dcdf73af44.
Reverted https://github.com/pytorch/pytorch/pull/136526 on behalf of https://github.com/jovianjaison due to this pr is causing errors internally ([comment](https://github.com/pytorch/pytorch/pull/136519#issuecomment-2405781093 ))
2024-10-10 18:32:16 +00:00
72ad1b8c6c
Make Context to be Device-agnostic Step by Step (2/N) ( #136526 )
...
- add new method(getDefaultGenerator, getNewGenerator) into AcceleratorHooksInterface
Pull Request resolved: https://github.com/pytorch/pytorch/pull/136526
Approved by: https://github.com/ezyang , https://github.com/EikanWang
ghstack dependencies: #136519
2024-10-09 07:34:30 +00:00
8962610247
[BE][clang-format] make macro PyObject_HEAD_INIT(type)
and PyVarObject_HEAD_INIT(type, size)
have its own line ( #136949 )
...
Pull Request resolved: https://github.com/pytorch/pytorch/pull/136949
Approved by: https://github.com/albanD , https://github.com/eqy
ghstack dependencies: #136945
2024-10-02 18:39:22 +00:00
86ad101370
Enable pickling torch._C.Generator
( #126271 )
...
Fixes #71398
Add `__reduce__` and `__setstate__` methods for `torch._C.Generator`.
`__reduce__` returns a tuple of 3 values:
1. `torch.Generator` itself.
2. A one-element tuple containing the `torch.device` to create the `Generator` with, since this cannot be changed after the object is created.
3. The state, a three-element tuple: the initial seed, the offset (or `None` if a CPU `Generator`), and the RNG state tensor.
`__setstate__` calls `manual_seed`, `set_offset` (if not `None`), and `set_state` on each respective element of the state.
Added test demonstrating successful reserialization with cpu and cuda `Generator`s.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/126271
Approved by: https://github.com/ezyang
2024-05-22 14:38:47 +00:00
249e65b92d
Graph-Safe RNG State Exchange for Tensor Parallelism ( #114068 )
...
See #113541
The PR allows for registering and controlling multiple RNG states using indices, ensuring cudagraph-safe operations, and includes both C++ and Python API changes to support this functionality.
cc @eellison @anijain2305 @jansel @ezyang @ptrblck @csarofeen @mcarilli
Pull Request resolved: https://github.com/pytorch/pytorch/pull/114068
Approved by: https://github.com/ezyang , https://github.com/eqy , https://github.com/xuzhao9
2024-03-27 01:14:38 +00:00
4dc09d6aa4
Revert "Graph-Safe RNG State Exchange for Tensor Parallelism ( #114068 )"
...
This reverts commit e9dcda5cba92884be6432cf65a777b8ed708e3d6.
Reverted https://github.com/pytorch/pytorch/pull/114068 on behalf of https://github.com/ezyang due to memory leak in another ci ([comment](https://github.com/pytorch/pytorch/pull/114068#issuecomment-2018044527 ))
2024-03-25 13:49:04 +00:00
e9dcda5cba
Graph-Safe RNG State Exchange for Tensor Parallelism ( #114068 )
...
See #113541
The PR allows for registering and controlling multiple RNG states using indices, ensuring cudagraph-safe operations, and includes both C++ and Python API changes to support this functionality.
cc @eellison @anijain2305 @jansel @ezyang @ptrblck @csarofeen @mcarilli
Pull Request resolved: https://github.com/pytorch/pytorch/pull/114068
Approved by: https://github.com/ezyang
2024-03-21 01:57:08 +00:00
dabb90f2a4
Revert "[Exception] [6/N] Remove use of torch::TypeError ( #117964 )"
...
This reverts commit 87335fabaeca41f9721ba5d5eb7eafcf70b7afad.
Reverted https://github.com/pytorch/pytorch/pull/117964 on behalf of https://github.com/facebook-github-bot due to Diff reverted internally ([comment](https://github.com/pytorch/pytorch/pull/117964#issuecomment-1913079096 ))
2024-01-27 08:44:34 +00:00
87335fabae
[Exception] [6/N] Remove use of torch::TypeError ( #117964 )
...
Pull Request resolved: https://github.com/pytorch/pytorch/pull/117964
Approved by: https://github.com/albanD
2024-01-25 03:35:58 +00:00
91bbcf8c71
[1/N] replace THPUtils_assert with TORCH_CHECK ( #116675 )
...
This PR replaces THPUtils_assert with TORCH_CHECK.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/116675
Approved by: https://github.com/albanD
2024-01-04 11:15:33 +00:00
f4796df914
Add support for generators on the IPU device ( #110704 )
...
This change adds hooks similar to those used on other device types, to allow the Torch to create and use generators provided by the IPU backend.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/110704
Approved by: https://github.com/ezyang
2023-10-06 21:36:14 +00:00
d0ad848aa5
Enable misc clang-tidy checks ( #110283 )
...
This PR enables the misc-XX checks in clang-tidy. Meanwhile, I excluded some of them that require a lot of code changes and have no immediate benefits. Some additional fixes and suppression were also given.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/110283
Approved by: https://github.com/albanD
2023-09-30 10:39:52 +00:00
633bd0765e
Integrate xpu into torch.Generator and torch.seed ( #109866 )
...
Integrate torch.xpu.Generator into torch.Generator
Integrate torch.xpu.seed into torch.seed
Pull Request resolved: https://github.com/pytorch/pytorch/pull/109866
Approved by: https://github.com/ezyang
2023-09-27 17:44:45 +00:00
01fc6466d1
[Reland] [1/N] fix clang-tidy warnings in torch/csrc ( #108114 )
...
Reland of PR #107648 with auto replaced with Py_ssize_t in eval_frame.c. This PR applies fixes to some found issues by clang-tidy in torch/csrc.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/108114
Approved by: https://github.com/Skylion007
2023-08-30 17:11:16 +00:00
8cbf77585d
Revert "[1/N] fix clang-tidy warnings in torch/csrc ( #107648 )"
...
This reverts commit 49eeca00d1e76dd0158758f2c29da6b1d06bf54a.
Reverted https://github.com/pytorch/pytorch/pull/107648 on behalf of https://github.com/osalpekar due to This causes breakages due to underspecified type ([comment](https://github.com/pytorch/pytorch/pull/107648#issuecomment-1696372588 ))
2023-08-28 20:35:12 +00:00
49eeca00d1
[1/N] fix clang-tidy warnings in torch/csrc ( #107648 )
...
Apply fixes to some found issues by clang-tidy in torch/csrc.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/107648
Approved by: https://github.com/Skylion007
2023-08-25 00:30:09 +00:00
ecde622649
Revert "reseed all Generators in Dataloader's _worker_loop() -- via GC ( #107131 )"
...
This reverts commit 42625da5e1c29d710abf6db01c2506898043fdb2.
Reverted https://github.com/pytorch/pytorch/pull/107131 on behalf of https://github.com/facebook-github-bot due to Diff reverted internally ([comment](https://github.com/pytorch/pytorch/pull/107131#issuecomment-1690325745 ))
2023-08-23 17:08:07 +00:00
42625da5e1
reseed all Generators in Dataloader's _worker_loop() -- via GC ( #107131 )
...
Alternative to https://github.com/pytorch/pytorch/pull/107034 , implements @ezyang 's suggestion from https://github.com/pytorch/pytorch/pull/107034#discussion_r1292857201 .
This PR addresses https://fb.workplace.com/groups/pytorch.oss.dev/posts/1699944830430051 and does a bunch of stacked changes:
- Make `Generator` class support GC;this makes all `Generator` instances tracked and accessile through Python's GC.
- Use the GC to retrieve all existing Generator instances in Dataloader's `_worker_loop` and re-seed them: this extends what is already applied to the global/default Generator, which is already re-seeded.
~TODO: a bit of docs and justification, which I'll do if this PR is mergeable.~ -- Done
CC @albanD @ezyang as previously discussed
BC-Breaking Note
-------------------
We now re-seed all `Generator` instances within the `Dataloader` workers' loop to ensure that their RNG is different across workers.
Previously, the RNG of user-defined `Generators` would be the same across workers, which could lead to wrong training procedures. This only affects user-defined `Generators`, not the default `Generator` (which was already re-seeded).
Pull Request resolved: https://github.com/pytorch/pytorch/pull/107131
Approved by: https://github.com/ezyang
2023-08-18 10:23:23 +00:00
1157b4393b
Add const reference and std::move in opportunities detected by clang-tidy ( #105815 )
...
Pull Request resolved: https://github.com/pytorch/pytorch/pull/105815
Approved by: https://github.com/Skylion007
2023-07-25 12:28:14 +00:00
971df458db
Reland of "Python binding to set/get CUDA rng state offset" ( #99565 )
...
Why?
* To reduce the latency of hot path in https://github.com/pytorch/pytorch/pull/97377
Concern - I had to add `set_offset` in all instances of `GeneratorImpl`. I don't know if there is a better way.
~~~~
import torch
torch.cuda.manual_seed(123)
print(torch.cuda.get_rng_state())
torch.cuda.set_rng_state_offset(40)
print(torch.cuda.get_rng_state())
tensor([123, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0], dtype=torch.uint8)
tensor([123, 0, 0, 0, 0, 0, 0, 0, 40, 0, 0, 0, 0, 0,
0, 0], dtype=torch.uint8)
~~~~
Reland of https://github.com/pytorch/pytorch/pull/98965
(cherry picked from commit 8214fe07e8a200e0fe9ca4264bb6fca985c4911e)
Pull Request resolved: https://github.com/pytorch/pytorch/pull/99565
Approved by: https://github.com/anijain2305
2023-04-20 15:42:25 +00:00
bb2cd4a107
Revert "Python binding to set/get CUDA rng state offset ( #98965 )"
...
This reverts commit 8214fe07e8a200e0fe9ca4264bb6fca985c4911e.
Reverted https://github.com/pytorch/pytorch/pull/98965 on behalf of https://github.com/DanilBaibak due to Break internal build
2023-04-19 11:23:32 +00:00
8214fe07e8
Python binding to set/get CUDA rng state offset ( #98965 )
...
Why?
* To reduce the latency of hot path in https://github.com/pytorch/pytorch/pull/97377
Concern - I had to add `set_offset` in all instances of `GeneratorImpl`. I don't know if there is a better way.
~~~~
import torch
torch.cuda.manual_seed(123)
print(torch.cuda.get_rng_state())
torch.cuda.set_rng_state_offset(40)
print(torch.cuda.get_rng_state())
tensor([123, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0], dtype=torch.uint8)
tensor([123, 0, 0, 0, 0, 0, 0, 0, 40, 0, 0, 0, 0, 0,
0, 0], dtype=torch.uint8)
~~~
Pull Request resolved: https://github.com/pytorch/pytorch/pull/98965
Approved by: https://github.com/kulinseth , https://github.com/ezyang
2023-04-18 07:52:21 +00:00
cb3c478069
Revert "refactor(add privateuseone floder in aten/src/ATen): add a PrivateUse… ( #98127 )"
...
This reverts commit 5a537e291d03baf3ea8b23e4102acb10bfd5db23.
Reverted https://github.com/pytorch/pytorch/pull/98127 on behalf of https://github.com/weiwangmeta due to Sorry, our internal code is not ready to take such changes
2023-04-08 05:32:21 +00:00
5a537e291d
refactor(add privateuseone floder in aten/src/ATen): add a PrivateUse… ( #98127 )
...
Add a PrivateUse1 folder to contain all the feature adaptations for PrivateUse1 under Aten,For example GetGeneratorPrivate which is used for the three-party backend to register his own Generator implementation.This makes it easier for us to centrally manage these features, and it will increase the convenience of adaptation for different back-end manufacturers. For more info: https://github.com/pytorch/pytorch/issues/98073
Pull Request resolved: https://github.com/pytorch/pytorch/pull/98127
Approved by: https://github.com/bdhirsh
2023-04-07 03:43:16 +00:00
7038458c5b
Add Generator register for the privateuse1 backend ( #93920 )
...
Fixes #92202
Add generator regiter for the backend of `privateuseone`
module: backend
Pull Request resolved: https://github.com/pytorch/pytorch/pull/93920
Approved by: https://github.com/bdhirsh
2023-03-07 03:43:23 +00:00
b3603f8129
Revert "Deduplicate c10 error and PyTorchError hierarchy ( #87855 )"
...
This reverts commit 34f2d3e6ae56744c20c2f859f97101dff291bbbc.
Reverted https://github.com/pytorch/pytorch/pull/87855 on behalf of https://github.com/osalpekar due to perf regression in quantization tests
2023-01-06 19:56:35 +00:00
688e351970
[MPS] Implement MPSGenerator to enable manual random seeding ( #91348 )
...
This patch adds support for creating torch.Generator for MPS device, and enables its functions such as manual_seed, get_state, and set_state.
Fixes #84288 and #84516
Pull Request resolved: https://github.com/pytorch/pytorch/pull/91348
Approved by: https://github.com/malfet , https://github.com/albanD
2023-01-03 16:01:19 +00:00
34f2d3e6ae
Deduplicate c10 error and PyTorchError hierarchy ( #87855 )
...
Fixes #53370
Pull Request resolved: https://github.com/pytorch/pytorch/pull/87855
Approved by: https://github.com/albanD
2023-01-02 15:53:36 +00:00
30fb2c4aba
[lint] autoformat test/cpp and torch/csrc
...
Let's have some fun.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/78828
Approved by: https://github.com/ezyang
2022-06-11 21:11:16 +00:00
5cae40c169
[pytorch][aten][cuda] move CUDAGeneratorImpl.h to ATen/cuda ( #70650 )
...
Summary:
This patch moves a CUDA-specific file, `CUDAGeneratorImpl.h` to `ATen/cuda` as the following TODO comment in `CUDAGeneratorImpl.h` suggests:
```
// TODO: this file should be in ATen/cuda, not top level
```
Pull Request resolved: https://github.com/pytorch/pytorch/pull/70650
Reviewed By: jianyuh, xw285cornell
Differential Revision: D33414890
Pulled By: shintaro-iwasaki
fbshipit-source-id: 4ff839205f4e4ea4c8767f164d583eb7072f1b8b
2022-01-10 22:27:04 -08:00
b08d64202a
Remove THGeneral ( #69041 )
...
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/69041
`TH_CONCAT_{N}` is still being used by THP so I've moved that into
it's own header but all the compiled code is gone.
Test Plan: Imported from OSS
Reviewed By: anjali411
Differential Revision: D32872477
Pulled By: ngimel
fbshipit-source-id: 06c82d8f96dbcee0715be407c61dfc7d7e8be47a
2021-12-13 16:14:28 -08:00