Support non-tensor attrs in __tensor_flatten__#176457
Support non-tensor attrs in __tensor_flatten__#176457aorenste wants to merge 13 commits intogh/aorenste/206/basefrom
Conversation
The first return value of __tensor_flatten__ can now contain opaque (non-tensor) values such as DeviceMesh. Opaques flow through the flat arg list alongside tensors: they get indices, become graph inputs/outputs, and are pulled from all_args by position during subclass reconstruction — the same as PlainTensorMeta. An empty OpaqueMeta marker in SubclassCreationMeta.attrs distinguishes opaque slots from tensor slots (needed by process_runtime_tangent, which skips non-differentiable opaques). All code that previously iterated __tensor_flatten__ results and assumed every element was a tensor now handles opaques: subclass_parametrization, non_strict_utils, FSDP _init_utils, common_utils (get_untyped_storages), frontend_utils, and parametrize.py (which stores opaques as plain attributes rather than parameters). Tests added (all in test/test_opaque_obj_v2.py): - test_tensor_subclass_with_opaque_attr_backward - test_tensor_subclass_opaque_backward_compiled_autograd - test_tensor_subclass_shared_opaque_remapping - test_shared_opaque_identity_guard - test_shared_direct_opaque_identity_guard - test_tensor_subclass_shared_opaque_backward - test_deeply_nested_tensor_subclass_with_opaque - test_subclass_parametrization_with_opaque_attrs - test_export_non_strict_with_opaque_attrs - test_get_untyped_storages_with_opaque_attrs - test_subclass_opaque_attrs_cache_hit Authored with Claude. [ghstack-poisoned]
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/176457
Note: Links to docs will display an error until the docs builds have been completed. ✅ You can merge normally! (2 Unrelated Failures)As of commit f583a4b with merge base 9a8ed4e ( BROKEN TRUNK - The following job failed but were present on the merge base:👉 Rebase onto the `viable/strict` branch to avoid these failures
UNSTABLE - The following job is marked as unstable, possibly due to flakiness on trunk:
This comment was automatically generated by Dr. CI and updates every 15 minutes. |
The first return value of __tensor_flatten__ can now contain opaque (non-tensor) values such as DeviceMesh. Opaques flow through the flat arg list alongside tensors: they get indices, become graph inputs/outputs, and are pulled from all_args by position during subclass reconstruction — the same as PlainTensorMeta. An empty OpaqueMeta marker in SubclassCreationMeta.attrs distinguishes opaque slots from tensor slots (needed by process_runtime_tangent, which skips non-differentiable opaques). All code that previously iterated __tensor_flatten__ results and assumed every element was a tensor now handles opaques: subclass_parametrization, non_strict_utils, FSDP _init_utils, common_utils (get_untyped_storages), frontend_utils, and parametrize.py (which stores opaques as plain attributes rather than parameters). Tests added (all in test/test_opaque_obj_v2.py): - test_tensor_subclass_with_opaque_attr_backward - test_tensor_subclass_opaque_backward_compiled_autograd - test_tensor_subclass_shared_opaque_remapping - test_shared_opaque_identity_guard - test_shared_direct_opaque_identity_guard - test_tensor_subclass_shared_opaque_backward - test_deeply_nested_tensor_subclass_with_opaque - test_subclass_parametrization_with_opaque_attrs - test_export_non_strict_with_opaque_attrs - test_get_untyped_storages_with_opaque_attrs - test_subclass_opaque_attrs_cache_hit Authored with Claude. ghstack-source-id: f485fef Pull Request resolved: #176457
The first return value of `__tensor_flatten__` can now contain opaque (non-tensor) values such as DeviceMesh. Opaques flow through the flat arg list alongside tensors: they get indices, become graph inputs/outputs, and are pulled from all_args by position during subclass reconstruction — the same as PlainTensorMeta. An empty OpaqueMeta marker in SubclassCreationMeta.attrs distinguishes opaque slots from tensor slots (needed by process_runtime_tangent, which skips non-differentiable opaques). All code that previously iterated `__tensor_flatten__` results and assumed every element was a tensor now handles opaques: subclass_parametrization, non_strict_utils, FSDP _init_utils, common_utils (get_untyped_storages), frontend_utils, and parametrize.py (which stores opaques as plain attributes rather than parameters). Tests added (all in test/test_opaque_obj_v2.py): - test_tensor_subclass_with_opaque_attr_backward - test_tensor_subclass_opaque_backward_compiled_autograd - test_tensor_subclass_shared_opaque_remapping - test_shared_opaque_identity_guard - test_shared_direct_opaque_identity_guard - test_tensor_subclass_shared_opaque_backward - test_deeply_nested_tensor_subclass_with_opaque - test_subclass_parametrization_with_opaque_attrs - test_export_non_strict_with_opaque_attrs - test_get_untyped_storages_with_opaque_attrs - test_subclass_opaque_attrs_cache_hit Authored with Claude. cc voznesenskym penguinwu EikanWang jgong5 Guobing-Chen XiaobingSuper zhuhaozhe blzheng wenzhe-nrv jiayisunx kadeng chauhang amjames Lucaskabela jataylo [ghstack-poisoned]
The first return value of __tensor_flatten__ can now contain opaque (non-tensor) values such as DeviceMesh. Opaques flow through the flat arg list alongside tensors: they get indices, become graph inputs/outputs, and are pulled from all_args by position during subclass reconstruction — the same as PlainTensorMeta. An empty OpaqueMeta marker in SubclassCreationMeta.attrs distinguishes opaque slots from tensor slots (needed by process_runtime_tangent, which skips non-differentiable opaques). All code that previously iterated __tensor_flatten__ results and assumed every element was a tensor now handles opaques: subclass_parametrization, non_strict_utils, FSDP _init_utils, common_utils (get_untyped_storages), frontend_utils, and parametrize.py (which stores opaques as plain attributes rather than parameters). Tests added (all in test/test_opaque_obj_v2.py): - test_tensor_subclass_with_opaque_attr_backward - test_tensor_subclass_opaque_backward_compiled_autograd - test_tensor_subclass_shared_opaque_remapping - test_shared_opaque_identity_guard - test_shared_direct_opaque_identity_guard - test_tensor_subclass_shared_opaque_backward - test_deeply_nested_tensor_subclass_with_opaque - test_subclass_parametrization_with_opaque_attrs - test_export_non_strict_with_opaque_attrs - test_get_untyped_storages_with_opaque_attrs - test_subclass_opaque_attrs_cache_hit Authored with Claude. ghstack-source-id: a18076d Pull Request resolved: #176457
The first return value of `__tensor_flatten__` can now contain opaque (non-tensor) values such as DeviceMesh. Opaques flow through the flat arg list alongside tensors: they get indices, become graph inputs/outputs, and are pulled from all_args by position during subclass reconstruction — the same as PlainTensorMeta. An empty OpaqueMeta marker in SubclassCreationMeta.attrs distinguishes opaque slots from tensor slots (needed by process_runtime_tangent, which skips non-differentiable opaques). All code that previously iterated `__tensor_flatten__` results and assumed every element was a tensor now handles opaques: subclass_parametrization, non_strict_utils, FSDP _init_utils, common_utils (get_untyped_storages), frontend_utils, and parametrize.py (which stores opaques as plain attributes rather than parameters). Tests added (all in test/test_opaque_obj_v2.py): - test_tensor_subclass_with_opaque_attr_backward - test_tensor_subclass_opaque_backward_compiled_autograd - test_tensor_subclass_shared_opaque_remapping - test_shared_opaque_identity_guard - test_shared_direct_opaque_identity_guard - test_tensor_subclass_shared_opaque_backward - test_deeply_nested_tensor_subclass_with_opaque - test_subclass_parametrization_with_opaque_attrs - test_export_non_strict_with_opaque_attrs - test_get_untyped_storages_with_opaque_attrs - test_subclass_opaque_attrs_cache_hit - test_value_type_opaque_in_tensor_attrs_errors Authored with Claude. cc voznesenskym penguinwu EikanWang jgong5 Guobing-Chen XiaobingSuper zhuhaozhe blzheng wenzhe-nrv jiayisunx kadeng chauhang amjames Lucaskabela jataylo [ghstack-poisoned]
The first return value of __tensor_flatten__ can now contain opaque (non-tensor) values such as DeviceMesh. Opaques flow through the flat arg list alongside tensors: they get indices, become graph inputs/outputs, and are pulled from all_args by position during subclass reconstruction — the same as PlainTensorMeta. An empty OpaqueMeta marker in SubclassCreationMeta.attrs distinguishes opaque slots from tensor slots (needed by process_runtime_tangent, which skips non-differentiable opaques). All code that previously iterated __tensor_flatten__ results and assumed every element was a tensor now handles opaques: subclass_parametrization, non_strict_utils, FSDP _init_utils, common_utils (get_untyped_storages), frontend_utils, and parametrize.py (which stores opaques as plain attributes rather than parameters). Tests added (all in test/test_opaque_obj_v2.py): - test_tensor_subclass_with_opaque_attr_backward - test_tensor_subclass_opaque_backward_compiled_autograd - test_tensor_subclass_shared_opaque_remapping - test_shared_opaque_identity_guard - test_shared_direct_opaque_identity_guard - test_tensor_subclass_shared_opaque_backward - test_deeply_nested_tensor_subclass_with_opaque - test_subclass_parametrization_with_opaque_attrs - test_export_non_strict_with_opaque_attrs - test_get_untyped_storages_with_opaque_attrs - test_subclass_opaque_attrs_cache_hit Authored with Claude. ghstack-source-id: 47dad0f Pull Request resolved: #176457
The first return value of `__tensor_flatten__` can now contain opaque (non-tensor) values such as DeviceMesh. Opaques flow through the flat arg list alongside tensors: they get indices, become graph inputs/outputs, and are pulled from all_args by position during subclass reconstruction — the same as PlainTensorMeta. An empty OpaqueMeta marker in SubclassCreationMeta.attrs distinguishes opaque slots from tensor slots (needed by process_runtime_tangent, which skips non-differentiable opaques). All code that previously iterated `__tensor_flatten__` results and assumed every element was a tensor now handles opaques: subclass_parametrization, non_strict_utils, FSDP _init_utils, common_utils (get_untyped_storages), frontend_utils, and parametrize.py (which stores opaques as plain attributes rather than parameters). Tests added (all in test/test_opaque_obj_v2.py): - test_tensor_subclass_with_opaque_attr_backward - test_tensor_subclass_opaque_backward_compiled_autograd - test_tensor_subclass_shared_opaque_remapping - test_shared_opaque_identity_guard - test_shared_direct_opaque_identity_guard - test_tensor_subclass_shared_opaque_backward - test_deeply_nested_tensor_subclass_with_opaque - test_subclass_parametrization_with_opaque_attrs - test_export_non_strict_with_opaque_attrs - test_get_untyped_storages_with_opaque_attrs - test_subclass_opaque_attrs_cache_hit - test_value_type_opaque_in_tensor_attrs_errors Authored with Claude. cc voznesenskym penguinwu EikanWang jgong5 Guobing-Chen XiaobingSuper zhuhaozhe blzheng wenzhe-nrv jiayisunx kadeng chauhang amjames Lucaskabela jataylo [ghstack-poisoned]
The first return value of __tensor_flatten__ can now contain opaque (non-tensor) values such as DeviceMesh. Opaques flow through the flat arg list alongside tensors: they get indices, become graph inputs/outputs, and are pulled from all_args by position during subclass reconstruction — the same as PlainTensorMeta. An empty OpaqueMeta marker in SubclassCreationMeta.attrs distinguishes opaque slots from tensor slots (needed by process_runtime_tangent, which skips non-differentiable opaques). All code that previously iterated __tensor_flatten__ results and assumed every element was a tensor now handles opaques: subclass_parametrization, non_strict_utils, FSDP _init_utils, common_utils (get_untyped_storages), frontend_utils, and parametrize.py (which stores opaques as plain attributes rather than parameters). Tests added (all in test/test_opaque_obj_v2.py): - test_tensor_subclass_with_opaque_attr_backward - test_tensor_subclass_opaque_backward_compiled_autograd - test_tensor_subclass_shared_opaque_remapping - test_shared_opaque_identity_guard - test_shared_direct_opaque_identity_guard - test_tensor_subclass_shared_opaque_backward - test_deeply_nested_tensor_subclass_with_opaque - test_subclass_parametrization_with_opaque_attrs - test_export_non_strict_with_opaque_attrs - test_get_untyped_storages_with_opaque_attrs - test_subclass_opaque_attrs_cache_hit Authored with Claude. ghstack-source-id: 2dd7af8 Pull Request resolved: #176457
The first return value of `__tensor_flatten__` can now contain opaque (non-tensor) values such as DeviceMesh. Opaques flow through the flat arg list alongside tensors: they get indices, become graph inputs/outputs, and are pulled from all_args by position during subclass reconstruction — the same as PlainTensorMeta. An empty OpaqueMeta marker in SubclassCreationMeta.attrs distinguishes opaque slots from tensor slots (needed by process_runtime_tangent, which skips non-differentiable opaques). All code that previously iterated `__tensor_flatten__` results and assumed every element was a tensor now handles opaques: subclass_parametrization, non_strict_utils, FSDP _init_utils, common_utils (get_untyped_storages), frontend_utils, and parametrize.py (which stores opaques as plain attributes rather than parameters). Tests added (all in test/test_opaque_obj_v2.py): - test_tensor_subclass_with_opaque_attr_backward - test_tensor_subclass_opaque_backward_compiled_autograd - test_tensor_subclass_shared_opaque_remapping - test_shared_opaque_identity_guard - test_shared_direct_opaque_identity_guard - test_tensor_subclass_shared_opaque_backward - test_deeply_nested_tensor_subclass_with_opaque - test_subclass_parametrization_with_opaque_attrs - test_export_non_strict_with_opaque_attrs - test_get_untyped_storages_with_opaque_attrs - test_subclass_opaque_attrs_cache_hit - test_value_type_opaque_in_tensor_attrs_errors Authored with Claude. cc voznesenskym penguinwu EikanWang jgong5 Guobing-Chen XiaobingSuper zhuhaozhe blzheng wenzhe-nrv jiayisunx kadeng chauhang amjames Lucaskabela jataylo [ghstack-poisoned]
The first return value of __tensor_flatten__ can now contain opaque (non-tensor) values such as DeviceMesh. Opaques flow through the flat arg list alongside tensors: they get indices, become graph inputs/outputs, and are pulled from all_args by position during subclass reconstruction — the same as PlainTensorMeta. An empty OpaqueMeta marker in SubclassCreationMeta.attrs distinguishes opaque slots from tensor slots (needed by process_runtime_tangent, which skips non-differentiable opaques). All code that previously iterated __tensor_flatten__ results and assumed every element was a tensor now handles opaques: subclass_parametrization, non_strict_utils, FSDP _init_utils, common_utils (get_untyped_storages), frontend_utils, and parametrize.py (which stores opaques as plain attributes rather than parameters). Tests added (all in test/test_opaque_obj_v2.py): - test_tensor_subclass_with_opaque_attr_backward - test_tensor_subclass_opaque_backward_compiled_autograd - test_tensor_subclass_shared_opaque_remapping - test_shared_opaque_identity_guard - test_shared_direct_opaque_identity_guard - test_tensor_subclass_shared_opaque_backward - test_deeply_nested_tensor_subclass_with_opaque - test_subclass_parametrization_with_opaque_attrs - test_export_non_strict_with_opaque_attrs - test_get_untyped_storages_with_opaque_attrs - test_subclass_opaque_attrs_cache_hit Authored with Claude. ghstack-source-id: 2dd7af8 Pull Request resolved: #176457
The first return value of __tensor_flatten__ can now contain opaque (non-tensor) values such as DeviceMesh. Opaques flow through the flat arg list alongside tensors: they get indices, become graph inputs/outputs, and are pulled from all_args by position during subclass reconstruction — the same as PlainTensorMeta. An empty OpaqueMeta marker in SubclassCreationMeta.attrs distinguishes opaque slots from tensor slots (needed by process_runtime_tangent, which skips non-differentiable opaques). All code that previously iterated __tensor_flatten__ results and assumed every element was a tensor now handles opaques: subclass_parametrization, non_strict_utils, FSDP _init_utils, common_utils (get_untyped_storages), frontend_utils, and parametrize.py (which stores opaques as plain attributes rather than parameters). Tests added (all in test/test_opaque_obj_v2.py): - test_tensor_subclass_with_opaque_attr_backward - test_tensor_subclass_opaque_backward_compiled_autograd - test_tensor_subclass_shared_opaque_remapping - test_shared_opaque_identity_guard - test_shared_direct_opaque_identity_guard - test_tensor_subclass_shared_opaque_backward - test_deeply_nested_tensor_subclass_with_opaque - test_subclass_parametrization_with_opaque_attrs - test_export_non_strict_with_opaque_attrs - test_get_untyped_storages_with_opaque_attrs - test_subclass_opaque_attrs_cache_hit Authored with Claude. ghstack-source-id: bc4d79e Pull Request resolved: #176457
The first return value of `__tensor_flatten__` can now contain opaque (non-tensor) values such as DeviceMesh. Opaques flow through the flat arg list alongside tensors: they get indices, become graph inputs/outputs, and are pulled from all_args by position during subclass reconstruction — the same as PlainTensorMeta. An empty OpaqueMeta marker in SubclassCreationMeta.attrs distinguishes opaque slots from tensor slots (needed by process_runtime_tangent, which skips non-differentiable opaques). All code that previously iterated `__tensor_flatten__` results and assumed every element was a tensor now handles opaques: subclass_parametrization, non_strict_utils, FSDP _init_utils, common_utils (get_untyped_storages), frontend_utils, and parametrize.py (which stores opaques as plain attributes rather than parameters). Tests added (all in test/test_opaque_obj_v2.py): - test_tensor_subclass_with_opaque_attr_backward - test_tensor_subclass_opaque_backward_compiled_autograd - test_tensor_subclass_shared_opaque_remapping - test_shared_opaque_identity_guard - test_shared_direct_opaque_identity_guard - test_tensor_subclass_shared_opaque_backward - test_deeply_nested_tensor_subclass_with_opaque - test_subclass_parametrization_with_opaque_attrs - test_export_non_strict_with_opaque_attrs - test_get_untyped_storages_with_opaque_attrs - test_subclass_opaque_attrs_cache_hit - test_value_type_opaque_in_tensor_attrs_errors Authored with Claude. cc voznesenskym penguinwu EikanWang jgong5 Guobing-Chen XiaobingSuper zhuhaozhe blzheng wenzhe-nrv jiayisunx kadeng chauhang amjames Lucaskabela jataylo [ghstack-poisoned]
The first return value of __tensor_flatten__ can now contain opaque (non-tensor) values such as DeviceMesh. Opaques flow through the flat arg list alongside tensors: they get indices, become graph inputs/outputs, and are pulled from all_args by position during subclass reconstruction — the same as PlainTensorMeta. An empty OpaqueMeta marker in SubclassCreationMeta.attrs distinguishes opaque slots from tensor slots (needed by process_runtime_tangent, which skips non-differentiable opaques). All code that previously iterated __tensor_flatten__ results and assumed every element was a tensor now handles opaques: subclass_parametrization, non_strict_utils, FSDP _init_utils, common_utils (get_untyped_storages), frontend_utils, and parametrize.py (which stores opaques as plain attributes rather than parameters). Tests added (all in test/test_opaque_obj_v2.py): - test_tensor_subclass_with_opaque_attr_backward - test_tensor_subclass_opaque_backward_compiled_autograd - test_tensor_subclass_shared_opaque_remapping - test_shared_opaque_identity_guard - test_shared_direct_opaque_identity_guard - test_tensor_subclass_shared_opaque_backward - test_deeply_nested_tensor_subclass_with_opaque - test_subclass_parametrization_with_opaque_attrs - test_export_non_strict_with_opaque_attrs - test_get_untyped_storages_with_opaque_attrs - test_subclass_opaque_attrs_cache_hit Authored with Claude. ghstack-source-id: 65fb56c Pull Request resolved: #176457
The first return value of `__tensor_flatten__` can now contain opaque (non-tensor) values such as DeviceMesh. Opaques flow through the flat arg list alongside tensors: they get indices, become graph inputs/outputs, and are pulled from all_args by position during subclass reconstruction — the same as PlainTensorMeta. An empty OpaqueMeta marker in SubclassCreationMeta.attrs distinguishes opaque slots from tensor slots (needed by process_runtime_tangent, which skips non-differentiable opaques). All code that previously iterated `__tensor_flatten__` results and assumed every element was a tensor now handles opaques: subclass_parametrization, non_strict_utils, FSDP _init_utils, common_utils (get_untyped_storages), frontend_utils, and parametrize.py (which stores opaques as plain attributes rather than parameters). Tests added (all in test/test_opaque_obj_v2.py): - test_tensor_subclass_with_opaque_attr_backward - test_tensor_subclass_opaque_backward_compiled_autograd - test_tensor_subclass_shared_opaque_remapping - test_shared_opaque_identity_guard - test_shared_direct_opaque_identity_guard - test_tensor_subclass_shared_opaque_backward - test_deeply_nested_tensor_subclass_with_opaque - test_subclass_parametrization_with_opaque_attrs - test_export_non_strict_with_opaque_attrs - test_get_untyped_storages_with_opaque_attrs - test_subclass_opaque_attrs_cache_hit - test_value_type_opaque_in_tensor_attrs_errors Authored with Claude. cc voznesenskym penguinwu EikanWang jgong5 Guobing-Chen XiaobingSuper zhuhaozhe blzheng wenzhe-nrv jiayisunx kadeng chauhang amjames Lucaskabela jataylo [ghstack-poisoned]
The first return value of __tensor_flatten__ can now contain opaque (non-tensor) values such as DeviceMesh. Opaques flow through the flat arg list alongside tensors: they get indices, become graph inputs/outputs, and are pulled from all_args by position during subclass reconstruction — the same as PlainTensorMeta. An empty OpaqueMeta marker in SubclassCreationMeta.attrs distinguishes opaque slots from tensor slots (needed by process_runtime_tangent, which skips non-differentiable opaques). All code that previously iterated __tensor_flatten__ results and assumed every element was a tensor now handles opaques: subclass_parametrization, non_strict_utils, FSDP _init_utils, common_utils (get_untyped_storages), frontend_utils, and parametrize.py (which stores opaques as plain attributes rather than parameters). Tests added (all in test/test_opaque_obj_v2.py): - test_tensor_subclass_with_opaque_attr_backward - test_tensor_subclass_opaque_backward_compiled_autograd - test_tensor_subclass_shared_opaque_remapping - test_shared_opaque_identity_guard - test_shared_direct_opaque_identity_guard - test_tensor_subclass_shared_opaque_backward - test_deeply_nested_tensor_subclass_with_opaque - test_subclass_parametrization_with_opaque_attrs - test_export_non_strict_with_opaque_attrs - test_get_untyped_storages_with_opaque_attrs - test_subclass_opaque_attrs_cache_hit Authored with Claude. ghstack-source-id: 45b0259 Pull Request resolved: #176457
The first return value of `__tensor_flatten__` can now contain opaque (non-tensor) values such as DeviceMesh. Opaques flow through the flat arg list alongside tensors: they get indices, become graph inputs/outputs, and are pulled from all_args by position during subclass reconstruction — the same as PlainTensorMeta. An empty OpaqueMeta marker in SubclassCreationMeta.attrs distinguishes opaque slots from tensor slots (needed by process_runtime_tangent, which skips non-differentiable opaques). All code that previously iterated `__tensor_flatten__` results and assumed every element was a tensor now handles opaques: subclass_parametrization, non_strict_utils, FSDP _init_utils, common_utils (get_untyped_storages), frontend_utils, and parametrize.py (which stores opaques as plain attributes rather than parameters). Tests added (all in test/test_opaque_obj_v2.py): - test_tensor_subclass_with_opaque_attr_backward - test_tensor_subclass_opaque_backward_compiled_autograd - test_tensor_subclass_shared_opaque_remapping - test_shared_opaque_identity_guard - test_shared_direct_opaque_identity_guard - test_tensor_subclass_shared_opaque_backward - test_deeply_nested_tensor_subclass_with_opaque - test_subclass_parametrization_with_opaque_attrs - test_export_non_strict_with_opaque_attrs - test_get_untyped_storages_with_opaque_attrs - test_subclass_opaque_attrs_cache_hit - test_value_type_opaque_in_tensor_attrs_errors Authored with Claude. cc voznesenskym penguinwu EikanWang jgong5 Guobing-Chen XiaobingSuper zhuhaozhe blzheng wenzhe-nrv jiayisunx kadeng chauhang amjames Lucaskabela jataylo [ghstack-poisoned]
The first return value of __tensor_flatten__ can now contain opaque (non-tensor) values such as DeviceMesh. Opaques flow through the flat arg list alongside tensors: they get indices, become graph inputs/outputs, and are pulled from all_args by position during subclass reconstruction — the same as PlainTensorMeta. An empty OpaqueMeta marker in SubclassCreationMeta.attrs distinguishes opaque slots from tensor slots (needed by process_runtime_tangent, which skips non-differentiable opaques). All code that previously iterated __tensor_flatten__ results and assumed every element was a tensor now handles opaques: subclass_parametrization, non_strict_utils, FSDP _init_utils, common_utils (get_untyped_storages), frontend_utils, and parametrize.py (which stores opaques as plain attributes rather than parameters). Tests added (all in test/test_opaque_obj_v2.py): - test_tensor_subclass_with_opaque_attr_backward - test_tensor_subclass_opaque_backward_compiled_autograd - test_tensor_subclass_shared_opaque_remapping - test_shared_opaque_identity_guard - test_shared_direct_opaque_identity_guard - test_tensor_subclass_shared_opaque_backward - test_deeply_nested_tensor_subclass_with_opaque - test_subclass_parametrization_with_opaque_attrs - test_export_non_strict_with_opaque_attrs - test_get_untyped_storages_with_opaque_attrs - test_subclass_opaque_attrs_cache_hit Authored with Claude. ghstack-source-id: c505ee7 Pull Request resolved: #176457
The first return value of `__tensor_flatten__` can now contain opaque (non-tensor) values such as DeviceMesh. Opaques flow through the flat arg list alongside tensors: they get indices, become graph inputs/outputs, and are pulled from all_args by position during subclass reconstruction — the same as PlainTensorMeta. An empty OpaqueMeta marker in SubclassCreationMeta.attrs distinguishes opaque slots from tensor slots (needed by process_runtime_tangent, which skips non-differentiable opaques). All code that previously iterated `__tensor_flatten__` results and assumed every element was a tensor now handles opaques: subclass_parametrization, non_strict_utils, FSDP _init_utils, common_utils (get_untyped_storages), frontend_utils, and parametrize.py (which stores opaques as plain attributes rather than parameters). Tests added (all in test/test_opaque_obj_v2.py): - test_tensor_subclass_with_opaque_attr_backward - test_tensor_subclass_opaque_backward_compiled_autograd - test_tensor_subclass_shared_opaque_remapping - test_shared_opaque_identity_guard - test_shared_direct_opaque_identity_guard - test_tensor_subclass_shared_opaque_backward - test_deeply_nested_tensor_subclass_with_opaque - test_subclass_parametrization_with_opaque_attrs - test_export_non_strict_with_opaque_attrs - test_get_untyped_storages_with_opaque_attrs - test_subclass_opaque_attrs_cache_hit - test_value_type_opaque_in_tensor_attrs_errors Authored with Claude. cc voznesenskym penguinwu EikanWang jgong5 Guobing-Chen XiaobingSuper zhuhaozhe blzheng wenzhe-nrv jiayisunx kadeng chauhang amjames Lucaskabela jataylo [ghstack-poisoned]
The first return value of __tensor_flatten__ can now contain opaque (non-tensor) values such as DeviceMesh. Opaques flow through the flat arg list alongside tensors: they get indices, become graph inputs/outputs, and are pulled from all_args by position during subclass reconstruction — the same as PlainTensorMeta. An empty OpaqueMeta marker in SubclassCreationMeta.attrs distinguishes opaque slots from tensor slots (needed by process_runtime_tangent, which skips non-differentiable opaques). All code that previously iterated __tensor_flatten__ results and assumed every element was a tensor now handles opaques: subclass_parametrization, non_strict_utils, FSDP _init_utils, common_utils (get_untyped_storages), frontend_utils, and parametrize.py (which stores opaques as plain attributes rather than parameters). Tests added (all in test/test_opaque_obj_v2.py): - test_tensor_subclass_with_opaque_attr_backward - test_tensor_subclass_opaque_backward_compiled_autograd - test_tensor_subclass_shared_opaque_remapping - test_shared_opaque_identity_guard - test_shared_direct_opaque_identity_guard - test_tensor_subclass_shared_opaque_backward - test_deeply_nested_tensor_subclass_with_opaque - test_subclass_parametrization_with_opaque_attrs - test_export_non_strict_with_opaque_attrs - test_get_untyped_storages_with_opaque_attrs - test_subclass_opaque_attrs_cache_hit Authored with Claude. ghstack-source-id: fa270e1 Pull Request resolved: #176457
|
@pytorchbot merge |
Merge startedYour change will be merged once all checks pass (ETA 0-4 Hours). Learn more about merging in the wiki. Questions? Feedback? Please reach out to the PyTorch DevX Team |
Merge failedReason: 1 jobs have failed, first few of them are: trunk / macos-py3-arm64 / test (default, 3, 3, macos-m1-stable) Details for Dev Infra teamRaised by workflow job |
The first return value of `__tensor_flatten__` can now contain opaque (non-tensor) values such as DeviceMesh. Opaques flow through the flat arg list alongside tensors: they get indices, become graph inputs/outputs, and are pulled from all_args by position during subclass reconstruction — the same as PlainTensorMeta. An empty OpaqueMeta marker in SubclassCreationMeta.attrs distinguishes opaque slots from tensor slots (needed by process_runtime_tangent, which skips non-differentiable opaques). All code that previously iterated `__tensor_flatten__` results and assumed every element was a tensor now handles opaques: subclass_parametrization, non_strict_utils, FSDP _init_utils, common_utils (get_untyped_storages), frontend_utils, and parametrize.py (which stores opaques as plain attributes rather than parameters). Tests added (all in test/test_opaque_obj_v2.py): - test_tensor_subclass_with_opaque_attr_backward - test_tensor_subclass_opaque_backward_compiled_autograd - test_tensor_subclass_shared_opaque_remapping - test_shared_opaque_identity_guard - test_shared_direct_opaque_identity_guard - test_tensor_subclass_shared_opaque_backward - test_deeply_nested_tensor_subclass_with_opaque - test_subclass_parametrization_with_opaque_attrs - test_export_non_strict_with_opaque_attrs - test_get_untyped_storages_with_opaque_attrs - test_subclass_opaque_attrs_cache_hit - test_value_type_opaque_in_tensor_attrs_errors Authored with Claude. cc voznesenskym penguinwu EikanWang jgong5 Guobing-Chen XiaobingSuper zhuhaozhe blzheng wenzhe-nrv jiayisunx kadeng chauhang amjames Lucaskabela jataylo [ghstack-poisoned]
The first return value of __tensor_flatten__ can now contain opaque (non-tensor) values such as DeviceMesh. Opaques flow through the flat arg list alongside tensors: they get indices, become graph inputs/outputs, and are pulled from all_args by position during subclass reconstruction — the same as PlainTensorMeta. An empty OpaqueMeta marker in SubclassCreationMeta.attrs distinguishes opaque slots from tensor slots (needed by process_runtime_tangent, which skips non-differentiable opaques). All code that previously iterated __tensor_flatten__ results and assumed every element was a tensor now handles opaques: subclass_parametrization, non_strict_utils, FSDP _init_utils, common_utils (get_untyped_storages), frontend_utils, and parametrize.py (which stores opaques as plain attributes rather than parameters). Tests added (all in test/test_opaque_obj_v2.py): - test_tensor_subclass_with_opaque_attr_backward - test_tensor_subclass_opaque_backward_compiled_autograd - test_tensor_subclass_shared_opaque_remapping - test_shared_opaque_identity_guard - test_shared_direct_opaque_identity_guard - test_tensor_subclass_shared_opaque_backward - test_deeply_nested_tensor_subclass_with_opaque - test_subclass_parametrization_with_opaque_attrs - test_export_non_strict_with_opaque_attrs - test_get_untyped_storages_with_opaque_attrs - test_subclass_opaque_attrs_cache_hit Authored with Claude. ghstack-source-id: 0dd82ff Pull Request resolved: #176457
The first return value of `__tensor_flatten__` can now contain opaque (non-tensor) values such as DeviceMesh. Opaques flow through the flat arg list alongside tensors: they get indices, become graph inputs/outputs, and are pulled from all_args by position during subclass reconstruction — the same as PlainTensorMeta. An empty OpaqueMeta marker in SubclassCreationMeta.attrs distinguishes opaque slots from tensor slots (needed by process_runtime_tangent, which skips non-differentiable opaques). All code that previously iterated `__tensor_flatten__` results and assumed every element was a tensor now handles opaques: subclass_parametrization, non_strict_utils, FSDP _init_utils, common_utils (get_untyped_storages), frontend_utils, and parametrize.py (which stores opaques as plain attributes rather than parameters). Tests added (all in test/test_opaque_obj_v2.py): - test_tensor_subclass_with_opaque_attr_backward - test_tensor_subclass_opaque_backward_compiled_autograd - test_tensor_subclass_shared_opaque_remapping - test_shared_opaque_identity_guard - test_shared_direct_opaque_identity_guard - test_tensor_subclass_shared_opaque_backward - test_deeply_nested_tensor_subclass_with_opaque - test_subclass_parametrization_with_opaque_attrs - test_export_non_strict_with_opaque_attrs - test_get_untyped_storages_with_opaque_attrs - test_subclass_opaque_attrs_cache_hit - test_value_type_opaque_in_tensor_attrs_errors Authored with Claude. cc voznesenskym penguinwu EikanWang jgong5 Guobing-Chen XiaobingSuper zhuhaozhe blzheng wenzhe-nrv jiayisunx kadeng chauhang amjames Lucaskabela jataylo [ghstack-poisoned]
The first return value of __tensor_flatten__ can now contain opaque (non-tensor) values such as DeviceMesh. Opaques flow through the flat arg list alongside tensors: they get indices, become graph inputs/outputs, and are pulled from all_args by position during subclass reconstruction — the same as PlainTensorMeta. An empty OpaqueMeta marker in SubclassCreationMeta.attrs distinguishes opaque slots from tensor slots (needed by process_runtime_tangent, which skips non-differentiable opaques). All code that previously iterated __tensor_flatten__ results and assumed every element was a tensor now handles opaques: subclass_parametrization, non_strict_utils, FSDP _init_utils, common_utils (get_untyped_storages), frontend_utils, and parametrize.py (which stores opaques as plain attributes rather than parameters). Tests added (all in test/test_opaque_obj_v2.py): - test_tensor_subclass_with_opaque_attr_backward - test_tensor_subclass_opaque_backward_compiled_autograd - test_tensor_subclass_shared_opaque_remapping - test_shared_opaque_identity_guard - test_shared_direct_opaque_identity_guard - test_tensor_subclass_shared_opaque_backward - test_deeply_nested_tensor_subclass_with_opaque - test_subclass_parametrization_with_opaque_attrs - test_export_non_strict_with_opaque_attrs - test_get_untyped_storages_with_opaque_attrs - test_subclass_opaque_attrs_cache_hit Authored with Claude. ghstack-source-id: 065031f Pull Request resolved: #176457
The first return value of `__tensor_flatten__` can now contain opaque (non-tensor) values such as DeviceMesh. Opaques flow through the flat arg list alongside tensors: they get indices, become graph inputs/outputs, and are pulled from all_args by position during subclass reconstruction — the same as PlainTensorMeta. An empty OpaqueMeta marker in SubclassCreationMeta.attrs distinguishes opaque slots from tensor slots (needed by process_runtime_tangent, which skips non-differentiable opaques). All code that previously iterated `__tensor_flatten__` results and assumed every element was a tensor now handles opaques: subclass_parametrization, non_strict_utils, FSDP _init_utils, common_utils (get_untyped_storages), frontend_utils, and parametrize.py (which stores opaques as plain attributes rather than parameters). Tests added (all in test/test_opaque_obj_v2.py): - test_tensor_subclass_with_opaque_attr_backward - test_tensor_subclass_opaque_backward_compiled_autograd - test_tensor_subclass_shared_opaque_remapping - test_shared_opaque_identity_guard - test_shared_direct_opaque_identity_guard - test_tensor_subclass_shared_opaque_backward - test_deeply_nested_tensor_subclass_with_opaque - test_subclass_parametrization_with_opaque_attrs - test_export_non_strict_with_opaque_attrs - test_get_untyped_storages_with_opaque_attrs - test_subclass_opaque_attrs_cache_hit - test_value_type_opaque_in_tensor_attrs_errors Authored with Claude. cc voznesenskym penguinwu EikanWang jgong5 Guobing-Chen XiaobingSuper zhuhaozhe blzheng wenzhe-nrv jiayisunx kadeng chauhang amjames Lucaskabela jataylo [ghstack-poisoned]
The first return value of __tensor_flatten__ can now contain opaque (non-tensor) values such as DeviceMesh. Opaques flow through the flat arg list alongside tensors: they get indices, become graph inputs/outputs, and are pulled from all_args by position during subclass reconstruction — the same as PlainTensorMeta. An empty OpaqueMeta marker in SubclassCreationMeta.attrs distinguishes opaque slots from tensor slots (needed by process_runtime_tangent, which skips non-differentiable opaques). All code that previously iterated __tensor_flatten__ results and assumed every element was a tensor now handles opaques: subclass_parametrization, non_strict_utils, FSDP _init_utils, common_utils (get_untyped_storages), frontend_utils, and parametrize.py (which stores opaques as plain attributes rather than parameters). Tests added (all in test/test_opaque_obj_v2.py): - test_tensor_subclass_with_opaque_attr_backward - test_tensor_subclass_opaque_backward_compiled_autograd - test_tensor_subclass_shared_opaque_remapping - test_shared_opaque_identity_guard - test_shared_direct_opaque_identity_guard - test_tensor_subclass_shared_opaque_backward - test_deeply_nested_tensor_subclass_with_opaque - test_subclass_parametrization_with_opaque_attrs - test_export_non_strict_with_opaque_attrs - test_get_untyped_storages_with_opaque_attrs - test_subclass_opaque_attrs_cache_hit Authored with Claude. ghstack-source-id: 35ec966 Pull Request resolved: #176457
|
@pytorchbot merge |
Merge startedYour change will be merged once all checks pass (ETA 0-4 Hours). Learn more about merging in the wiki. Questions? Feedback? Please reach out to the PyTorch DevX Team |
The first return value of `__tensor_flatten__` can now contain opaque (non-tensor) values such as DeviceMesh. Opaques flow through the flat arg list alongside tensors: they get indices, become graph inputs/outputs, and are pulled from all_args by position during subclass reconstruction — the same as PlainTensorMeta. An empty OpaqueMeta marker in SubclassCreationMeta.attrs distinguishes opaque slots from tensor slots (needed by process_runtime_tangent, which skips non-differentiable opaques). All code that previously iterated `__tensor_flatten__` results and assumed every element was a tensor now handles opaques: subclass_parametrization, non_strict_utils, FSDP _init_utils, common_utils (get_untyped_storages), frontend_utils, and parametrize.py (which stores opaques as plain attributes rather than parameters). Tests added (all in test/test_opaque_obj_v2.py): - test_tensor_subclass_with_opaque_attr_backward - test_tensor_subclass_opaque_backward_compiled_autograd - test_tensor_subclass_shared_opaque_remapping - test_shared_opaque_identity_guard - test_shared_direct_opaque_identity_guard - test_tensor_subclass_shared_opaque_backward - test_deeply_nested_tensor_subclass_with_opaque - test_subclass_parametrization_with_opaque_attrs - test_export_non_strict_with_opaque_attrs - test_get_untyped_storages_with_opaque_attrs - test_subclass_opaque_attrs_cache_hit - test_value_type_opaque_in_tensor_attrs_errors Authored with Claude. Pull Request resolved: pytorch#176457 Approved by: https://github.com/ezyang
Stack from ghstack (oldest at bottom):
The first return value of
__tensor_flatten__can now contain opaque(non-tensor) values such as DeviceMesh. Opaques flow through the flat
arg list alongside tensors: they get indices, become graph inputs/outputs,
and are pulled from all_args by position during subclass reconstruction
— the same as PlainTensorMeta. An empty OpaqueMeta marker in
SubclassCreationMeta.attrs distinguishes opaque slots from tensor slots
(needed by process_runtime_tangent, which skips non-differentiable
opaques).
All code that previously iterated
__tensor_flatten__results and assumedevery element was a tensor now handles opaques: subclass_parametrization,
non_strict_utils, FSDP _init_utils, common_utils (get_untyped_storages),
frontend_utils, and parametrize.py (which stores opaques as plain
attributes rather than parameters).
Tests added (all in test/test_opaque_obj_v2.py):
Authored with Claude.
cc @voznesenskym @penguinwu @EikanWang @jgong5 @Guobing-Chen @XiaobingSuper @zhuhaozhe @blzheng @wenzhe-nrv @jiayisunx @kadeng @chauhang @amjames @Lucaskabela @jataylo