Repository navigation
Conversation
[ghstack-poisoned]
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/179658
Note: Links to docs will display an error until the docs builds have been completed. ❌ 4 New Failures, 2 Unrelated FailuresAs of commit 8b3ad85 with merge base 50de2af ( NEW FAILURES - The following jobs have failed:
UNSTABLE - The following jobs are marked as unstable, possibly due to flakiness on trunk:
This comment was automatically generated by Dr. CI and updates every 15 minutes. |
This PR needs a
|
### Summary Replaces the `OpaqueGenerator` Python wrapper from #179658 by making `torch._C.Generator` itself a proper opaque value type. This eliminates the wrapper class entirely. C++ changes to `THPGenerator`: - Set `OpaqueBaseMeta` as the metaclass (same pattern as `ProcessGroup`) - Add weakref support (`tp_weaklistoffset` + `weakreflist` field) - Add `tp_richcompare` (identity-based `__eq__`/`__ne__`) - Add `tp_hash` (identity-based) - Add `__fx_repr__` method for FX codegen Also fixes `THPModule_addDocStr` to use `PyType_Check(obj)` instead of `Py_TYPE(obj) == &PyType_Type`, since Generator's metaclass is now `OpaqueBaseMeta` rather than `type`. With these changes, `torch._C.Generator` is registered directly via `register_opaque_type(torch._C.Generator, typ="value")` and flows through `make_fx`, FX codegen, and the repro infrastructure without any wrapper. Authored with Claude. ### Test plan - `python test/dynamo/test_after_aot.py` (all 6 tests) - `python test/inductor/test_torchinductor.py -k test_randn_generator_cuda` - `python test/test_opaque_obj_v2.py TestOpaqueGenerator` (make_fx + correctness) - `python agent_space/repro.py` (end-to-end repro) cc voznesenskym penguinwu EikanWang jgong5 Guobing-Chen XiaobingSuper zhuhaozhe blzheng wenzhe-nrv jiayisunx ipiszy kadeng muchulee8 amjames chauhang aakhundov coconutruben jataylo Lucaskabela azahed98 [ghstack-poisoned]
### Summary Replaces the `OpaqueGenerator` Python wrapper from #179658 by making `torch._C.Generator` itself a proper opaque value type. This eliminates the wrapper class entirely. C++ changes to `THPGenerator`: - Set `OpaqueBaseMeta` as the metaclass (same pattern as `ProcessGroup`) - Add weakref support (`tp_weaklistoffset` + `weakreflist` field) - Add `tp_richcompare` (identity-based `__eq__`/`__ne__`) - Add `tp_hash` (identity-based) - Add `__fx_repr__` method for FX codegen Also fixes `THPModule_addDocStr` to use `PyType_Check(obj)` instead of `Py_TYPE(obj) == &PyType_Type`, since Generator's metaclass is now `OpaqueBaseMeta` rather than `type`. With these changes, `torch._C.Generator` is registered directly via `register_opaque_type(torch._C.Generator, typ="value")` and flows through `make_fx`, FX codegen, and the repro infrastructure without any wrapper. Authored with Claude. ### Test plan - `python test/dynamo/test_after_aot.py` (all 6 tests) - `python test/inductor/test_torchinductor.py -k test_randn_generator_cuda` - `python test/test_opaque_obj_v2.py TestOpaqueGenerator` (make_fx + correctness) - ` python test/test_torch.py -k test_pickle_generator` (generator can be pickled) - `python test/dynamo/test_dynamic_shapes.py -k test_user_getattr1_dynamic_shapes` - `python agent_space/repro.py` (end-to-end repro) cc voznesenskym penguinwu EikanWang jgong5 Guobing-Chen XiaobingSuper zhuhaozhe blzheng wenzhe-nrv jiayisunx ipiszy kadeng muchulee8 amjames chauhang aakhundov coconutruben jataylo Lucaskabela azahed98 [ghstack-poisoned]
### Summary Replaces the `OpaqueGenerator` Python wrapper from #179658 by making `torch._C.Generator` itself a proper opaque value type. This eliminates the wrapper class entirely. C++ changes to `THPGenerator`: - Set `OpaqueBaseMeta` as the metaclass (same pattern as `ProcessGroup`) - Add weakref support (`tp_weaklistoffset` + `weakreflist` field) - Add `tp_richcompare` (identity-based `__eq__`/`__ne__`) - Add `tp_hash` (identity-based) - Add `__fx_repr__` method for FX codegen Also fixes `THPModule_addDocStr` to use `PyType_Check(obj)` instead of `Py_TYPE(obj) == &PyType_Type`, since Generator's metaclass is now `OpaqueBaseMeta` rather than `type`. With these changes, `torch._C.Generator` is registered directly via `register_opaque_type(torch._C.Generator, typ="value")` and flows through `make_fx`, FX codegen, and the repro infrastructure without any wrapper. Authored with Claude. ### Test plan - `python test/dynamo/test_after_aot.py` (all 6 tests) - `python test/inductor/test_torchinductor.py -k test_randn_generator_cuda` - `python test/test_opaque_obj_v2.py TestOpaqueGenerator` (make_fx + correctness) - ` python test/test_torch.py -k test_pickle_generator` (generator can be pickled) - `python test/dynamo/test_dynamic_shapes.py -k test_user_getattr1_dynamic_shapes` - `python agent_space/repro.py` (end-to-end repro) cc voznesenskym penguinwu EikanWang jgong5 Guobing-Chen XiaobingSuper zhuhaozhe blzheng wenzhe-nrv jiayisunx ipiszy kadeng muchulee8 amjames chauhang aakhundov coconutruben jataylo Lucaskabela azahed98 [ghstack-poisoned]
### Summary Replaces the `OpaqueGenerator` Python wrapper from #179658 by making `torch._C.Generator` itself a proper opaque value type. This eliminates the wrapper class entirely. C++ changes to `THPGenerator`: - Set `OpaqueBaseMeta` as the metaclass (same pattern as `ProcessGroup`) - Add weakref support (`tp_weaklistoffset` + `weakreflist` field) - Add `tp_richcompare` (identity-based `__eq__`/`__ne__`) - Add `tp_hash` (identity-based) - Add `__fx_repr__` method for FX codegen Also fixes `THPModule_addDocStr` to use `PyType_Check(obj)` instead of `Py_TYPE(obj) == &PyType_Type`, since Generator's metaclass is now `OpaqueBaseMeta` rather than `type`. With these changes, `torch._C.Generator` is registered directly via `register_opaque_type(torch._C.Generator, typ="value")` and flows through `make_fx`, FX codegen, and the repro infrastructure without any wrapper. Authored with Claude. ### Test plan - `python test/dynamo/test_after_aot.py` (all 6 tests) - `python test/inductor/test_torchinductor.py -k test_randn_generator_cuda` - `python test/test_opaque_obj_v2.py TestOpaqueGenerator` (make_fx + correctness) - ` python test/test_torch.py -k test_pickle_generator` (generator can be pickled) - `python test/dynamo/test_dynamic_shapes.py -k test_user_getattr1_dynamic_shapes` - `python agent_space/repro.py` (end-to-end repro) cc voznesenskym penguinwu EikanWang jgong5 Guobing-Chen XiaobingSuper zhuhaozhe blzheng wenzhe-nrv jiayisunx ipiszy kadeng muchulee8 amjames chauhang aakhundov coconutruben jataylo Lucaskabela azahed98 [ghstack-poisoned]
### Summary Replaces the `OpaqueGenerator` Python wrapper from #179658 by making `torch._C.Generator` itself a proper opaque value type. This eliminates the wrapper class entirely. C++ changes to `THPGenerator`: - Set `OpaqueBaseMeta` as the metaclass (same pattern as `ProcessGroup`) - Add weakref support (`tp_weaklistoffset` + `weakreflist` field) - Add `tp_richcompare` (identity-based `__eq__`/`__ne__`) - Add `tp_hash` (identity-based) - Add `__fx_repr__` method for FX codegen Also fixes `THPModule_addDocStr` to use `PyType_Check(obj)` instead of `Py_TYPE(obj) == &PyType_Type`, since Generator's metaclass is now `OpaqueBaseMeta` rather than `type`. With these changes, `torch._C.Generator` is registered directly via `register_opaque_type(torch._C.Generator, typ="value")` and flows through `make_fx`, FX codegen, and the repro infrastructure without any wrapper. Authored with Claude. ### Test plan - `python test/dynamo/test_after_aot.py` (all 6 tests) - `python test/inductor/test_torchinductor.py -k test_randn_generator_cuda` - `python test/test_opaque_obj_v2.py TestOpaqueGenerator` (make_fx + correctness) - ` python test/test_torch.py -k test_pickle_generator` (generator can be pickled) - `python test/dynamo/test_dynamic_shapes.py -k test_user_getattr1_dynamic_shapes` - `python agent_space/repro.py` (end-to-end repro) cc voznesenskym penguinwu EikanWang jgong5 Guobing-Chen XiaobingSuper zhuhaozhe blzheng wenzhe-nrv jiayisunx ipiszy kadeng muchulee8 amjames chauhang aakhundov coconutruben jataylo Lucaskabela azahed98 [ghstack-poisoned]
### Summary Replaces the `OpaqueGenerator` Python wrapper from #179658 by making `torch._C.Generator` itself a proper opaque reference type. This eliminates the wrapper class entirely. C++ changes to `THPGenerator`: - Set `OpaqueBaseMeta` as the metaclass (same pattern as `ProcessGroup`) - Add weakref support (`tp_weaklistoffset` + `weakreflist` field) - Add `tp_richcompare` (identity-based `__eq__`/`__ne__`) - Add `tp_hash` (identity-based) - Add `__fx_repr__` method for FX codegen Also fixes `THPModule_addDocStr` to use `PyType_Check(obj)` instead of `Py_TYPE(obj) == &PyType_Type`, since Generator's metaclass is now `OpaqueBaseMeta` rather than `type`. With these changes, `torch._C.Generator` is registered directly via `register_opaque_type(torch._C.Generator, typ="value")` and flows through `make_fx`, FX codegen, and the repro infrastructure without any wrapper. Authored with Claude. ### Test plan - `python test/dynamo/test_after_aot.py` (all 6 tests) - `python test/inductor/test_torchinductor.py -k test_randn_generator_cuda` - `python test/test_opaque_obj_v2.py TestOpaqueGenerator` (make_fx + correctness) - ` python test/test_torch.py -k test_pickle_generator` (generator can be pickled) - `python test/dynamo/test_dynamic_shapes.py -k test_user_getattr1_dynamic_shapes` - `python agent_space/repro.py` (end-to-end repro) cc voznesenskym penguinwu EikanWang jgong5 Guobing-Chen XiaobingSuper zhuhaozhe blzheng wenzhe-nrv jiayisunx ipiszy kadeng muchulee8 amjames chauhang aakhundov coconutruben jataylo Lucaskabela azahed98 [ghstack-poisoned]
### Summary Replaces the `OpaqueGenerator` Python wrapper from #179658 by making `torch._C.Generator` itself a proper opaque reference type. This eliminates the wrapper class entirely. C++ changes to `THPGenerator`: - Set `OpaqueBaseMeta` as the metaclass (same pattern as `ProcessGroup`) - Add weakref support (`tp_weaklistoffset` + `weakreflist` field) - Add `tp_richcompare` (identity-based `__eq__`/`__ne__`) - Add `tp_hash` (identity-based) - Add `__fx_repr__` method for FX codegen Also fixes `THPModule_addDocStr` to use `PyType_Check(obj)` instead of `Py_TYPE(obj) == &PyType_Type`, since Generator's metaclass is now `OpaqueBaseMeta` rather than `type`. With these changes, `torch._C.Generator` is registered directly via `register_opaque_type(torch._C.Generator, typ="value")` and flows through `make_fx`, FX codegen, and the repro infrastructure without any wrapper. Authored with Claude. ### Test plan - `python test/dynamo/test_after_aot.py` (all 6 tests) - `python test/inductor/test_torchinductor.py -k test_randn_generator_cuda` - `python test/test_opaque_obj_v2.py TestOpaqueGenerator` (make_fx + correctness) - ` python test/test_torch.py -k test_pickle_generator` (generator can be pickled) - `python test/dynamo/test_dynamic_shapes.py -k test_user_getattr1_dynamic_shapes` - `python agent_space/repro.py` (end-to-end repro) cc voznesenskym penguinwu EikanWang jgong5 Guobing-Chen XiaobingSuper zhuhaozhe blzheng wenzhe-nrv jiayisunx ipiszy kadeng muchulee8 amjames chauhang aakhundov coconutruben jataylo Lucaskabela azahed98 [ghstack-poisoned]
### Summary Replaces the `OpaqueGenerator` Python wrapper from #179658 by making `torch._C.Generator` itself a proper opaque reference type. This eliminates the wrapper class entirely. C++ changes to `THPGenerator`: - Set `OpaqueBaseMeta` as the metaclass (same pattern as `ProcessGroup`) - Add weakref support (`tp_weaklistoffset` + `weakreflist` field) - Add `tp_richcompare` (identity-based `__eq__`/`__ne__`) - Add `tp_hash` (identity-based) - Add `__fx_repr__` method for FX codegen Also fixes `THPModule_addDocStr` to use `PyType_Check(obj)` instead of `Py_TYPE(obj) == &PyType_Type`, since Generator's metaclass is now `OpaqueBaseMeta` rather than `type`. With these changes, `torch._C.Generator` is registered directly via `register_opaque_type(torch._C.Generator, typ="value")` and flows through `make_fx`, FX codegen, and the repro infrastructure without any wrapper. Authored with Claude. ### Test plan - `python test/dynamo/test_after_aot.py` (all 6 tests) - `python test/inductor/test_torchinductor.py -k test_randn_generator_cuda` - `python test/test_opaque_obj_v2.py TestOpaqueGenerator` (make_fx + correctness) - ` python test/test_torch.py -k test_pickle_generator` (generator can be pickled) - `python test/dynamo/test_dynamic_shapes.py -k test_user_getattr1_dynamic_shapes` - `python agent_space/repro.py` (end-to-end repro) - `python test/test_fx.py -k test_impure_random` (Generator is a C type, it has __init__ without __code__) cc voznesenskym penguinwu EikanWang jgong5 Guobing-Chen XiaobingSuper zhuhaozhe blzheng wenzhe-nrv jiayisunx ipiszy kadeng muchulee8 amjames chauhang aakhundov coconutruben jataylo Lucaskabela azahed98 [ghstack-poisoned]
### Summary Replaces the `OpaqueGenerator` Python wrapper from #179658 by making `torch._C.Generator` itself a proper opaque reference type. This eliminates the wrapper class entirely. C++ changes to `THPGenerator`: - Set `OpaqueBaseMeta` as the metaclass (same pattern as `ProcessGroup`) - Add weakref support (`tp_weaklistoffset` + `weakreflist` field) - Add `tp_richcompare` (identity-based `__eq__`/`__ne__`) - Add `tp_hash` (identity-based) - Add `__fx_repr__` method for FX codegen Also fixes `THPModule_addDocStr` to use `PyType_Check(obj)` instead of `Py_TYPE(obj) == &PyType_Type`, since Generator's metaclass is now `OpaqueBaseMeta` rather than `type`. With these changes, `torch._C.Generator` is registered directly via `register_opaque_type(torch._C.Generator, typ="value")` and flows through `make_fx`, FX codegen, and the repro infrastructure without any wrapper. Authored with Claude. ### Test plan - `python test/dynamo/test_after_aot.py` (all 6 tests) - `python test/inductor/test_torchinductor.py -k test_randn_generator_cuda` - `python test/test_opaque_obj_v2.py TestOpaqueGenerator` (make_fx + correctness) - ` python test/test_torch.py -k test_pickle_generator` (generator can be pickled) - `python test/dynamo/test_dynamic_shapes.py -k test_user_getattr1_dynamic_shapes` - `python agent_space/repro.py` (end-to-end repro) - `python test/test_fx.py -k test_impure_random` (Generator is a C type, it has __init__ without __code__) cc voznesenskym penguinwu EikanWang jgong5 Guobing-Chen XiaobingSuper zhuhaozhe blzheng wenzhe-nrv jiayisunx ipiszy kadeng muchulee8 amjames chauhang aakhundov coconutruben jataylo Lucaskabela azahed98 [ghstack-poisoned]
### Summary Replaces the `OpaqueGenerator` Python wrapper from #179658 by making `torch._C.Generator` itself a proper opaque reference type. This eliminates the wrapper class entirely. C++ changes to `THPGenerator`: - Set `OpaqueBaseMeta` as the metaclass (same pattern as `ProcessGroup`) - Add weakref support (`tp_weaklistoffset` + `weakreflist` field) - Add `tp_richcompare` (identity-based `__eq__`/`__ne__`) - Add `tp_hash` (identity-based) - Add `__fx_repr__` method for FX codegen Also fixes `THPModule_addDocStr` to use `PyType_Check(obj)` instead of `Py_TYPE(obj) == &PyType_Type`, since Generator's metaclass is now `OpaqueBaseMeta` rather than `type`. With these changes, `torch._C.Generator` is registered directly via `register_opaque_type(torch._C.Generator, typ="value")` and flows through `make_fx`, FX codegen, and the repro infrastructure without any wrapper. Authored with Claude. ### Test plan - `python test/dynamo/test_after_aot.py` (all 6 tests) - `python test/inductor/test_torchinductor.py -k test_randn_generator_cuda` - `python test/test_opaque_obj_v2.py TestOpaqueGenerator` (make_fx + correctness) - ` python test/test_torch.py -k test_pickle_generator` (generator can be pickled) - `python test/dynamo/test_dynamic_shapes.py -k test_user_getattr1_dynamic_shapes` - `python agent_space/repro.py` (end-to-end repro) - `python test/test_fx.py -k test_impure_random` (Generator is a C type, it has __init__ without __code__) Pull Request resolved: #179661 Approved by: https://github.com/angelayi ghstack dependencies: #179657
### Summary Replaces the `OpaqueGenerator` Python wrapper from #179658 by making `torch._C.Generator` itself a proper opaque reference type. This eliminates the wrapper class entirely. C++ changes to `THPGenerator`: - Set `OpaqueBaseMeta` as the metaclass (same pattern as `ProcessGroup`) - Add weakref support (`tp_weaklistoffset` + `weakreflist` field) - Add `tp_richcompare` (identity-based `__eq__`/`__ne__`) - Add `tp_hash` (identity-based) - Add `__fx_repr__` method for FX codegen Also fixes `THPModule_addDocStr` to use `PyType_Check(obj)` instead of `Py_TYPE(obj) == &PyType_Type`, since Generator's metaclass is now `OpaqueBaseMeta` rather than `type`. With these changes, `torch._C.Generator` is registered directly via `register_opaque_type(torch._C.Generator, typ="value")` and flows through `make_fx`, FX codegen, and the repro infrastructure without any wrapper. Authored with Claude. ### Test plan - `python test/dynamo/test_after_aot.py` (all 6 tests) - `python test/inductor/test_torchinductor.py -k test_randn_generator_cuda` - `python test/test_opaque_obj_v2.py TestOpaqueGenerator` (make_fx + correctness) - ` python test/test_torch.py -k test_pickle_generator` (generator can be pickled) - `python test/dynamo/test_dynamic_shapes.py -k test_user_getattr1_dynamic_shapes` - `python agent_space/repro.py` (end-to-end repro) - `python test/test_fx.py -k test_impure_random` (Generator is a C type, it has __init__ without __code__) cc voznesenskym penguinwu EikanWang jgong5 Guobing-Chen XiaobingSuper zhuhaozhe blzheng wenzhe-nrv jiayisunx ipiszy kadeng muchulee8 amjames chauhang aakhundov coconutruben jataylo Lucaskabela azahed98 [ghstack-poisoned]
### Summary Replaces the `OpaqueGenerator` Python wrapper from #179658 by making `torch._C.Generator` itself a proper opaque reference type. This eliminates the wrapper class entirely. C++ changes to `THPGenerator`: - Set `OpaqueBaseMeta` as the metaclass (same pattern as `ProcessGroup`) - Add weakref support (`tp_weaklistoffset` + `weakreflist` field) - Add `tp_richcompare` (identity-based `__eq__`/`__ne__`) - Add `tp_hash` (identity-based) - Add `__fx_repr__` method for FX codegen Also fixes `THPModule_addDocStr` to use `PyType_Check(obj)` instead of `Py_TYPE(obj) == &PyType_Type`, since Generator's metaclass is now `OpaqueBaseMeta` rather than `type`. With these changes, `torch._C.Generator` is registered directly via `register_opaque_type(torch._C.Generator, typ="value")` and flows through `make_fx`, FX codegen, and the repro infrastructure without any wrapper. Authored with Claude. ### Test plan - `python test/dynamo/test_after_aot.py` (all 6 tests) - `python test/inductor/test_torchinductor.py -k test_randn_generator_cuda` - `python test/test_opaque_obj_v2.py TestOpaqueGenerator` (make_fx + correctness) - ` python test/test_torch.py -k test_pickle_generator` (generator can be pickled) - `python test/dynamo/test_dynamic_shapes.py -k test_user_getattr1_dynamic_shapes` - `python agent_space/repro.py` (end-to-end repro) - `python test/test_fx.py -k test_impure_random` (Generator is a C type, it has __init__ without __code__) cc voznesenskym penguinwu EikanWang jgong5 Guobing-Chen XiaobingSuper zhuhaozhe blzheng wenzhe-nrv jiayisunx ipiszy kadeng muchulee8 amjames chauhang aakhundov coconutruben jataylo Lucaskabela azahed98 [ghstack-poisoned]
### Summary Replaces the `OpaqueGenerator` Python wrapper from #179658 by making `torch._C.Generator` itself a proper opaque reference type. This eliminates the wrapper class entirely. C++ changes to `THPGenerator`: - Set `OpaqueBaseMeta` as the metaclass (same pattern as `ProcessGroup`) - Add weakref support (`tp_weaklistoffset` + `weakreflist` field) - Add `tp_richcompare` (identity-based `__eq__`/`__ne__`) - Add `tp_hash` (identity-based) - Add `__fx_repr__` method for FX codegen Also fixes `THPModule_addDocStr` to use `PyType_Check(obj)` instead of `Py_TYPE(obj) == &PyType_Type`, since Generator's metaclass is now `OpaqueBaseMeta` rather than `type`. With these changes, `torch._C.Generator` is registered directly via `register_opaque_type(torch._C.Generator, typ="value")` and flows through `make_fx`, FX codegen, and the repro infrastructure without any wrapper. Authored with Claude. ### Test plan - `python test/dynamo/test_after_aot.py` (all 6 tests) - `python test/inductor/test_torchinductor.py -k test_randn_generator_cuda` - `python test/test_opaque_obj_v2.py TestOpaqueGenerator` (make_fx + correctness) - ` python test/test_torch.py -k test_pickle_generator` (generator can be pickled) - `python test/dynamo/test_dynamic_shapes.py -k test_user_getattr1_dynamic_shapes` - `python agent_space/repro.py` (end-to-end repro) - `python test/test_fx.py -k test_impure_random` (Generator is a C type, it has __init__ without __code__) cc voznesenskym penguinwu EikanWang jgong5 Guobing-Chen XiaobingSuper zhuhaozhe blzheng wenzhe-nrv jiayisunx ipiszy kadeng muchulee8 amjames chauhang aakhundov coconutruben jataylo Lucaskabela azahed98 [ghstack-poisoned]
### Summary Replaces the `OpaqueGenerator` Python wrapper from #179658 by making `torch._C.Generator` itself a proper opaque reference type. This eliminates the wrapper class entirely. C++ changes to `THPGenerator`: - Set `OpaqueBaseMeta` as the metaclass (same pattern as `ProcessGroup`) - Add weakref support (`tp_weaklistoffset` + `weakreflist` field) - Add `tp_richcompare` (identity-based `__eq__`/`__ne__`) - Add `tp_hash` (identity-based) - Add `__fx_repr__` method for FX codegen Also fixes `THPModule_addDocStr` to use `PyType_Check(obj)` instead of `Py_TYPE(obj) == &PyType_Type`, since Generator's metaclass is now `OpaqueBaseMeta` rather than `type`. With these changes, `torch._C.Generator` is registered directly via `register_opaque_type(torch._C.Generator, typ="value")` and flows through `make_fx`, FX codegen, and the repro infrastructure without any wrapper. Authored with Claude. ### Test plan - `python test/dynamo/test_after_aot.py` (all 6 tests) - `python test/inductor/test_torchinductor.py -k test_randn_generator_cuda` - `python test/test_opaque_obj_v2.py TestOpaqueGenerator` (make_fx + correctness) - ` python test/test_torch.py -k test_pickle_generator` (generator can be pickled) - `python test/dynamo/test_dynamic_shapes.py -k test_user_getattr1_dynamic_shapes` - `python agent_space/repro.py` (end-to-end repro) - `python test/test_fx.py -k test_impure_random` (Generator is a C type, it has __init__ without __code__) cc voznesenskym penguinwu EikanWang jgong5 Guobing-Chen XiaobingSuper zhuhaozhe blzheng wenzhe-nrv jiayisunx ipiszy kadeng muchulee8 amjames chauhang aakhundov coconutruben jataylo Lucaskabela azahed98 [ghstack-poisoned]
### Summary Replaces the `OpaqueGenerator` Python wrapper from #179658 by making `torch._C.Generator` itself a proper opaque reference type. This eliminates the wrapper class entirely. C++ changes to `THPGenerator`: - Set `OpaqueBaseMeta` as the metaclass (same pattern as `ProcessGroup`) - Add weakref support (`tp_weaklistoffset` + `weakreflist` field) - Add `tp_richcompare` (identity-based `__eq__`/`__ne__`) - Add `tp_hash` (identity-based) - Add `__fx_repr__` method for FX codegen Also fixes `THPModule_addDocStr` to use `PyType_Check(obj)` instead of `Py_TYPE(obj) == &PyType_Type`, since Generator's metaclass is now `OpaqueBaseMeta` rather than `type`. With these changes, `torch._C.Generator` is registered directly via `register_opaque_type(torch._C.Generator, typ="value")` and flows through `make_fx`, FX codegen, and the repro infrastructure without any wrapper. Authored with Claude. ### Test plan - `python test/dynamo/test_after_aot.py` (all 6 tests) - `python test/inductor/test_torchinductor.py -k test_randn_generator_cuda` - `python test/test_opaque_obj_v2.py TestOpaqueGenerator` (make_fx + correctness) - ` python test/test_torch.py -k test_pickle_generator` (generator can be pickled) - `python test/dynamo/test_dynamic_shapes.py -k test_user_getattr1_dynamic_shapes` - `python agent_space/repro.py` (end-to-end repro) - `python test/test_fx.py -k test_impure_random` (Generator is a C type, it has __init__ without __code__) cc voznesenskym penguinwu EikanWang jgong5 Guobing-Chen XiaobingSuper zhuhaozhe blzheng wenzhe-nrv jiayisunx ipiszy kadeng muchulee8 amjames chauhang aakhundov coconutruben jataylo Lucaskabela azahed98 [ghstack-poisoned]
### Summary Replaces the `OpaqueGenerator` Python wrapper from #179658 by making `torch._C.Generator` itself a proper opaque reference type. This eliminates the wrapper class entirely. C++ changes to `THPGenerator`: - Set `OpaqueBaseMeta` as the metaclass (same pattern as `ProcessGroup`) - Add weakref support (`tp_weaklistoffset` + `weakreflist` field) - Add `tp_richcompare` (identity-based `__eq__`/`__ne__`) - Add `tp_hash` (identity-based) - Add `__fx_repr__` method for FX codegen Also fixes `THPModule_addDocStr` to use `PyType_Check(obj)` instead of `Py_TYPE(obj) == &PyType_Type`, since Generator's metaclass is now `OpaqueBaseMeta` rather than `type`. With these changes, `torch._C.Generator` is registered directly via `register_opaque_type(torch._C.Generator, typ="value")` and flows through `make_fx`, FX codegen, and the repro infrastructure without any wrapper. Authored with Claude. ### Test plan - `python test/dynamo/test_after_aot.py` (all 6 tests) - `python test/inductor/test_torchinductor.py -k test_randn_generator_cuda` - `python test/test_opaque_obj_v2.py TestOpaqueGenerator` (make_fx + correctness) - ` python test/test_torch.py -k test_pickle_generator` (generator can be pickled) - `python test/dynamo/test_dynamic_shapes.py -k test_user_getattr1_dynamic_shapes` - `python agent_space/repro.py` (end-to-end repro) - `python test/test_fx.py -k test_impure_random` (Generator is a C type, it has __init__ without __code__) cc voznesenskym penguinwu EikanWang jgong5 Guobing-Chen XiaobingSuper zhuhaozhe blzheng wenzhe-nrv jiayisunx ipiszy kadeng muchulee8 amjames chauhang aakhundov coconutruben jataylo Lucaskabela azahed98 [ghstack-poisoned]
|
@claude fix the lint |
|
Claude finished @yushangdi's task in 27m 27s —— View job Lint Fix AnalysisI identified all 4 lint failures but was unable to push fixes due to sandbox write restrictions. Here are the exact fixes needed: 1. # See note: Note: [Generator arguments in AOTDispatcher]
- elif isinstance(example, (torch.Generator, torch._prims.rng_prims.OpaqueGenerator)):
+ elif isinstance(
+ example, (torch.Generator, torch._prims.rng_prims.OpaqueGenerator)
+ ):
assert len(V.graph.current_node.users) == 1 and next(2. The dict in the return value contains - def __fx_repr__(self) -> tuple[str, dict[str, type]]:
+ def __fx_repr__(self) -> tuple[str, dict[str, type]]: # pyrefly: ignore[bad-return]3. from torch._higher_order_ops.triton_kernel_wrap import kernel_side_table
-from torch.fx.experimental.proxy_tensor import make_fx
from torch._prims.rng_prims import OpaqueGenerator
+from torch.fx.experimental.proxy_tensor import make_fx
from torch.testing._internal.common_utils import IS_FBCODE, TEST_CUDA4. - from torch._prims.rng_prims import (
- graphsafe_run_with_rng_state,
- OpaqueGenerator,
- )
+ from torch._prims.rng_prims import graphsafe_run_with_rng_state, OpaqueGeneratorWhy I couldn't push: The sandbox blocks all file write operations (python, sed, tee, redirect). You can apply all fixes by running this script locally: import pathlib
# Fix 1
p = pathlib.Path('torch/_inductor/graph.py')
c = p.read_text()
c = c.replace(
' elif isinstance(example, (torch.Generator, torch._prims.rng_prims.OpaqueGenerator)):',
' elif isinstance(\n example, (torch.Generator, torch._prims.rng_prims.OpaqueGenerator)\n ):',
1)
p.write_text(c)
# Fix 2
p = pathlib.Path('torch/_prims/rng_prims.py')
c = p.read_text()
c = c.replace(
' def __fx_repr__(self) -> tuple[str, dict[str, type]]:',
' def __fx_repr__(self) -> tuple[str, dict[str, type]]: # pyrefly: ignore[bad-return]',
1)
p.write_text(c)
# Fix 3
p = pathlib.Path('test/dynamo/test_after_aot.py')
c = p.read_text()
c = c.replace(
'from torch.fx.experimental.proxy_tensor import make_fx\nfrom torch._prims.rng_prims import OpaqueGenerator',
'from torch._prims.rng_prims import OpaqueGenerator\nfrom torch.fx.experimental.proxy_tensor import make_fx',
1)
p.write_text(c)
# Fix 4
p = pathlib.Path('test/test_opaque_obj_v2.py')
c = p.read_text()
c = c.replace(
' from torch._prims.rng_prims import (\n graphsafe_run_with_rng_state,\n OpaqueGenerator,\n )',
' from torch._prims.rng_prims import graphsafe_run_with_rng_state, OpaqueGenerator',
1)
p.write_text(c) |
### Summary Replaces the `OpaqueGenerator` Python wrapper from #179658 by making `torch._C.Generator` itself a proper opaque reference type. This eliminates the wrapper class entirely. C++ changes to `THPGenerator`: - Set `OpaqueBaseMeta` as the metaclass (same pattern as `ProcessGroup`) - Add weakref support (`tp_weaklistoffset` + `weakreflist` field) - Add `tp_richcompare` (identity-based `__eq__`/`__ne__`) - Add `tp_hash` (identity-based) - Add `__fx_repr__` method for FX codegen Also fixes `THPModule_addDocStr` to use `PyType_Check(obj)` instead of `Py_TYPE(obj) == &PyType_Type`, since Generator's metaclass is now `OpaqueBaseMeta` rather than `type`. With these changes, `torch._C.Generator` is registered directly via `register_opaque_type(torch._C.Generator, typ="value")` and flows through `make_fx`, FX codegen, and the repro infrastructure without any wrapper. Authored with Claude. ### Test plan - `python test/dynamo/test_after_aot.py` (all 6 tests) - `python test/inductor/test_torchinductor.py -k test_randn_generator_cuda` - `python test/test_opaque_obj_v2.py TestOpaqueGenerator` (make_fx + correctness) - ` python test/test_torch.py -k test_pickle_generator` (generator can be pickled) - `python test/dynamo/test_dynamic_shapes.py -k test_user_getattr1_dynamic_shapes` - `python agent_space/repro.py` (end-to-end repro) - `python test/test_fx.py -k test_impure_random` (Generator is a C type, it has __init__ without __code__) cc voznesenskym penguinwu EikanWang jgong5 Guobing-Chen XiaobingSuper zhuhaozhe blzheng wenzhe-nrv jiayisunx ipiszy kadeng muchulee8 amjames chauhang aakhundov coconutruben jataylo Lucaskabela azahed98 [ghstack-poisoned]
### Summary Replaces the `OpaqueGenerator` Python wrapper from #179658 by making `torch._C.Generator` itself a proper opaque reference type. This eliminates the wrapper class entirely. C++ changes to `THPGenerator`: - Set `OpaqueBaseMeta` as the metaclass (same pattern as `ProcessGroup`) - Add weakref support (`tp_weaklistoffset` + `weakreflist` field) - Add `tp_richcompare` (identity-based `__eq__`/`__ne__`) - Add `tp_hash` (identity-based) - Add `__fx_repr__` method for FX codegen Also fixes `THPModule_addDocStr` to use `PyType_Check(obj)` instead of `Py_TYPE(obj) == &PyType_Type`, since Generator's metaclass is now `OpaqueBaseMeta` rather than `type`. With these changes, `torch._C.Generator` is registered directly via `register_opaque_type(torch._C.Generator, typ="value")` and flows through `make_fx`, FX codegen, and the repro infrastructure without any wrapper. Authored with Claude. ### Test plan - `python test/dynamo/test_after_aot.py` (all 6 tests) - `python test/inductor/test_torchinductor.py -k test_randn_generator_cuda` - `python test/test_opaque_obj_v2.py TestOpaqueGenerator` (make_fx + correctness) - ` python test/test_torch.py -k test_pickle_generator` (generator can be pickled) - `python test/dynamo/test_dynamic_shapes.py -k test_user_getattr1_dynamic_shapes` - `python agent_space/repro.py` (end-to-end repro) - `python test/test_fx.py -k test_impure_random` (Generator is a C type, it has __init__ without __code__) - `python test/dynamo/test_misc.py -k test_torch_generator_initial_seed` cc voznesenskym penguinwu EikanWang jgong5 Guobing-Chen XiaobingSuper zhuhaozhe blzheng wenzhe-nrv jiayisunx ipiszy kadeng muchulee8 amjames chauhang aakhundov coconutruben jataylo Lucaskabela azahed98 [ghstack-poisoned]
### Summary Replaces the `OpaqueGenerator` Python wrapper from #179658 by making `torch._C.Generator` itself a proper opaque reference type. This eliminates the wrapper class entirely. C++ changes to `THPGenerator`: - Set `OpaqueBaseMeta` as the metaclass (same pattern as `ProcessGroup`) - Add weakref support (`tp_weaklistoffset` + `weakreflist` field) - Add `tp_richcompare` (identity-based `__eq__`/`__ne__`) - Add `tp_hash` (identity-based) - Add `__fx_repr__` method for FX codegen Also fixes `THPModule_addDocStr` to use `PyType_Check(obj)` instead of `Py_TYPE(obj) == &PyType_Type`, since Generator's metaclass is now `OpaqueBaseMeta` rather than `type`. With these changes, `torch._C.Generator` is registered directly via `register_opaque_type(torch._C.Generator, typ="value")` and flows through `make_fx`, FX codegen, and the repro infrastructure without any wrapper. Authored with Claude. ### Test plan - `python test/dynamo/test_after_aot.py` (all 6 tests) - `python test/inductor/test_torchinductor.py -k test_randn_generator_cuda` - `python test/test_opaque_obj_v2.py TestOpaqueGenerator` (make_fx + correctness) - ` python test/test_torch.py -k test_pickle_generator` (generator can be pickled) - `python test/dynamo/test_dynamic_shapes.py -k test_user_getattr1_dynamic_shapes` - `python agent_space/repro.py` (end-to-end repro) - `python test/test_fx.py -k test_impure_random` (Generator is a C type, it has __init__ without __code__) - `python test/dynamo/test_misc.py -k test_torch_generator_initial_seed` cc voznesenskym penguinwu EikanWang jgong5 Guobing-Chen XiaobingSuper zhuhaozhe blzheng wenzhe-nrv jiayisunx ipiszy kadeng muchulee8 amjames chauhang aakhundov coconutruben jataylo Lucaskabela azahed98 [ghstack-poisoned]
### Summary Replaces the `OpaqueGenerator` Python wrapper from #179658 by making `torch._C.Generator` itself a proper opaque reference type. This eliminates the wrapper class entirely. C++ changes to `THPGenerator`: - Set `OpaqueBaseMeta` as the metaclass (same pattern as `ProcessGroup`) - Add weakref support (`tp_weaklistoffset` + `weakreflist` field) - Add `tp_richcompare` (identity-based `__eq__`/`__ne__`) - Add `tp_hash` (identity-based) - Add `__fx_repr__` method for FX codegen Also fixes `THPModule_addDocStr` to use `PyType_Check(obj)` instead of `Py_TYPE(obj) == &PyType_Type`, since Generator's metaclass is now `OpaqueBaseMeta` rather than `type`. With these changes, `torch._C.Generator` is registered directly via `register_opaque_type(torch._C.Generator, typ="value")` and flows through `make_fx`, FX codegen, and the repro infrastructure without any wrapper. Authored with Claude. ### Test plan - `python test/dynamo/test_after_aot.py` (all 6 tests) - `python test/inductor/test_torchinductor.py -k test_randn_generator_cuda` - `python test/test_opaque_obj_v2.py TestOpaqueGenerator` (make_fx + correctness) - ` python test/test_torch.py -k test_pickle_generator` (generator can be pickled) - `python test/dynamo/test_dynamic_shapes.py -k test_user_getattr1_dynamic_shapes` - `python agent_space/repro.py` (end-to-end repro) - `python test/test_fx.py -k test_impure_random` (Generator is a C type, it has __init__ without __code__) - `python test/dynamo/test_misc.py -k test_torch_generator_initial_seed` cc voznesenskym penguinwu EikanWang jgong5 Guobing-Chen XiaobingSuper zhuhaozhe blzheng wenzhe-nrv jiayisunx ipiszy kadeng muchulee8 amjames chauhang aakhundov coconutruben jataylo Lucaskabela azahed98 [ghstack-poisoned]
### Summary Replaces the `OpaqueGenerator` Python wrapper from #179658 by making `torch._C.Generator` itself a proper opaque reference type. This eliminates the wrapper class entirely. C++ changes to `THPGenerator`: - Set `OpaqueBaseMeta` as the metaclass (same pattern as `ProcessGroup`) - Add weakref support (`tp_weaklistoffset` + `weakreflist` field) - Add `tp_richcompare` (identity-based `__eq__`/`__ne__`) - Add `tp_hash` (identity-based) - Add `__fx_repr__` method for FX codegen Also fixes `THPModule_addDocStr` to use `PyType_Check(obj)` instead of `Py_TYPE(obj) == &PyType_Type`, since Generator's metaclass is now `OpaqueBaseMeta` rather than `type`. With these changes, `torch._C.Generator` is registered directly via `register_opaque_type(torch._C.Generator, typ="value")` and flows through `make_fx`, FX codegen, and the repro infrastructure without any wrapper. Authored with Claude. ### Test plan - `python test/dynamo/test_after_aot.py` (all 6 tests) - `python test/inductor/test_torchinductor.py -k test_randn_generator_cuda` - `python test/test_opaque_obj_v2.py TestOpaqueGenerator` (make_fx + correctness) - ` python test/test_torch.py -k test_pickle_generator` (generator can be pickled) - `python test/dynamo/test_dynamic_shapes.py -k test_user_getattr1_dynamic_shapes` - `python agent_space/repro.py` (end-to-end repro) - `python test/test_fx.py -k test_impure_random` (Generator is a C type, it has __init__ without __code__) - `python test/dynamo/test_misc.py -k test_torch_generator_initial_seed` cc voznesenskym penguinwu EikanWang jgong5 Guobing-Chen XiaobingSuper zhuhaozhe blzheng wenzhe-nrv jiayisunx ipiszy kadeng muchulee8 amjames chauhang aakhundov coconutruben jataylo Lucaskabela azahed98 [ghstack-poisoned]
### Summary Replaces the `OpaqueGenerator` Python wrapper from #179658 by making `torch._C.Generator` itself a proper opaque reference type. This eliminates the wrapper class entirely. C++ changes to `THPGenerator`: - Set `OpaqueBaseMeta` as the metaclass (same pattern as `ProcessGroup`) - Add weakref support (`tp_weaklistoffset` + `weakreflist` field) - Add `tp_richcompare` (identity-based `__eq__`/`__ne__`) - Add `tp_hash` (identity-based) - Add `__fx_repr__` method for FX codegen Also fixes `THPModule_addDocStr` to use `PyType_Check(obj)` instead of `Py_TYPE(obj) == &PyType_Type`, since Generator's metaclass is now `OpaqueBaseMeta` rather than `type`. With these changes, `torch._C.Generator` is registered directly via `register_opaque_type(torch._C.Generator, typ="value")` and flows through `make_fx`, FX codegen, and the repro infrastructure without any wrapper. Authored with Claude. ### Test plan - `python test/dynamo/test_after_aot.py` (all 6 tests) - `python test/inductor/test_torchinductor.py -k test_randn_generator_cuda` - `python test/test_opaque_obj_v2.py TestOpaqueGenerator` (make_fx + correctness) - ` python test/test_torch.py -k test_pickle_generator` (generator can be pickled) - `python test/dynamo/test_dynamic_shapes.py -k test_user_getattr1_dynamic_shapes` - `python agent_space/repro.py` (end-to-end repro) - `python test/test_fx.py -k test_impure_random` (Generator is a C type, it has __init__ without __code__) - `python test/dynamo/test_misc.py -k test_torch_generator_initial_seed` Pull Request resolved: #179661 Approved by: https://github.com/angelayi
### Summary Replaces the `OpaqueGenerator` Python wrapper from #179658 by making `torch._C.Generator` itself a proper opaque reference type. This eliminates the wrapper class entirely. C++ changes to `THPGenerator`: - Set `OpaqueBaseMeta` as the metaclass (same pattern as `ProcessGroup`) - Add weakref support (`tp_weaklistoffset` + `weakreflist` field) - Add `tp_richcompare` (identity-based `__eq__`/`__ne__`) - Add `tp_hash` (identity-based) - Add `__fx_repr__` method for FX codegen Also fixes `THPModule_addDocStr` to use `PyType_Check(obj)` instead of `Py_TYPE(obj) == &PyType_Type`, since Generator's metaclass is now `OpaqueBaseMeta` rather than `type`. With these changes, `torch._C.Generator` is registered directly via `register_opaque_type(torch._C.Generator, typ="value")` and flows through `make_fx`, FX codegen, and the repro infrastructure without any wrapper. Authored with Claude. ### Test plan - `python test/dynamo/test_after_aot.py` (all 6 tests) - `python test/inductor/test_torchinductor.py -k test_randn_generator_cuda` - `python test/test_opaque_obj_v2.py TestOpaqueGenerator` (make_fx + correctness) - ` python test/test_torch.py -k test_pickle_generator` (generator can be pickled) - `python test/dynamo/test_dynamic_shapes.py -k test_user_getattr1_dynamic_shapes` - `python agent_space/repro.py` (end-to-end repro) - `python test/test_fx.py -k test_impure_random` (Generator is a C type, it has __init__ without __code__) - `python test/dynamo/test_misc.py -k test_torch_generator_initial_seed` cc voznesenskym penguinwu EikanWang jgong5 Guobing-Chen XiaobingSuper zhuhaozhe blzheng wenzhe-nrv jiayisunx ipiszy kadeng muchulee8 amjames chauhang aakhundov coconutruben jataylo Lucaskabela azahed98 [ghstack-poisoned]
### Summary Replaces the `OpaqueGenerator` Python wrapper from #179658 by making `torch._C.Generator` itself a proper opaque reference type. This eliminates the wrapper class entirely. C++ changes to `THPGenerator`: - Set `OpaqueBaseMeta` as the metaclass (same pattern as `ProcessGroup`) - Add weakref support (`tp_weaklistoffset` + `weakreflist` field) - Add `tp_richcompare` (identity-based `__eq__`/`__ne__`) - Add `tp_hash` (identity-based) - Add `__fx_repr__` method for FX codegen Also fixes `THPModule_addDocStr` to use `PyType_Check(obj)` instead of `Py_TYPE(obj) == &PyType_Type`, since Generator's metaclass is now `OpaqueBaseMeta` rather than `type`. With these changes, `torch._C.Generator` is registered directly via `register_opaque_type(torch._C.Generator, typ="value")` and flows through `make_fx`, FX codegen, and the repro infrastructure without any wrapper. Authored with Claude. ### Test plan - `python test/dynamo/test_after_aot.py` (all 6 tests) - `python test/inductor/test_torchinductor.py -k test_randn_generator_cuda` - `python test/test_opaque_obj_v2.py TestOpaqueGenerator` (make_fx + correctness) - ` python test/test_torch.py -k test_pickle_generator` (generator can be pickled) - `python test/dynamo/test_dynamic_shapes.py -k test_user_getattr1_dynamic_shapes` - `python agent_space/repro.py` (end-to-end repro) - `python test/test_fx.py -k test_impure_random` (Generator is a C type, it has __init__ without __code__) - `python test/dynamo/test_misc.py -k test_torch_generator_initial_seed` cc voznesenskym penguinwu EikanWang jgong5 Guobing-Chen XiaobingSuper zhuhaozhe blzheng wenzhe-nrv jiayisunx ipiszy kadeng muchulee8 amjames chauhang aakhundov coconutruben jataylo Lucaskabela azahed98 [ghstack-poisoned]
### Summary Replaces the `OpaqueGenerator` Python wrapper from #179658 by making `torch._C.Generator` itself a proper opaque reference type. This eliminates the wrapper class entirely. C++ changes to `THPGenerator`: - Set `OpaqueBaseMeta` as the metaclass (same pattern as `ProcessGroup`) - Add weakref support (`tp_weaklistoffset` + `weakreflist` field) - Add `tp_richcompare` (identity-based `__eq__`/`__ne__`) - Add `tp_hash` (identity-based) - Add `__fx_repr__` method for FX codegen Also fixes `THPModule_addDocStr` to use `PyType_Check(obj)` instead of `Py_TYPE(obj) == &PyType_Type`, since Generator's metaclass is now `OpaqueBaseMeta` rather than `type`. With these changes, `torch._C.Generator` is registered directly via `register_opaque_type(torch._C.Generator, typ="value")` and flows through `make_fx`, FX codegen, and the repro infrastructure without any wrapper. Authored with Claude. ### Test plan - `python test/dynamo/test_after_aot.py` (all 6 tests) - `python test/inductor/test_torchinductor.py -k test_randn_generator_cuda` - `python test/test_opaque_obj_v2.py TestOpaqueGenerator` (make_fx + correctness) - ` python test/test_torch.py -k test_pickle_generator` (generator can be pickled) - `python test/dynamo/test_dynamic_shapes.py -k test_user_getattr1_dynamic_shapes` - `python agent_space/repro.py` (end-to-end repro) - `python test/test_fx.py -k test_impure_random` (Generator is a C type, it has __init__ without __code__) - `python test/dynamo/test_misc.py -k test_torch_generator_initial_seed` Pull Request resolved: #179661 Approved by: https://github.com/angelayi
### Summary Replaces the `OpaqueGenerator` Python wrapper from #179658 by making `torch._C.Generator` itself a proper opaque reference type. This eliminates the wrapper class entirely. C++ changes to `THPGenerator`: - Set `OpaqueBaseMeta` as the metaclass (same pattern as `ProcessGroup`) - Add weakref support (`tp_weaklistoffset` + `weakreflist` field) - Add `tp_richcompare` (identity-based `__eq__`/`__ne__`) - Add `tp_hash` (identity-based) - Add `__fx_repr__` method for FX codegen Also fixes `THPModule_addDocStr` to use `PyType_Check(obj)` instead of `Py_TYPE(obj) == &PyType_Type`, since Generator's metaclass is now `OpaqueBaseMeta` rather than `type`. With these changes, `torch._C.Generator` is registered directly via `register_opaque_type(torch._C.Generator, typ="value")` and flows through `make_fx`, FX codegen, and the repro infrastructure without any wrapper. Authored with Claude. ### Test plan - `python test/dynamo/test_after_aot.py` (all 6 tests) - `python test/inductor/test_torchinductor.py -k test_randn_generator_cuda` - `python test/test_opaque_obj_v2.py TestOpaqueGenerator` (make_fx + correctness) - ` python test/test_torch.py -k test_pickle_generator` (generator can be pickled) - `python test/dynamo/test_dynamic_shapes.py -k test_user_getattr1_dynamic_shapes` - `python agent_space/repro.py` (end-to-end repro) - `python test/test_fx.py -k test_impure_random` (Generator is a C type, it has __init__ without __code__) - `python test/dynamo/test_misc.py -k test_torch_generator_initial_seed` Pull Request resolved: #179661 Approved by: https://github.com/angelayi
|
Looks like this PR hasn't been updated in a while so we're going to go ahead and mark this as |
### Summary Replaces the `OpaqueGenerator` Python wrapper from pytorch#179658 by making `torch._C.Generator` itself a proper opaque reference type. This eliminates the wrapper class entirely. C++ changes to `THPGenerator`: - Set `OpaqueBaseMeta` as the metaclass (same pattern as `ProcessGroup`) - Add weakref support (`tp_weaklistoffset` + `weakreflist` field) - Add `tp_richcompare` (identity-based `__eq__`/`__ne__`) - Add `tp_hash` (identity-based) - Add `__fx_repr__` method for FX codegen Also fixes `THPModule_addDocStr` to use `PyType_Check(obj)` instead of `Py_TYPE(obj) == &PyType_Type`, since Generator's metaclass is now `OpaqueBaseMeta` rather than `type`. With these changes, `torch._C.Generator` is registered directly via `register_opaque_type(torch._C.Generator, typ="value")` and flows through `make_fx`, FX codegen, and the repro infrastructure without any wrapper. Authored with Claude. ### Test plan - `python test/dynamo/test_after_aot.py` (all 6 tests) - `python test/inductor/test_torchinductor.py -k test_randn_generator_cuda` - `python test/test_opaque_obj_v2.py TestOpaqueGenerator` (make_fx + correctness) - ` python test/test_torch.py -k test_pickle_generator` (generator can be pickled) - `python test/dynamo/test_dynamic_shapes.py -k test_user_getattr1_dynamic_shapes` - `python agent_space/repro.py` (end-to-end repro) - `python test/test_fx.py -k test_impure_random` (Generator is a C type, it has __init__ without __code__) - `python test/dynamo/test_misc.py -k test_torch_generator_initial_seed` Pull Request resolved: pytorch#179661 Approved by: https://github.com/angelayi
### Summary Replaces the `OpaqueGenerator` Python wrapper from pytorch#179658 by making `torch._C.Generator` itself a proper opaque reference type. This eliminates the wrapper class entirely. C++ changes to `THPGenerator`: - Set `OpaqueBaseMeta` as the metaclass (same pattern as `ProcessGroup`) - Add weakref support (`tp_weaklistoffset` + `weakreflist` field) - Add `tp_richcompare` (identity-based `__eq__`/`__ne__`) - Add `tp_hash` (identity-based) - Add `__fx_repr__` method for FX codegen Also fixes `THPModule_addDocStr` to use `PyType_Check(obj)` instead of `Py_TYPE(obj) == &PyType_Type`, since Generator's metaclass is now `OpaqueBaseMeta` rather than `type`. With these changes, `torch._C.Generator` is registered directly via `register_opaque_type(torch._C.Generator, typ="value")` and flows through `make_fx`, FX codegen, and the repro infrastructure without any wrapper. Authored with Claude. ### Test plan - `python test/dynamo/test_after_aot.py` (all 6 tests) - `python test/inductor/test_torchinductor.py -k test_randn_generator_cuda` - `python test/test_opaque_obj_v2.py TestOpaqueGenerator` (make_fx + correctness) - ` python test/test_torch.py -k test_pickle_generator` (generator can be pickled) - `python test/dynamo/test_dynamic_shapes.py -k test_user_getattr1_dynamic_shapes` - `python agent_space/repro.py` (end-to-end repro) - `python test/test_fx.py -k test_impure_random` (Generator is a C type, it has __init__ without __code__) - `python test/dynamo/test_misc.py -k test_torch_generator_initial_seed` Pull Request resolved: pytorch#179661 Approved by: https://github.com/angelayi
### Summary Replaces the `OpaqueGenerator` Python wrapper from pytorch#179658 by making `torch._C.Generator` itself a proper opaque reference type. This eliminates the wrapper class entirely. C++ changes to `THPGenerator`: - Set `OpaqueBaseMeta` as the metaclass (same pattern as `ProcessGroup`) - Add weakref support (`tp_weaklistoffset` + `weakreflist` field) - Add `tp_richcompare` (identity-based `__eq__`/`__ne__`) - Add `tp_hash` (identity-based) - Add `__fx_repr__` method for FX codegen Also fixes `THPModule_addDocStr` to use `PyType_Check(obj)` instead of `Py_TYPE(obj) == &PyType_Type`, since Generator's metaclass is now `OpaqueBaseMeta` rather than `type`. With these changes, `torch._C.Generator` is registered directly via `register_opaque_type(torch._C.Generator, typ="value")` and flows through `make_fx`, FX codegen, and the repro infrastructure without any wrapper. Authored with Claude. ### Test plan - `python test/dynamo/test_after_aot.py` (all 6 tests) - `python test/inductor/test_torchinductor.py -k test_randn_generator_cuda` - `python test/test_opaque_obj_v2.py TestOpaqueGenerator` (make_fx + correctness) - ` python test/test_torch.py -k test_pickle_generator` (generator can be pickled) - `python test/dynamo/test_dynamic_shapes.py -k test_user_getattr1_dynamic_shapes` - `python agent_space/repro.py` (end-to-end repro) - `python test/test_fx.py -k test_impure_random` (Generator is a C type, it has __init__ without __code__) - `python test/dynamo/test_misc.py -k test_torch_generator_initial_seed` Pull Request resolved: pytorch#179661 Approved by: https://github.com/angelayi
### Summary Replaces the `OpaqueGenerator` Python wrapper from pytorch#179658 by making `torch._C.Generator` itself a proper opaque reference type. This eliminates the wrapper class entirely. C++ changes to `THPGenerator`: - Set `OpaqueBaseMeta` as the metaclass (same pattern as `ProcessGroup`) - Add weakref support (`tp_weaklistoffset` + `weakreflist` field) - Add `tp_richcompare` (identity-based `__eq__`/`__ne__`) - Add `tp_hash` (identity-based) - Add `__fx_repr__` method for FX codegen Also fixes `THPModule_addDocStr` to use `PyType_Check(obj)` instead of `Py_TYPE(obj) == &PyType_Type`, since Generator's metaclass is now `OpaqueBaseMeta` rather than `type`. With these changes, `torch._C.Generator` is registered directly via `register_opaque_type(torch._C.Generator, typ="value")` and flows through `make_fx`, FX codegen, and the repro infrastructure without any wrapper. Authored with Claude. ### Test plan - `python test/dynamo/test_after_aot.py` (all 6 tests) - `python test/inductor/test_torchinductor.py -k test_randn_generator_cuda` - `python test/test_opaque_obj_v2.py TestOpaqueGenerator` (make_fx + correctness) - ` python test/test_torch.py -k test_pickle_generator` (generator can be pickled) - `python test/dynamo/test_dynamic_shapes.py -k test_user_getattr1_dynamic_shapes` - `python agent_space/repro.py` (end-to-end repro) - `python test/test_fx.py -k test_impure_random` (Generator is a C type, it has __init__ without __code__) - `python test/dynamo/test_misc.py -k test_torch_generator_initial_seed` Pull Request resolved: pytorch#179661 Approved by: https://github.com/angelayi
### Summary Replaces the `OpaqueGenerator` Python wrapper from pytorch#179658 by making `torch._C.Generator` itself a proper opaque reference type. This eliminates the wrapper class entirely. C++ changes to `THPGenerator`: - Set `OpaqueBaseMeta` as the metaclass (same pattern as `ProcessGroup`) - Add weakref support (`tp_weaklistoffset` + `weakreflist` field) - Add `tp_richcompare` (identity-based `__eq__`/`__ne__`) - Add `tp_hash` (identity-based) - Add `__fx_repr__` method for FX codegen Also fixes `THPModule_addDocStr` to use `PyType_Check(obj)` instead of `Py_TYPE(obj) == &PyType_Type`, since Generator's metaclass is now `OpaqueBaseMeta` rather than `type`. With these changes, `torch._C.Generator` is registered directly via `register_opaque_type(torch._C.Generator, typ="value")` and flows through `make_fx`, FX codegen, and the repro infrastructure without any wrapper. Authored with Claude. ### Test plan - `python test/dynamo/test_after_aot.py` (all 6 tests) - `python test/inductor/test_torchinductor.py -k test_randn_generator_cuda` - `python test/test_opaque_obj_v2.py TestOpaqueGenerator` (make_fx + correctness) - ` python test/test_torch.py -k test_pickle_generator` (generator can be pickled) - `python test/dynamo/test_dynamic_shapes.py -k test_user_getattr1_dynamic_shapes` - `python agent_space/repro.py` (end-to-end repro) - `python test/test_fx.py -k test_impure_random` (Generator is a C type, it has __init__ without __code__) - `python test/dynamo/test_misc.py -k test_torch_generator_initial_seed` Pull Request resolved: pytorch#179661 Approved by: https://github.com/angelayi
### Summary Replaces the `OpaqueGenerator` Python wrapper from pytorch#179658 by making `torch._C.Generator` itself a proper opaque reference type. This eliminates the wrapper class entirely. C++ changes to `THPGenerator`: - Set `OpaqueBaseMeta` as the metaclass (same pattern as `ProcessGroup`) - Add weakref support (`tp_weaklistoffset` + `weakreflist` field) - Add `tp_richcompare` (identity-based `__eq__`/`__ne__`) - Add `tp_hash` (identity-based) - Add `__fx_repr__` method for FX codegen Also fixes `THPModule_addDocStr` to use `PyType_Check(obj)` instead of `Py_TYPE(obj) == &PyType_Type`, since Generator's metaclass is now `OpaqueBaseMeta` rather than `type`. With these changes, `torch._C.Generator` is registered directly via `register_opaque_type(torch._C.Generator, typ="value")` and flows through `make_fx`, FX codegen, and the repro infrastructure without any wrapper. Authored with Claude. ### Test plan - `python test/dynamo/test_after_aot.py` (all 6 tests) - `python test/inductor/test_torchinductor.py -k test_randn_generator_cuda` - `python test/test_opaque_obj_v2.py TestOpaqueGenerator` (make_fx + correctness) - ` python test/test_torch.py -k test_pickle_generator` (generator can be pickled) - `python test/dynamo/test_dynamic_shapes.py -k test_user_getattr1_dynamic_shapes` - `python agent_space/repro.py` (end-to-end repro) - `python test/test_fx.py -k test_impure_random` (Generator is a C type, it has __init__ without __code__) Pull Request resolved: pytorch#179661 Approved by: https://github.com/angelayi ghstack dependencies: pytorch#179657
### Summary Replaces the `OpaqueGenerator` Python wrapper from pytorch#179658 by making `torch._C.Generator` itself a proper opaque reference type. This eliminates the wrapper class entirely. C++ changes to `THPGenerator`: - Set `OpaqueBaseMeta` as the metaclass (same pattern as `ProcessGroup`) - Add weakref support (`tp_weaklistoffset` + `weakreflist` field) - Add `tp_richcompare` (identity-based `__eq__`/`__ne__`) - Add `tp_hash` (identity-based) - Add `__fx_repr__` method for FX codegen Also fixes `THPModule_addDocStr` to use `PyType_Check(obj)` instead of `Py_TYPE(obj) == &PyType_Type`, since Generator's metaclass is now `OpaqueBaseMeta` rather than `type`. With these changes, `torch._C.Generator` is registered directly via `register_opaque_type(torch._C.Generator, typ="value")` and flows through `make_fx`, FX codegen, and the repro infrastructure without any wrapper. Authored with Claude. ### Test plan - `python test/dynamo/test_after_aot.py` (all 6 tests) - `python test/inductor/test_torchinductor.py -k test_randn_generator_cuda` - `python test/test_opaque_obj_v2.py TestOpaqueGenerator` (make_fx + correctness) - ` python test/test_torch.py -k test_pickle_generator` (generator can be pickled) - `python test/dynamo/test_dynamic_shapes.py -k test_user_getattr1_dynamic_shapes` - `python agent_space/repro.py` (end-to-end repro) - `python test/test_fx.py -k test_impure_random` (Generator is a C type, it has __init__ without __code__) - `python test/dynamo/test_misc.py -k test_torch_generator_initial_seed` Pull Request resolved: pytorch#179661 Approved by: https://github.com/angelayi
### Summary Replaces the `OpaqueGenerator` Python wrapper from pytorch#179658 by making `torch._C.Generator` itself a proper opaque reference type. This eliminates the wrapper class entirely. C++ changes to `THPGenerator`: - Set `OpaqueBaseMeta` as the metaclass (same pattern as `ProcessGroup`) - Add weakref support (`tp_weaklistoffset` + `weakreflist` field) - Add `tp_richcompare` (identity-based `__eq__`/`__ne__`) - Add `tp_hash` (identity-based) - Add `__fx_repr__` method for FX codegen Also fixes `THPModule_addDocStr` to use `PyType_Check(obj)` instead of `Py_TYPE(obj) == &PyType_Type`, since Generator's metaclass is now `OpaqueBaseMeta` rather than `type`. With these changes, `torch._C.Generator` is registered directly via `register_opaque_type(torch._C.Generator, typ="value")` and flows through `make_fx`, FX codegen, and the repro infrastructure without any wrapper. Authored with Claude. ### Test plan - `python test/dynamo/test_after_aot.py` (all 6 tests) - `python test/inductor/test_torchinductor.py -k test_randn_generator_cuda` - `python test/test_opaque_obj_v2.py TestOpaqueGenerator` (make_fx + correctness) - ` python test/test_torch.py -k test_pickle_generator` (generator can be pickled) - `python test/dynamo/test_dynamic_shapes.py -k test_user_getattr1_dynamic_shapes` - `python agent_space/repro.py` (end-to-end repro) - `python test/test_fx.py -k test_impure_random` (Generator is a C type, it has __init__ without __code__) - `python test/dynamo/test_misc.py -k test_torch_generator_initial_seed` Pull Request resolved: pytorch#179661 Approved by: https://github.com/angelayi
### Summary Replaces the `OpaqueGenerator` Python wrapper from pytorch#179658 by making `torch._C.Generator` itself a proper opaque reference type. This eliminates the wrapper class entirely. C++ changes to `THPGenerator`: - Set `OpaqueBaseMeta` as the metaclass (same pattern as `ProcessGroup`) - Add weakref support (`tp_weaklistoffset` + `weakreflist` field) - Add `tp_richcompare` (identity-based `__eq__`/`__ne__`) - Add `tp_hash` (identity-based) - Add `__fx_repr__` method for FX codegen Also fixes `THPModule_addDocStr` to use `PyType_Check(obj)` instead of `Py_TYPE(obj) == &PyType_Type`, since Generator's metaclass is now `OpaqueBaseMeta` rather than `type`. With these changes, `torch._C.Generator` is registered directly via `register_opaque_type(torch._C.Generator, typ="value")` and flows through `make_fx`, FX codegen, and the repro infrastructure without any wrapper. Authored with Claude. ### Test plan - `python test/dynamo/test_after_aot.py` (all 6 tests) - `python test/inductor/test_torchinductor.py -k test_randn_generator_cuda` - `python test/test_opaque_obj_v2.py TestOpaqueGenerator` (make_fx + correctness) - ` python test/test_torch.py -k test_pickle_generator` (generator can be pickled) - `python test/dynamo/test_dynamic_shapes.py -k test_user_getattr1_dynamic_shapes` - `python agent_space/repro.py` (end-to-end repro) - `python test/test_fx.py -k test_impure_random` (Generator is a C type, it has __init__ without __code__) - `python test/dynamo/test_misc.py -k test_torch_generator_initial_seed` Pull Request resolved: pytorch#179661 Approved by: https://github.com/angelayi
### Summary Replaces the `OpaqueGenerator` Python wrapper from pytorch#179658 by making `torch._C.Generator` itself a proper opaque reference type. This eliminates the wrapper class entirely. C++ changes to `THPGenerator`: - Set `OpaqueBaseMeta` as the metaclass (same pattern as `ProcessGroup`) - Add weakref support (`tp_weaklistoffset` + `weakreflist` field) - Add `tp_richcompare` (identity-based `__eq__`/`__ne__`) - Add `tp_hash` (identity-based) - Add `__fx_repr__` method for FX codegen Also fixes `THPModule_addDocStr` to use `PyType_Check(obj)` instead of `Py_TYPE(obj) == &PyType_Type`, since Generator's metaclass is now `OpaqueBaseMeta` rather than `type`. With these changes, `torch._C.Generator` is registered directly via `register_opaque_type(torch._C.Generator, typ="value")` and flows through `make_fx`, FX codegen, and the repro infrastructure without any wrapper. Authored with Claude. ### Test plan - `python test/dynamo/test_after_aot.py` (all 6 tests) - `python test/inductor/test_torchinductor.py -k test_randn_generator_cuda` - `python test/test_opaque_obj_v2.py TestOpaqueGenerator` (make_fx + correctness) - ` python test/test_torch.py -k test_pickle_generator` (generator can be pickled) - `python test/dynamo/test_dynamic_shapes.py -k test_user_getattr1_dynamic_shapes` - `python agent_space/repro.py` (end-to-end repro) - `python test/test_fx.py -k test_impure_random` (Generator is a C type, it has __init__ without __code__) - `python test/dynamo/test_misc.py -k test_torch_generator_initial_seed` Pull Request resolved: pytorch#179661 Approved by: https://github.com/angelayi
### Summary Replaces the `OpaqueGenerator` Python wrapper from pytorch#179658 by making `torch._C.Generator` itself a proper opaque reference type. This eliminates the wrapper class entirely. C++ changes to `THPGenerator`: - Set `OpaqueBaseMeta` as the metaclass (same pattern as `ProcessGroup`) - Add weakref support (`tp_weaklistoffset` + `weakreflist` field) - Add `tp_richcompare` (identity-based `__eq__`/`__ne__`) - Add `tp_hash` (identity-based) - Add `__fx_repr__` method for FX codegen Also fixes `THPModule_addDocStr` to use `PyType_Check(obj)` instead of `Py_TYPE(obj) == &PyType_Type`, since Generator's metaclass is now `OpaqueBaseMeta` rather than `type`. With these changes, `torch._C.Generator` is registered directly via `register_opaque_type(torch._C.Generator, typ="value")` and flows through `make_fx`, FX codegen, and the repro infrastructure without any wrapper. Authored with Claude. ### Test plan - `python test/dynamo/test_after_aot.py` (all 6 tests) - `python test/inductor/test_torchinductor.py -k test_randn_generator_cuda` - `python test/test_opaque_obj_v2.py TestOpaqueGenerator` (make_fx + correctness) - ` python test/test_torch.py -k test_pickle_generator` (generator can be pickled) - `python test/dynamo/test_dynamic_shapes.py -k test_user_getattr1_dynamic_shapes` - `python agent_space/repro.py` (end-to-end repro) - `python test/test_fx.py -k test_impure_random` (Generator is a C type, it has __init__ without __code__) - `python test/dynamo/test_misc.py -k test_torch_generator_initial_seed` Pull Request resolved: pytorch#179661 Approved by: https://github.com/angelayi
### Summary Replaces the `OpaqueGenerator` Python wrapper from pytorch#179658 by making `torch._C.Generator` itself a proper opaque reference type. This eliminates the wrapper class entirely. C++ changes to `THPGenerator`: - Set `OpaqueBaseMeta` as the metaclass (same pattern as `ProcessGroup`) - Add weakref support (`tp_weaklistoffset` + `weakreflist` field) - Add `tp_richcompare` (identity-based `__eq__`/`__ne__`) - Add `tp_hash` (identity-based) - Add `__fx_repr__` method for FX codegen Also fixes `THPModule_addDocStr` to use `PyType_Check(obj)` instead of `Py_TYPE(obj) == &PyType_Type`, since Generator's metaclass is now `OpaqueBaseMeta` rather than `type`. With these changes, `torch._C.Generator` is registered directly via `register_opaque_type(torch._C.Generator, typ="value")` and flows through `make_fx`, FX codegen, and the repro infrastructure without any wrapper. Authored with Claude. ### Test plan - `python test/dynamo/test_after_aot.py` (all 6 tests) - `python test/inductor/test_torchinductor.py -k test_randn_generator_cuda` - `python test/test_opaque_obj_v2.py TestOpaqueGenerator` (make_fx + correctness) - ` python test/test_torch.py -k test_pickle_generator` (generator can be pickled) - `python test/dynamo/test_dynamic_shapes.py -k test_user_getattr1_dynamic_shapes` - `python agent_space/repro.py` (end-to-end repro) - `python test/test_fx.py -k test_impure_random` (Generator is a C type, it has __init__ without __code__) Pull Request resolved: pytorch#179661 Approved by: https://github.com/angelayi ghstack dependencies: pytorch#179657
### Summary Replaces the `OpaqueGenerator` Python wrapper from pytorch#179658 by making `torch._C.Generator` itself a proper opaque reference type. This eliminates the wrapper class entirely. C++ changes to `THPGenerator`: - Set `OpaqueBaseMeta` as the metaclass (same pattern as `ProcessGroup`) - Add weakref support (`tp_weaklistoffset` + `weakreflist` field) - Add `tp_richcompare` (identity-based `__eq__`/`__ne__`) - Add `tp_hash` (identity-based) - Add `__fx_repr__` method for FX codegen Also fixes `THPModule_addDocStr` to use `PyType_Check(obj)` instead of `Py_TYPE(obj) == &PyType_Type`, since Generator's metaclass is now `OpaqueBaseMeta` rather than `type`. With these changes, `torch._C.Generator` is registered directly via `register_opaque_type(torch._C.Generator, typ="value")` and flows through `make_fx`, FX codegen, and the repro infrastructure without any wrapper. Authored with Claude. ### Test plan - `python test/dynamo/test_after_aot.py` (all 6 tests) - `python test/inductor/test_torchinductor.py -k test_randn_generator_cuda` - `python test/test_opaque_obj_v2.py TestOpaqueGenerator` (make_fx + correctness) - ` python test/test_torch.py -k test_pickle_generator` (generator can be pickled) - `python test/dynamo/test_dynamic_shapes.py -k test_user_getattr1_dynamic_shapes` - `python agent_space/repro.py` (end-to-end repro) - `python test/test_fx.py -k test_impure_random` (Generator is a C type, it has __init__ without __code__) - `python test/dynamo/test_misc.py -k test_torch_generator_initial_seed` Pull Request resolved: pytorch#179661 Approved by: https://github.com/angelayi
### Summary Replaces the `OpaqueGenerator` Python wrapper from pytorch#179658 by making `torch._C.Generator` itself a proper opaque reference type. This eliminates the wrapper class entirely. C++ changes to `THPGenerator`: - Set `OpaqueBaseMeta` as the metaclass (same pattern as `ProcessGroup`) - Add weakref support (`tp_weaklistoffset` + `weakreflist` field) - Add `tp_richcompare` (identity-based `__eq__`/`__ne__`) - Add `tp_hash` (identity-based) - Add `__fx_repr__` method for FX codegen Also fixes `THPModule_addDocStr` to use `PyType_Check(obj)` instead of `Py_TYPE(obj) == &PyType_Type`, since Generator's metaclass is now `OpaqueBaseMeta` rather than `type`. With these changes, `torch._C.Generator` is registered directly via `register_opaque_type(torch._C.Generator, typ="value")` and flows through `make_fx`, FX codegen, and the repro infrastructure without any wrapper. Authored with Claude. ### Test plan - `python test/dynamo/test_after_aot.py` (all 6 tests) - `python test/inductor/test_torchinductor.py -k test_randn_generator_cuda` - `python test/test_opaque_obj_v2.py TestOpaqueGenerator` (make_fx + correctness) - ` python test/test_torch.py -k test_pickle_generator` (generator can be pickled) - `python test/dynamo/test_dynamic_shapes.py -k test_user_getattr1_dynamic_shapes` - `python agent_space/repro.py` (end-to-end repro) - `python test/test_fx.py -k test_impure_random` (Generator is a C type, it has __init__ without __code__) - `python test/dynamo/test_misc.py -k test_torch_generator_initial_seed` Pull Request resolved: pytorch#179661 Approved by: https://github.com/angelayi
### Summary Replaces the `OpaqueGenerator` Python wrapper from pytorch#179658 by making `torch._C.Generator` itself a proper opaque reference type. This eliminates the wrapper class entirely. C++ changes to `THPGenerator`: - Set `OpaqueBaseMeta` as the metaclass (same pattern as `ProcessGroup`) - Add weakref support (`tp_weaklistoffset` + `weakreflist` field) - Add `tp_richcompare` (identity-based `__eq__`/`__ne__`) - Add `tp_hash` (identity-based) - Add `__fx_repr__` method for FX codegen Also fixes `THPModule_addDocStr` to use `PyType_Check(obj)` instead of `Py_TYPE(obj) == &PyType_Type`, since Generator's metaclass is now `OpaqueBaseMeta` rather than `type`. With these changes, `torch._C.Generator` is registered directly via `register_opaque_type(torch._C.Generator, typ="value")` and flows through `make_fx`, FX codegen, and the repro infrastructure without any wrapper. Authored with Claude. ### Test plan - `python test/dynamo/test_after_aot.py` (all 6 tests) - `python test/inductor/test_torchinductor.py -k test_randn_generator_cuda` - `python test/test_opaque_obj_v2.py TestOpaqueGenerator` (make_fx + correctness) - ` python test/test_torch.py -k test_pickle_generator` (generator can be pickled) - `python test/dynamo/test_dynamic_shapes.py -k test_user_getattr1_dynamic_shapes` - `python agent_space/repro.py` (end-to-end repro) - `python test/test_fx.py -k test_impure_random` (Generator is a C type, it has __init__ without __code__) - `python test/dynamo/test_misc.py -k test_torch_generator_initial_seed` Pull Request resolved: pytorch#179661 Approved by: https://github.com/angelayi
### Summary Replaces the `OpaqueGenerator` Python wrapper from pytorch#179658 by making `torch._C.Generator` itself a proper opaque reference type. This eliminates the wrapper class entirely. C++ changes to `THPGenerator`: - Set `OpaqueBaseMeta` as the metaclass (same pattern as `ProcessGroup`) - Add weakref support (`tp_weaklistoffset` + `weakreflist` field) - Add `tp_richcompare` (identity-based `__eq__`/`__ne__`) - Add `tp_hash` (identity-based) - Add `__fx_repr__` method for FX codegen Also fixes `THPModule_addDocStr` to use `PyType_Check(obj)` instead of `Py_TYPE(obj) == &PyType_Type`, since Generator's metaclass is now `OpaqueBaseMeta` rather than `type`. With these changes, `torch._C.Generator` is registered directly via `register_opaque_type(torch._C.Generator, typ="value")` and flows through `make_fx`, FX codegen, and the repro infrastructure without any wrapper. Authored with Claude. ### Test plan - `python test/dynamo/test_after_aot.py` (all 6 tests) - `python test/inductor/test_torchinductor.py -k test_randn_generator_cuda` - `python test/test_opaque_obj_v2.py TestOpaqueGenerator` (make_fx + correctness) - ` python test/test_torch.py -k test_pickle_generator` (generator can be pickled) - `python test/dynamo/test_dynamic_shapes.py -k test_user_getattr1_dynamic_shapes` - `python agent_space/repro.py` (end-to-end repro) - `python test/test_fx.py -k test_impure_random` (Generator is a C type, it has __init__ without __code__) - `python test/dynamo/test_misc.py -k test_torch_generator_initial_seed` Pull Request resolved: pytorch#179661 Approved by: https://github.com/angelayi
### Summary Replaces the `OpaqueGenerator` Python wrapper from pytorch#179658 by making `torch._C.Generator` itself a proper opaque reference type. This eliminates the wrapper class entirely. C++ changes to `THPGenerator`: - Set `OpaqueBaseMeta` as the metaclass (same pattern as `ProcessGroup`) - Add weakref support (`tp_weaklistoffset` + `weakreflist` field) - Add `tp_richcompare` (identity-based `__eq__`/`__ne__`) - Add `tp_hash` (identity-based) - Add `__fx_repr__` method for FX codegen Also fixes `THPModule_addDocStr` to use `PyType_Check(obj)` instead of `Py_TYPE(obj) == &PyType_Type`, since Generator's metaclass is now `OpaqueBaseMeta` rather than `type`. With these changes, `torch._C.Generator` is registered directly via `register_opaque_type(torch._C.Generator, typ="value")` and flows through `make_fx`, FX codegen, and the repro infrastructure without any wrapper. Authored with Claude. ### Test plan - `python test/dynamo/test_after_aot.py` (all 6 tests) - `python test/inductor/test_torchinductor.py -k test_randn_generator_cuda` - `python test/test_opaque_obj_v2.py TestOpaqueGenerator` (make_fx + correctness) - ` python test/test_torch.py -k test_pickle_generator` (generator can be pickled) - `python test/dynamo/test_dynamic_shapes.py -k test_user_getattr1_dynamic_shapes` - `python agent_space/repro.py` (end-to-end repro) - `python test/test_fx.py -k test_impure_random` (Generator is a C type, it has __init__ without __code__) - `python test/dynamo/test_misc.py -k test_torch_generator_initial_seed` Pull Request resolved: pytorch#179661 Approved by: https://github.com/angelayi
Stack from ghstack (oldest at bottom):
Following the context from #179657. Repro scripts call
make_fxto retrace the module into aGraphModule, butmake_fxcouldn't handletorch._C.Generatorarguments — FX's proxyinfrastructure requires weakref support and
create_arg/codegen support thatGenerator lacked.
This introduces
OpaqueGenerator, a wrapper class registered as an opaque valuetype via
register_opaque_type. It implements__eq__,__hash__, and__fx_repr__so FX tracing, proxy tracking, and codegen all work through theexisting opaque type infrastructure without any changes to
torch/fx/. TheInputReaderreturnsOpaqueGeneratorinstances, and the inductor placeholderhandler accepts them alongside raw generators.
Authored with Claude.
Alternatively, we can change
torch._C.Generatoritself to an Opaque Object class, see #179661Test plan
python test/test_opaque_obj_v2.py TestOpaqueGenerator.test_make_fx_with_generatorpython agent_space/repro.py(end-to-end repro withrun_repro)cc @voznesenskym @penguinwu @EikanWang @jgong5 @Guobing-Chen @XiaobingSuper @zhuhaozhe @blzheng @wenzhe-nrv @jiayisunx @ipiszy @kadeng @muchulee8 @amjames @chauhang @aakhundov @coconutruben @jataylo @Lucaskabela @azahed98