1ad08c7a5b
Revert "[dynamo][itertools] refactor itertools.chain
and itertools.chain.from_iterable
to use polyfills ( #133864 )"
...
This reverts commit 1b703669576223024eb84a76c53b7ec5ed8bb270.
Reverted https://github.com/pytorch/pytorch/pull/133864 on behalf of https://github.com/ZainRizvi due to This is still failing internally with the same error about 'Graph break due to unsupported builtin _functools.reduce' ([comment](https://github.com/pytorch/pytorch/pull/133778#issuecomment-2321787968 ))
2024-08-30 16:06:10 +00:00
8aa44e14cf
Revert "[dynamo] refactor builtins.enumerate
to use polyfill ( #133894 )"
...
This reverts commit a2566adfb6064235db6d950568435fb6ef58a598.
Reverted https://github.com/pytorch/pytorch/pull/133894 on behalf of https://github.com/ZainRizvi due to This is still failing internally with the same error about 'Graph break due to unsupported builtin _functools.reduce' ([comment](https://github.com/pytorch/pytorch/pull/133778#issuecomment-2321787968 ))
2024-08-30 16:06:09 +00:00
10c31e96df
Revert "[dynamo][itertools] refactor itertools.islice
to use polyfill ( #133876 )"
...
This reverts commit 7d12e6dceb94a221288f21c0e79ce8ca667d657a.
Reverted https://github.com/pytorch/pytorch/pull/133876 on behalf of https://github.com/ZainRizvi due to This is still failing internally with the same error about 'Graph break due to unsupported builtin _functools.reduce' ([comment](https://github.com/pytorch/pytorch/pull/133778#issuecomment-2321787968 ))
2024-08-30 16:06:09 +00:00
7d12e6dceb
[dynamo][itertools] refactor itertools.islice
to use polyfill ( #133876 )
...
Pull Request resolved: https://github.com/pytorch/pytorch/pull/133876
Approved by: https://github.com/jansel
ghstack dependencies: #133769 , #133778 , #133779 , #133864 , #133894
2024-08-29 20:56:16 +00:00
a2566adfb6
[dynamo] refactor builtins.enumerate
to use polyfill ( #133894 )
...
Pull Request resolved: https://github.com/pytorch/pytorch/pull/133894
Approved by: https://github.com/jansel
ghstack dependencies: #133769 , #133778 , #133779 , #133864
2024-08-29 20:56:16 +00:00
1b70366957
[dynamo][itertools] refactor itertools.chain
and itertools.chain.from_iterable
to use polyfills ( #133864 )
...
Pull Request resolved: https://github.com/pytorch/pytorch/pull/133864
Approved by: https://github.com/jansel
ghstack dependencies: #133769 , #133778 , #133779
2024-08-29 20:56:16 +00:00
eaa449fbf0
[dynamo] simplify implementation for builtins.sum
( #133779 )
...
Pull Request resolved: https://github.com/pytorch/pytorch/pull/133779
Approved by: https://github.com/jansel , https://github.com/anijain2305
ghstack dependencies: #133769 , #133778
2024-08-29 20:56:16 +00:00
b5f1ffa7ab
[dynamo] simplify implementation for functools.reduce
( #133778 )
...
Pull Request resolved: https://github.com/pytorch/pytorch/pull/133778
Approved by: https://github.com/jansel , https://github.com/anijain2305
ghstack dependencies: #133769
2024-08-29 20:56:16 +00:00
e09324e7da
[dynamo] simplify polyfill registration for builtins.all
and builtins.any
( #133769 )
...
Pull Request resolved: https://github.com/pytorch/pytorch/pull/133769
Approved by: https://github.com/jansel
2024-08-29 20:56:16 +00:00
4811dc3de9
Revert "[dynamo] simplify polyfill registration for builtins.all
and builtins.any
( #133769 )"
...
This reverts commit cc3a76edbac4a48381db6ccc44a83927f80c545b.
Reverted https://github.com/pytorch/pytorch/pull/133769 on behalf of https://github.com/ZainRizvi due to Sorry but this has been discovered to be causing a performance regression internally ([comment](https://github.com/pytorch/pytorch/pull/133769#issuecomment-2316620213 ))
2024-08-29 03:00:47 +00:00
50e90d7203
Revert "[dynamo] simplify implementation for functools.reduce
( #133778 )"
...
This reverts commit 6c0b15e3828b8e2a0bd726a3e5d4e98c8ced5efe.
Reverted https://github.com/pytorch/pytorch/pull/133778 on behalf of https://github.com/ZainRizvi due to Sorry, but this breaks internal tests because of using functools ([comment](https://github.com/pytorch/pytorch/pull/133778#issuecomment-2310445169 ))
2024-08-26 15:16:17 +00:00
472c7cf962
Revert "[dynamo] simplify implementation for builtins.sum
( #133779 )"
...
This reverts commit 8d90392fb02ce5e6854e6b4dbcdc4a7bbd55f8e2.
Reverted https://github.com/pytorch/pytorch/pull/133779 on behalf of https://github.com/ZainRizvi due to Sorry, but this breaks internal tests because of using functools ([comment](https://github.com/pytorch/pytorch/pull/133778#issuecomment-2310445169 ))
2024-08-26 15:16:17 +00:00
8d90392fb0
[dynamo] simplify implementation for builtins.sum
( #133779 )
...
Pull Request resolved: https://github.com/pytorch/pytorch/pull/133779
Approved by: https://github.com/jansel
ghstack dependencies: #133769 , #133778
2024-08-23 10:10:19 +00:00
6c0b15e382
[dynamo] simplify implementation for functools.reduce
( #133778 )
...
Pull Request resolved: https://github.com/pytorch/pytorch/pull/133778
Approved by: https://github.com/jansel
ghstack dependencies: #133769
2024-08-23 09:10:44 +00:00
cc3a76edba
[dynamo] simplify polyfill registration for builtins.all
and builtins.any
( #133769 )
...
Pull Request resolved: https://github.com/pytorch/pytorch/pull/133769
Approved by: https://github.com/jansel
2024-08-23 09:05:24 +00:00
b6abac68ec
[BE][dynamo] reorganize polyfill module hierarchy ( #133977 )
...
Changes:
1. Move `polyfill.py` -> `polyfills/__init__.py`. It can be used as `polyfill.xxx` -> `polyfills.xxx`.
2. Move submodule loading from `polyfills/__init__.py` to `polyfills/loader.py`.
Merge `polyfill.py` and `polyfills/` packages. Each polyfill module have its own namespace for better code organization.
The ultimate goal is make `polyfills/__init__.py` empty and all polyfill functions move to its own namespace.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/133977
Approved by: https://github.com/jansel
2024-08-22 16:42:29 +00:00
88ead0afc6
Revert "[dynamo] simplify polyfill registration for builtins.all
and builtins.any
( #133769 )"
...
This reverts commit 178e8563b8a44243a6f69f3d257d9a3aab71b2c5.
Reverted https://github.com/pytorch/pytorch/pull/133769 on behalf of https://github.com/ZainRizvi due to breaking main windows cpu tests - this stack still causes that windows test to fail ([comment](https://github.com/pytorch/pytorch/pull/133712#issuecomment-2299776241 ))
2024-08-20 21:14:45 +00:00
3fa874abbe
Revert "[dynamo] simplify implementation for functools.reduce
( #133778 )"
...
This reverts commit 37b4bc60a4ec65858044983a36577912fb9b4651.
Reverted https://github.com/pytorch/pytorch/pull/133778 on behalf of https://github.com/ZainRizvi due to breaking main windows cpu tests - this stack still causes that windows test to fail ([comment](https://github.com/pytorch/pytorch/pull/133712#issuecomment-2299776241 ))
2024-08-20 21:14:45 +00:00
98e6a1d8ff
Revert "[dynamo] simplify implementation for builtins.sum
( #133779 )"
...
This reverts commit 3f58a8051a92470dbd254859322a7eb085a8f243.
Reverted https://github.com/pytorch/pytorch/pull/133779 on behalf of https://github.com/ZainRizvi due to breaking main windows cpu tests - this stack still causes that windows test to fail ([comment](https://github.com/pytorch/pytorch/pull/133712#issuecomment-2299776241 ))
2024-08-20 21:14:44 +00:00
b03381cac2
[dynamo] support cls.__flags__
( #133970 )
...
Pull Request resolved: https://github.com/pytorch/pytorch/pull/133970
Approved by: https://github.com/jansel
ghstack dependencies: #133969
2024-08-20 20:03:31 +00:00
5229b52bf2
[dynamo] support cls.__base__
( #133969 )
...
Pull Request resolved: https://github.com/pytorch/pytorch/pull/133969
Approved by: https://github.com/jansel
2024-08-20 20:03:31 +00:00
3f58a8051a
[dynamo] simplify implementation for builtins.sum
( #133779 )
...
Pull Request resolved: https://github.com/pytorch/pytorch/pull/133779
Approved by: https://github.com/jansel
ghstack dependencies: #133712 , #133769 , #133778
2024-08-20 19:48:57 +00:00
37b4bc60a4
[dynamo] simplify implementation for functools.reduce
( #133778 )
...
Pull Request resolved: https://github.com/pytorch/pytorch/pull/133778
Approved by: https://github.com/jansel
ghstack dependencies: #133712 , #133769
2024-08-20 19:48:57 +00:00
178e8563b8
[dynamo] simplify polyfill registration for builtins.all
and builtins.any
( #133769 )
...
Pull Request resolved: https://github.com/pytorch/pytorch/pull/133769
Approved by: https://github.com/jansel
ghstack dependencies: #133712
2024-08-20 19:48:57 +00:00
91fd270535
Revert "[dynamo] simplify polyfill registration for builtins.all
and builtins.any
( #133769 )"
...
This reverts commit 59ca56e56ca3e2f6dd80db57079725cf61f06810.
Reverted https://github.com/pytorch/pytorch/pull/133769 on behalf of https://github.com/jeanschmidt due to breaking main windows cpu tests - reverting them all, so we can identify the culprit with more calmness ([comment](https://github.com/pytorch/pytorch/pull/133712#issuecomment-2298528797 ))
2024-08-20 10:34:41 +00:00
5109c5ef23
Revert "[dynamo] simplify implementation for functools.reduce
( #133778 )"
...
This reverts commit ff9be0eda99c59cdbcc269853168657de93043c7.
Reverted https://github.com/pytorch/pytorch/pull/133778 on behalf of https://github.com/jeanschmidt due to breaking main windows cpu tests - reverting them all, so we can identify the culprit with more calmness ([comment](https://github.com/pytorch/pytorch/pull/133712#issuecomment-2298528797 ))
2024-08-20 10:34:41 +00:00
08b5e07e6c
Revert "[dynamo] simplify implementation for builtins.sum
( #133779 )"
...
This reverts commit 1fdeb4e32918017ee3a712e0bba86e8482fa293b.
Reverted https://github.com/pytorch/pytorch/pull/133779 on behalf of https://github.com/jeanschmidt due to breaking main windows cpu tests ([comment](https://github.com/pytorch/pytorch/pull/133779#issuecomment-2298285206 ))
2024-08-20 08:33:29 +00:00
1fdeb4e329
[dynamo] simplify implementation for builtins.sum
( #133779 )
...
Pull Request resolved: https://github.com/pytorch/pytorch/pull/133779
Approved by: https://github.com/jansel
ghstack dependencies: #133712 , #133769 , #133778
2024-08-19 22:14:34 +00:00
ff9be0eda9
[dynamo] simplify implementation for functools.reduce
( #133778 )
...
Pull Request resolved: https://github.com/pytorch/pytorch/pull/133778
Approved by: https://github.com/jansel
ghstack dependencies: #133712 , #133769
2024-08-19 22:14:33 +00:00
59ca56e56c
[dynamo] simplify polyfill registration for builtins.all
and builtins.any
( #133769 )
...
Pull Request resolved: https://github.com/pytorch/pytorch/pull/133769
Approved by: https://github.com/jansel
ghstack dependencies: #133712
2024-08-19 22:14:33 +00:00
08f14d5492
[refactor][dynamo][side-effects] Helper function for __new__ for user defined class ( #133799 )
...
Pull Request resolved: https://github.com/pytorch/pytorch/pull/133799
Approved by: https://github.com/jansel
ghstack dependencies: #133745 , #133747 , #133746
2024-08-19 17:21:48 +00:00
fed6096e73
[dynamo] Support object.__new__ call ( #133746 )
...
Pull Request resolved: https://github.com/pytorch/pytorch/pull/133746
Approved by: https://github.com/Skylion007 , https://github.com/jansel
ghstack dependencies: #133745 , #133747
2024-08-18 07:18:52 +00:00
4dc9795ebf
[refactor][easy] Directly call var_getattr method for PythonModuleVariable ( #133745 )
...
Pull Request resolved: https://github.com/pytorch/pytorch/pull/133745
Approved by: https://github.com/yanboliang
2024-08-17 05:30:01 +00:00
e554f71d7e
Implement filter in dynamo ( #131674 )
...
Fixes https://github.com/pytorch/pytorch/issues/128944
Pull Request resolved: https://github.com/pytorch/pytorch/pull/131674
Approved by: https://github.com/amjames , https://github.com/jansel
2024-08-14 14:54:13 +00:00
80ed3e9ccd
s/dipatch/dispatch/g ( #133192 )
...
Signed-off-by: Edward Z. Yang <ezyang@meta.com >
Pull Request resolved: https://github.com/pytorch/pytorch/pull/133192
Approved by: https://github.com/albanD
2024-08-12 20:26:58 +00:00
01cdcbf7c8
[dynamo] revert map/zip iterator related changes ( #132528 )
...
Need to revert due to internal hangs: S437700
This reverts commit b6c1490cc02316ffe85e5ae74651d80f0158ba64.
Revert "[dynamo] implement IteratorVariable and polyfill fallbacks for enumerate (#131725 )"
This reverts commit 2576dbbc35d66e8e9ed6cb12216ccc424cb87ec3.
Revert "[dynamo] add itertools repeat/count bytecode reconstruction (#131716 )"
This reverts commit 35b4de32fafc5ad024c20ef1275711bffc557ae9.
Revert "[dynamo] add lazy IteratorVariable implementations for map and zip (#131413 )"
This reverts commit 7d282d87550787d8269593093519c2ad7c5032cd.
Fixes #ISSUE_NUMBER
Pull Request resolved: https://github.com/pytorch/pytorch/pull/132528
Approved by: https://github.com/ZainRizvi
2024-08-04 18:46:55 +00:00
6e79932543
Add basic mypy annotations to dynamo ( #132415 )
...
Pull Request resolved: https://github.com/pytorch/pytorch/pull/132415
Approved by: https://github.com/XuehaiPan , https://github.com/jamesjwu
2024-08-04 18:43:36 +00:00
3558a8cf4a
Revert "Add basic mypy annotations to dynamo ( #132415 )"
...
This reverts commit 71e22e0959eb8d5a66833bf5c6b5903536a5bef1.
Reverted https://github.com/pytorch/pytorch/pull/132415 on behalf of https://github.com/ZainRizvi due to Sorry, this PR has entered a weird state in the diff train. Trying to revert it to skip it, and then we can try relanding it ([comment](https://github.com/pytorch/pytorch/pull/132415#issuecomment-2267631785 ))
2024-08-04 18:39:29 +00:00
0a25666f92
Revert "[dynamo] revert map/zip iterator related changes ( #132528 )"
...
This reverts commit e81e74ca6cb45e1ab831ddfe9a2ba5c7e17fa03f.
Reverted https://github.com/pytorch/pytorch/pull/132528 on behalf of https://github.com/ZainRizvi due to This stack entered a weird state in the diff train. Reverting and relanding to clean the state ([comment](https://github.com/pytorch/pytorch/pull/132528#issuecomment-2267628475 ))
2024-08-04 18:26:09 +00:00
06581c277a
[dynamo][stable-diffusion] Support dict(obj) on constrained subclasses of dict and OrderedDict ( #132558 )
...
Pull Request resolved: https://github.com/pytorch/pytorch/pull/132558
Approved by: https://github.com/jansel
2024-08-03 06:31:00 +00:00
e81e74ca6c
[dynamo] revert map/zip iterator related changes ( #132528 )
...
Need to revert due to internal hangs: S437700
This reverts commit b6c1490cc02316ffe85e5ae74651d80f0158ba64.
Revert "[dynamo] implement IteratorVariable and polyfill fallbacks for enumerate (#131725 )"
This reverts commit 2576dbbc35d66e8e9ed6cb12216ccc424cb87ec3.
Revert "[dynamo] add itertools repeat/count bytecode reconstruction (#131716 )"
This reverts commit 35b4de32fafc5ad024c20ef1275711bffc557ae9.
Revert "[dynamo] add lazy IteratorVariable implementations for map and zip (#131413 )"
This reverts commit 7d282d87550787d8269593093519c2ad7c5032cd.
Fixes #ISSUE_NUMBER
Pull Request resolved: https://github.com/pytorch/pytorch/pull/132528
Approved by: https://github.com/ZainRizvi
2024-08-02 19:40:57 +00:00
56f2917bef
[dynamo] Bugfix for recently added str handler ( #132461 )
...
There is probably more work to improve support. But this is hot fix to not fail on `.__func__`
Pull Request resolved: https://github.com/pytorch/pytorch/pull/132461
Approved by: https://github.com/williamwen42
ghstack dependencies: #132425
2024-08-02 13:16:39 +00:00
5ea0f51187
[Dynamo] Support abc.MutableMapping.get ( #132363 )
...
Pull Request resolved: https://github.com/pytorch/pytorch/pull/132363
Approved by: https://github.com/anijain2305 , https://github.com/mlazos
2024-08-02 04:17:35 +00:00
50ed6ce277
Support built-in id function for TensorVariable on parameters ( #130100 )
...
Fixes #130087
This patch tries to provide a built-in id function implementation for TensorVariable when the id function is called on tensors like module parameters. The id function call on intermediate tensors is not supported.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/130100
Approved by: https://github.com/anijain2305
2024-08-02 01:19:25 +00:00
71e22e0959
Add basic mypy annotations to dynamo ( #132415 )
...
Pull Request resolved: https://github.com/pytorch/pytorch/pull/132415
Approved by: https://github.com/XuehaiPan , https://github.com/jamesjwu
2024-08-01 20:14:25 +00:00
e74ba1b34a
[BE][Easy][15/19] enforce style for empty lines in import segments in torch/_d*/
( #129767 )
...
See https://github.com/pytorch/pytorch/pull/129751#issue-2380881501 . Most changes are auto-generated by linter.
You can review these PRs via:
```bash
git diff --ignore-all-space --ignore-blank-lines HEAD~1
```
Pull Request resolved: https://github.com/pytorch/pytorch/pull/129767
Approved by: https://github.com/anijain2305
2024-07-31 21:18:11 +00:00
bdd7a0322d
[Dynamo] Fix - str
handler for UserDefinedObjectVariable ( #130506 )
...
Fixes #130301
Adjusted the call_str method to handle str conversion for UserDefinedObjectVariable.
Attempt in a clean branch for unrelated test errors.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/130506
Approved by: https://github.com/oulgen , https://github.com/anijain2305
2024-07-31 16:39:59 +00:00
03e058189e
[dynamo] Support dict unpack of MutableMapping objects ( #131961 )
...
Fixes https://github.com/pytorch/pytorch/issues/128067
The basic functionality was alredy introduced earlier. This just ensures
that we support UserDefinedObjectVariable.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/131961
Approved by: https://github.com/williamwen42 , https://github.com/mlazos , https://github.com/yanboliang
ghstack dependencies: #131827 , #131956
2024-07-30 05:49:58 +00:00
2576dbbc35
[dynamo] implement IteratorVariable and polyfill fallbacks for enumerate ( #131725 )
...
Fixes https://github.com/pytorch/pytorch/issues/112794 .
Pull Request resolved: https://github.com/pytorch/pytorch/pull/131725
Approved by: https://github.com/anijain2305
ghstack dependencies: #131413 , #131716
2024-07-26 17:17:09 +00:00
7d282d8755
[dynamo] add lazy IteratorVariable implementations for map and zip ( #131413 )
...
Fixes https://github.com/pytorch/pytorch/issues/130750 .
Repro of lazy/eager `map` discrepancy without `islice`:
```python
def fn(a, b):
y = 1
def f(x):
nonlocal y
y += 1
return x
l = list(zip([a, b], map(f, [1, 2, 3, 4])))
return a + y
```
The major change is that we implement `MapVariable` and `ZipVariable` based on `IteratorVariable`. Before, `map` and `zip` were being traced by immediately unpacking the result as a `TupleVariable`, which is wrong in cases such as the example above.
`MapVariable`s are not allowed to be unpacked while `ZipVariable`s can only be unpacked if all of its iterables can also be unpacked.
We also add new `[has_]force_unpack_var_sequence` methods to `VariableTracker` for the case where it is safe to unpack the entire sequence lazily, e.g., when building a list from a map (i.e. `list(map(f, ...))`).
Pull Request resolved: https://github.com/pytorch/pytorch/pull/131413
Approved by: https://github.com/anijain2305
2024-07-26 10:47:38 +00:00