Guilherme Leobas
f66a159db5
[Set] Raise TypeError if set is called with the wrong number of arguments ( #152990 )
...
Pull Request resolved: https://github.com/pytorch/pytorch/pull/152990
Approved by: https://github.com/anijain2305
ghstack dependencies: #150792 , #152987 , #152988 , #152904 , #152901 , #152902 , #152903 , #152905 , #152906 , #152989 , #152907 , #152908
2025-05-16 14:28:32 +00:00
Guilherme Leobas
5a0ca65555
[Set] Add correct set/frozenset __init__ behavior ( #152908 )
...
Pull Request resolved: https://github.com/pytorch/pytorch/pull/152908
Approved by: https://github.com/anijain2305
ghstack dependencies: #150792 , #152987 , #152988 , #152904 , #152901 , #152902 , #152903 , #152905 , #152906 , #152989 , #152907
2025-05-16 14:28:32 +00:00
Guilherme Leobas
053025494f
[Set] Raise KeyError on empty set.pop() ( #152907 )
...
Pull Request resolved: https://github.com/pytorch/pytorch/pull/152907
Approved by: https://github.com/anijain2305
ghstack dependencies: #150792 , #152987 , #152988 , #152904 , #152901 , #152902 , #152903 , #152905 , #152906 , #152989
2025-05-16 14:28:32 +00:00
Guilherme Leobas
5964cb5eb1
[Set] Update set.union and set.update to support *args ( #152989 )
...
Pull Request resolved: https://github.com/pytorch/pytorch/pull/152989
Approved by: https://github.com/anijain2305
ghstack dependencies: #150792 , #152987 , #152988 , #152904 , #152901 , #152902 , #152903 , #152905 , #152906
2025-05-16 14:28:32 +00:00
Guilherme Leobas
4759922c5e
[Set] Add set.intersection(_update) ( #152906 )
...
Pull Request resolved: https://github.com/pytorch/pytorch/pull/152906
Approved by: https://github.com/anijain2305
ghstack dependencies: #150792 , #152987 , #152988 , #152904 , #152901 , #152902 , #152903 , #152905
2025-05-16 14:28:32 +00:00
Guilherme Leobas
ca96d55322
[Set] Add set.difference(_update) ( #152905 )
...
Pull Request resolved: https://github.com/pytorch/pytorch/pull/152905
Approved by: https://github.com/anijain2305
ghstack dependencies: #150792 , #152987 , #152988 , #152904 , #152901 , #152902 , #152903
2025-05-16 14:28:32 +00:00
Guilherme Leobas
5c6830ced0
[Set] Raise KeyError if elem not contained in the set ( #152903 )
...
Pull Request resolved: https://github.com/pytorch/pytorch/pull/152903
Approved by: https://github.com/anijain2305
ghstack dependencies: #150792 , #152987 , #152988 , #152904 , #152901 , #152902
2025-05-16 14:28:32 +00:00
Guilherme Leobas
574f4c507a
[Set] Add set.issubset and set.issuperset ( #152902 )
...
Pull Request resolved: https://github.com/pytorch/pytorch/pull/152902
Approved by: https://github.com/anijain2305
ghstack dependencies: #150792 , #152987 , #152988 , #152904 , #152901
2025-05-16 14:28:32 +00:00
Guilherme Leobas
5926b7a38f
[Set] Add set.symmetric_difference(_update) ( #152901 )
...
Pull Request resolved: https://github.com/pytorch/pytorch/pull/152901
Approved by: https://github.com/anijain2305
ghstack dependencies: #150792 , #152987 , #152988 , #152904
2025-05-16 14:28:32 +00:00
Guilherme Leobas
fe51ce62ca
[Set] Raise TypeError if number of arguments mismatch ( #152904 )
...
Pull Request resolved: https://github.com/pytorch/pytorch/pull/152904
Approved by: https://github.com/anijain2305
ghstack dependencies: #150792 , #152987 , #152988
2025-05-16 14:28:32 +00:00
Guilherme Leobas
481c345f49
[Set] Raise TypeError if argument is unhashable ( #152988 )
...
Pull Request resolved: https://github.com/pytorch/pytorch/pull/152988
Approved by: https://github.com/anijain2305
ghstack dependencies: #150792 , #152987
2025-05-16 14:28:32 +00:00
Guilherme Leobas
cf7021a0ee
[Set] Handle exception in ConstantVariable operation ( #152987 )
...
Pull Request resolved: https://github.com/pytorch/pytorch/pull/152987
Approved by: https://github.com/williamwen42 , https://github.com/anijain2305
ghstack dependencies: #150792
2025-05-16 14:28:32 +00:00
angelayi
3fe42d4d5d
[export] Dynamo symint support ( #152677 )
...
Basically adds native _IntWrapper support to dynamo. Here's my process of trying to make symint input support work on dynamo, and how I ended up with this approach [(doc)](https://docs.google.com/document/d/1GvNRQd8BnxlMay_hrEVgEta6VUeUW_hcFeRuB7q1nDY/edit?tab=t.0 ).
What I did was, before passing inputs to dynamo.export, I first wrap them with a class, `_IntWrapper`. When processing dynamic shapes, I will then add the corresponding dynamic shape specification to the `dynamism` field stored on the `_IntWrapper`. If there is no dynamism specified, then this will get unwrapped back to an integer. When dynamo tracing, when we encounter an `_IntWrapper`, we will convert this to a symint if the dynamism was specified as `Dim.DYNAMIC/AUTO`. Dynamo will then trace a graph that contains symint inputs, which will get passed to AOTAutograd and so on.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/152677
Approved by: https://github.com/pianpwk
2025-05-16 07:51:50 +00:00
Raymond Li
56e1c236bf
[Dynamo] Catch unserialisable NN modules ( #153503 )
...
Pull Request resolved: https://github.com/pytorch/pytorch/pull/153503
Approved by: https://github.com/c00w , https://github.com/jansel
2025-05-16 02:55:28 +00:00
Animesh Jain
fa8543454a
[dynamo][torch-function] Prevent unnecessary __torch_function__ tracing ( #153551 )
...
Pull Request resolved: https://github.com/pytorch/pytorch/pull/153551
Approved by: https://github.com/mlazos
2025-05-15 14:06:17 +00:00
Animesh Jain
b47be23461
[dynamo][compile-time] Faster inspect getattr_static for torch.Tensor ( #153522 )
...
Pull Request resolved: https://github.com/pytorch/pytorch/pull/153522
Approved by: https://github.com/StrongerXi , https://github.com/jansel
2025-05-15 05:54:15 +00:00
Animesh Jain
8f3d7972ad
[dynamo][compile-time] Cache the function signature to speedup inlining ( #153396 )
...
Pull Request resolved: https://github.com/pytorch/pytorch/pull/153396
Approved by: https://github.com/jansel , https://github.com/StrongerXi
ghstack dependencies: #153333
2025-05-14 14:01:46 +00:00
Guilherme Leobas
a4459cd4e3
Remove property from python_type function ( #152900 )
...
Pull Request resolved: https://github.com/pytorch/pytorch/pull/152900
Approved by: https://github.com/amjames , https://github.com/anijain2305
ghstack dependencies: #153070
2025-05-13 16:26:25 +00:00
PyTorch MergeBot
641e4bee67
Revert "[export][cond] support merging constant ints as unbacked symint ( #152742 )"
...
This reverts commit a805911d15 .
Reverted https://github.com/pytorch/pytorch/pull/152742 on behalf of https://github.com/ydwu4 due to breaking trunk ([comment](https://github.com/pytorch/pytorch/pull/152742#issuecomment-2874410372 ))
2025-05-12 23:06:33 +00:00
Yidi Wu
a805911d15
[export][cond] support merging constant ints as unbacked symint ( #152742 )
...
@pianpwk points out that this will be helpful to address several data dependent issues in huggingface [models](e23705e557/src/diffusers/schedulers/scheduling_euler_ancestral_discrete.py (L332) ) with the following pattern:
```python
idx = if u0 return 0 else return 1
return x[idx]
```
We could preserve the conditional with a cond.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/152742
Approved by: https://github.com/zou3519
2025-05-12 20:26:31 +00:00
Yidi Wu
ceb009baee
[map] always turn on dynamo for map ( #152041 )
...
Summary:
X-link: https://github.com/pytorch/executorch/pull/10409
Reland D72896450
Make map consistent with other control flow ops. After the change, map is able to support accessing closures in the map fn.
Test Plan: See existing tests.
Reviewed By: zou3519
Differential Revision: D73138427
Pull Request resolved: https://github.com/pytorch/pytorch/pull/152041
Approved by: https://github.com/zou3519
2025-05-12 02:10:08 +00:00
PyTorch MergeBot
01bb249978
Revert "has_triton: Use the device interface for detecting Triton availability ( #139171 )"
...
This reverts commit 48bfe9afc7 .
Reverted https://github.com/pytorch/pytorch/pull/139171 on behalf of https://github.com/masnesral due to Performance regression for huggingface ([comment](https://github.com/pytorch/pytorch/pull/139171#issuecomment-2868939790 ))
2025-05-10 14:46:23 +00:00
Ryan Guo
18e13a67ce
[dynamo] Harden torch function dispatchability check for attributes and methods access ( #153082 )
...
See more details in
https://github.com/pytorch/pytorch/issues/151771#issuecomment-2836372110 .
Fixes #151771 .
Differential Revision: [D74342291](https://our.internmc.facebook.com/intern/diff/D74342291 )
Pull Request resolved: https://github.com/pytorch/pytorch/pull/153082
Approved by: https://github.com/mlazos
2025-05-09 16:14:23 +00:00
rzou
2926dd4d8e
Stop proxy-ing autograd.Function.ctx into the graph ( #152621 )
...
The reason why we did this before is because that's how our older
autograd.Function x Dynamo interaction work, but we've since adopted
newer designs that don't actually need the autograd.Function.ctx proxied
into the graph.
We still need a fx.Proxy for the autograd.Function.ctx object, so
whenever we do I create one via discard_graph_changes.
Test Plan:
- existing tests
Pull Request resolved: https://github.com/pytorch/pytorch/pull/152621
Approved by: https://github.com/oulgen
2025-05-08 13:32:54 +00:00
Animesh Jain
34d4363e6d
[dynamo] Fix super and classmethod binding of cls object ( #153105 )
...
Pull Request resolved: https://github.com/pytorch/pytorch/pull/153105
Approved by: https://github.com/jansel
ghstack dependencies: #152883
2025-05-08 12:07:08 +00:00
Animesh Jain
6f6fac6a41
[dynamo] Fix bug in hasattr(tensor, "size") ( #152883 )
...
Fixes https://github.com/pytorch/pytorch/issues/135696
Pull Request resolved: https://github.com/pytorch/pytorch/pull/152883
Approved by: https://github.com/StrongerXi
2025-05-08 01:16:01 +00:00
George White
48bfe9afc7
has_triton: Use the device interface for detecting Triton availability (#139171 )
...
This PR replaces the `has_triton()` global method which was previously used for this task.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/139171
Approved by: https://github.com/jansel , https://github.com/shink
2025-05-07 12:23:10 +00:00
Guilherme Leobas
ae1e51b6ad
Add infra to run CPython tests under Dynamo ( #150787 )
...
Pull Request resolved: https://github.com/pytorch/pytorch/pull/150787
Approved by: https://github.com/zou3519
2025-05-07 04:03:14 +00:00
Yuanhao Ji
5796212d48
[Dynamo] Replace unimplemented with unimplemented_v2 in torch/_dynamo/variables/misc.py [1/2] ( #152274 )
...
Part of #147913
Replace `unimplemented` with`unimplemented_v2` in `torch/_dynamo/variables/misc.py`
Pull Request resolved: https://github.com/pytorch/pytorch/pull/152274
Approved by: https://github.com/williamwen42
Co-authored-by: William Wen <william.wen42@gmail.com>
2025-05-07 03:37:24 +00:00
Animesh Jain
ecd74c953f
[dynamo] Recursively realize the stack_values ( #152853 )
...
Might also fix - https://github.com/pytorch/pytorch/issues/135696
Pull Request resolved: https://github.com/pytorch/pytorch/pull/152853
Approved by: https://github.com/Lucaskabela , https://github.com/mlazos , https://github.com/jansel
2025-05-07 02:36:44 +00:00
PyTorch MergeBot
fcd5e49138
Revert "[dynamo] Recursively realize the stack_values ( #152853 )"
...
This reverts commit 460888f908 .
Reverted https://github.com/pytorch/pytorch/pull/152853 on behalf of https://github.com/malfet due to Looks like it broke inductor tests ([comment](https://github.com/pytorch/pytorch/pull/152853#issuecomment-2854897485 ))
2025-05-06 15:02:57 +00:00
Animesh Jain
460888f908
[dynamo] Recursively realize the stack_values ( #152853 )
...
Might also fix - https://github.com/pytorch/pytorch/issues/135696
Pull Request resolved: https://github.com/pytorch/pytorch/pull/152853
Approved by: https://github.com/Lucaskabela , https://github.com/mlazos , https://github.com/jansel
2025-05-06 06:30:31 +00:00
bobrenjc93
e2eb845313
[ez] fix a bunch of typos in dynamo ( #152886 )
...
Pull Request resolved: https://github.com/pytorch/pytorch/pull/152886
Approved by: https://github.com/williamwen42
2025-05-06 05:13:56 +00:00
PyTorch MergeBot
103fe856e1
Revert "Add infra to run CPython tests under Dynamo ( #150787 )"
...
This reverts commit 7c96dd8f0c .
Reverted https://github.com/pytorch/pytorch/pull/150787 on behalf of https://github.com/huydhn due to Sorry for reverting your change but a failed test is showing up in trunk ([comment](https://github.com/pytorch/pytorch/pull/150787#issuecomment-2852818113 ))
2025-05-06 00:20:02 +00:00
Ryan Guo
51e77f3b30
[dynamo] replace unimplemented with unimplemented_v2 in variables/torch_functions.py ( #151278 )
...
This addresses part of #147913 .
Pull Request resolved: https://github.com/pytorch/pytorch/pull/151278
Approved by: https://github.com/Skylion007 , https://github.com/williamwen42
ghstack dependencies: #151277
2025-05-05 18:45:40 +00:00
Ryan Guo
9e24f9b523
[dynamo] replace unimplemented with unimplemented_v2 in variables/functions.py ( #151277 )
...
This addresses part of #147913 .
Pull Request resolved: https://github.com/pytorch/pytorch/pull/151277
Approved by: https://github.com/Skylion007 , https://github.com/williamwen42
2025-05-05 18:45:40 +00:00
Guilherme Leobas
7c96dd8f0c
Add infra to run CPython tests under Dynamo ( #150787 )
...
Pull Request resolved: https://github.com/pytorch/pytorch/pull/150787
Approved by: https://github.com/zou3519
2025-05-05 17:20:14 +00:00
Matthijs Hogervorst
b117a6c47b
Fix two error messages involving Tensor.dense() ( #152631 )
...
Two error messages in the codebase instruct the user to use `Tendor.dense()`. This method doesn't exist, but `Tensor.to_dense()` does, and this is what the user should be using instead.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/152631
Approved by: https://github.com/jansel
2025-05-04 20:44:08 +00:00
Thomas Bohnstingl
ea12a38668
[associative_scan] Refactoring of input checking and dynamo invocation ( #148657 )
...
This PR is the counterpart of https://github.com/pytorch/pytorch/pull/142125 for the associative_scan operation. The way the input checks are performed and the combine_fn is not invoked in the frontend to check the output trees, but rather dynamo is used for that.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/148657
Approved by: https://github.com/ydwu4
2025-05-02 21:39:28 +00:00
Animesh Jain
9e3fc41060
[invoke_subgraph] rename identifiers to prevent python mangling ( #152581 )
...
Pull Request resolved: https://github.com/pytorch/pytorch/pull/152581
Approved by: https://github.com/BoyuanFeng , https://github.com/zou3519
ghstack dependencies: #152547
2025-05-02 06:46:05 +00:00
Animesh Jain
4649fd17b0
[invoke_subgraph] Unpacked operands ( #152547 )
...
Pull Request resolved: https://github.com/pytorch/pytorch/pull/152547
Approved by: https://github.com/ydwu4 , https://github.com/zou3519
2025-05-02 05:44:46 +00:00
Yidi Wu
13add553b2
[HOP][be] make supports_input_mutation and aliasisng a class field ( #152244 )
...
Pull Request resolved: https://github.com/pytorch/pytorch/pull/152244
Approved by: https://github.com/zou3519
ghstack dependencies: #152072 , #152073
2025-05-01 05:22:02 +00:00
Jason Ansel
15a3f58f91
Return ConstantVariable(None) from WithExitFunctionVariable.exit to prevent NoneType crash inside autocast exception path ( #152503 )
...
Copy of #152013 with PR time benchmarks updated (regressions seem unrelated)
Pull Request resolved: https://github.com/pytorch/pytorch/pull/152503
Approved by: https://github.com/anijain2305 , https://github.com/Skylion007
Co-authored-by: Witold Dziurdz <wdziurdz@habana.ai>
2025-05-01 04:01:24 +00:00
Ryan Guo
0904a182c2
[dynamo] Relax guard introduced when tracing __call__ on user defined object ( #152395 )
...
This relaxes the guard introduced in #100444 (which aggressively guard
on the object id, despite Dynamo is just tracing its `__call__` method.
This allows users to bypass the high compilation time issue in #150706
by compiling transformer blocks only. Without this patch, we'd get lots
of unnecessary recompilation, as the block has difference attention
processor instances.
Compiling blocks only _significantly_ speeds up compilation process
(from ~310s to ~32s), and even speeds up e2e performance for some reason
(7.83s to 7.67s).
Pull Request resolved: https://github.com/pytorch/pytorch/pull/152395
Approved by: https://github.com/anijain2305
ghstack dependencies: #152369
2025-04-30 17:34:21 +00:00
zhxchen17
1d8cdf373b
[dynamo] Guard serialization for NAME_MATCH ( #152332 )
...
Differential Revision: [D73780430](https://our.internmc.facebook.com/intern/diff/D73780430/ )
Pull Request resolved: https://github.com/pytorch/pytorch/pull/152332
Approved by: https://github.com/jansel
ghstack dependencies: #152325 , #152326 , #152327 , #152328 , #152329 , #152330 , #152331
2025-04-29 20:16:00 +00:00
Yuanhao Ji
2fb62f8288
[Dynamo][Typing] Enable typing hints for tx in misc.py ( #152412 )
...
Fixes #ISSUE_NUMBER
Pull Request resolved: https://github.com/pytorch/pytorch/pull/152412
Approved by: https://github.com/cyyever , https://github.com/Skylion007
2025-04-29 13:54:35 +00:00
Yuanhao Ji
f3ef46e5fa
[Dynamo] Replace unimplemented with unimplemented_v2 in torch/_dynamo/variables/iter.py ( #151789 )
...
Part of #147913
Replace `unimplemented` with`unimplemented_v2` in `torch/_dynamo/variables/iter.py`
Pull Request resolved: https://github.com/pytorch/pytorch/pull/151789
Approved by: https://github.com/Skylion007 , https://github.com/williamwen42
2025-04-28 22:56:39 +00:00
Yuanhao Ji
cbcf677223
[Dynamo] Replace unimplemented with unimplemented_v2 in torch/_dynamo/variables/lists.py ( #151873 )
...
Part of #147913
Replace `unimplemented` with`unimplemented_v2` in `torch/_dynamo/variables/lists.py`
Pull Request resolved: https://github.com/pytorch/pytorch/pull/151873
Approved by: https://github.com/williamwen42
Co-authored-by: William Wen <william.wen42@gmail.com>
2025-04-27 11:59:45 +00:00
Yuanhao Ji
0423a7b322
[Dynamo] Replace unimplemented with unimplemented_v2 in torch/_dynamo/variables/nn_module.py ( #151895 )
...
Part of #147913
Replace `unimplemented` with`unimplemented_v2` in `torch/_dynamo/variables/nn_module.py`
Pull Request resolved: https://github.com/pytorch/pytorch/pull/151895
Approved by: https://github.com/williamwen42
Co-authored-by: William Wen <william.wen42@gmail.com>
2025-04-27 11:54:42 +00:00
Zhiyi Zhang
225742838b
Add an additional check to trigger graph break for sparse tensor ( #151897 )
...
Fixes #151522
This PR fixes the issue that Dynamo fails to trigger a graph break for sparse tensors in certain code paths. I added an additional check to handle this case, and it resolves the original problem.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/151897
Approved by: https://github.com/jansel
2025-04-26 21:02:32 +00:00