[ET-VK][export] Update tensor representation sync logic to allow for flexibility in memory layouts#17564
[ET-VK][export] Update tensor representation sync logic to allow for flexibility in memory layouts#17564SS-JIA wants to merge 5 commits intogh/SS-JIA/438/basefrom
Conversation
…flexibility in memory layouts The tag_memory_meta_pass determines which storage type and memory layout to use for each tensor in the graph. Previously, OpRepSets enforced that "synced" tensors (e.g. all inputs to a binary op) use the exact same storage type AND memory layout by collapsing them into a single shared TensorRepSet. This was overly restrictive for quantized operators like q8ta_add, where inputs and outputs must share the same packed dimension but are allowed to use different memory layouts (e.g. input A uses PACKED_INT8_4W4C, input B uses PACKED_INT8_4C1W, output uses PACKED_INT8_4C1W). This diff introduces PackedDimInfo, a Python-side mirror of the C++ PackedDimInfo struct in Tensor.h, which captures the packed dimension and block size for each memory layout. The sync logic is rewritten so that synced tensors are constrained to have "compatible" packed dim info (same packed_dim and packed_dim_block_size) rather than identical memory layouts. This is achieved through three new TensorRepSet methods: has_same_packed_dim_info_set checks exact PDI equality, has_compatible_packed_dim_info_set checks superset containment, and filter_for_compatible_packed_dim_infos narrows a repset to only layouts with compatible PDIs. The OpRepSets initialization now stores individual repsets per arg/output instead of collapsing synced groups into a single object, and constraint propagation uses packed-dim filtering. The tag_memory_meta_pass is simplified to always call constrain_op_out_repset since the new OpRepSets sync logic handles propagation internally. Also renames make_filtered_tensor_repset to filter_invalid_reprs for clarity and adds comprehensive unit tests for TensorRepSet, TensorRepSetList, OpRepSets, and TensorReprList. Authored with Claude. Differential Revision: [D93768636](https://our.internmc.facebook.com/intern/diff/D93768636/) [ghstack-poisoned]
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/17564
Note: Links to docs will display an error until the docs builds have been completed. ❌ 3 New Failures, 51 Pending, 1 Unrelated FailureAs of commit e5de1ee with merge base 1056c34 ( NEW FAILURES - The following jobs have failed:
BROKEN TRUNK - The following job failed but were present on the merge base:👉 Rebase onto the `viable/strict` branch to avoid these failures
This comment was automatically generated by Dr. CI and updates every 15 minutes. |
This PR needs a
|
… allow for flexibility in memory layouts" The tag_memory_meta_pass determines which storage type and memory layout to use for each tensor in the graph. Previously, OpRepSets enforced that "synced" tensors (e.g. all inputs to a binary op) use the exact same storage type AND memory layout by collapsing them into a single shared TensorRepSet. This was overly restrictive for quantized operators like q8ta_add, where inputs and outputs must share the same packed dimension but are allowed to use different memory layouts (e.g. input A uses PACKED_INT8_4W4C, input B uses PACKED_INT8_4C1W, output uses PACKED_INT8_4C1W). This diff introduces PackedDimInfo, a Python-side mirror of the C++ PackedDimInfo struct in Tensor.h, which captures the packed dimension and block size for each memory layout. The sync logic is rewritten so that synced tensors are constrained to have "compatible" packed dim info (same packed_dim and packed_dim_block_size) rather than identical memory layouts. This is achieved through three new TensorRepSet methods: has_same_packed_dim_info_set checks exact PDI equality, has_compatible_packed_dim_info_set checks superset containment, and filter_for_compatible_packed_dim_infos narrows a repset to only layouts with compatible PDIs. The OpRepSets initialization now stores individual repsets per arg/output instead of collapsing synced groups into a single object, and constraint propagation uses packed-dim filtering. The tag_memory_meta_pass is simplified to always call constrain_op_out_repset since the new OpRepSets sync logic handles propagation internally. Also renames make_filtered_tensor_repset to filter_invalid_reprs for clarity and adds comprehensive unit tests for TensorRepSet, TensorRepSetList, OpRepSets, and TensorReprList. Authored with Claude. Differential Revision: [D93768636](https://our.internmc.facebook.com/intern/diff/D93768636/) [ghstack-poisoned]
… allow for flexibility in memory layouts" The tag_memory_meta_pass determines which storage type and memory layout to use for each tensor in the graph. Previously, OpRepSets enforced that "synced" tensors (e.g. all inputs to a binary op) use the exact same storage type AND memory layout by collapsing them into a single shared TensorRepSet. This was overly restrictive for quantized operators like q8ta_add, where inputs and outputs must share the same packed dimension but are allowed to use different memory layouts (e.g. input A uses PACKED_INT8_4W4C, input B uses PACKED_INT8_4C1W, output uses PACKED_INT8_4C1W). This diff introduces PackedDimInfo, a Python-side mirror of the C++ PackedDimInfo struct in Tensor.h, which captures the packed dimension and block size for each memory layout. The sync logic is rewritten so that synced tensors are constrained to have "compatible" packed dim info (same packed_dim and packed_dim_block_size) rather than identical memory layouts. This is achieved through three new TensorRepSet methods: has_same_packed_dim_info_set checks exact PDI equality, has_compatible_packed_dim_info_set checks superset containment, and filter_for_compatible_packed_dim_infos narrows a repset to only layouts with compatible PDIs. The OpRepSets initialization now stores individual repsets per arg/output instead of collapsing synced groups into a single object, and constraint propagation uses packed-dim filtering. The tag_memory_meta_pass is simplified to always call constrain_op_out_repset since the new OpRepSets sync logic handles propagation internally. Also renames make_filtered_tensor_repset to filter_invalid_reprs for clarity and adds comprehensive unit tests for TensorRepSet, TensorRepSetList, OpRepSets, and TensorReprList. Authored with Claude. Differential Revision: [D93768636](https://our.internmc.facebook.com/intern/diff/D93768636/) [ghstack-poisoned]
… allow for flexibility in memory layouts" The tag_memory_meta_pass determines which storage type and memory layout to use for each tensor in the graph. Previously, OpRepSets enforced that "synced" tensors (e.g. all inputs to a binary op) use the exact same storage type AND memory layout by collapsing them into a single shared TensorRepSet. This was overly restrictive for quantized operators like q8ta_add, where inputs and outputs must share the same packed dimension but are allowed to use different memory layouts (e.g. input A uses PACKED_INT8_4W4C, input B uses PACKED_INT8_4C1W, output uses PACKED_INT8_4C1W). This diff introduces PackedDimInfo, a Python-side mirror of the C++ PackedDimInfo struct in Tensor.h, which captures the packed dimension and block size for each memory layout. The sync logic is rewritten so that synced tensors are constrained to have "compatible" packed dim info (same packed_dim and packed_dim_block_size) rather than identical memory layouts. This is achieved through three new TensorRepSet methods: has_same_packed_dim_info_set checks exact PDI equality, has_compatible_packed_dim_info_set checks superset containment, and filter_for_compatible_packed_dim_infos narrows a repset to only layouts with compatible PDIs. The OpRepSets initialization now stores individual repsets per arg/output instead of collapsing synced groups into a single object, and constraint propagation uses packed-dim filtering. The tag_memory_meta_pass is simplified to always call constrain_op_out_repset since the new OpRepSets sync logic handles propagation internally. Also renames make_filtered_tensor_repset to filter_invalid_reprs for clarity and adds comprehensive unit tests for TensorRepSet, TensorRepSetList, OpRepSets, and TensorReprList. Authored with Claude. Differential Revision: [D93768636](https://our.internmc.facebook.com/intern/diff/D93768636/) [ghstack-poisoned]
… allow for flexibility in memory layouts" The tag_memory_meta_pass determines which storage type and memory layout to use for each tensor in the graph. Previously, OpRepSets enforced that "synced" tensors (e.g. all inputs to a binary op) use the exact same storage type AND memory layout by collapsing them into a single shared TensorRepSet. This was overly restrictive for quantized operators like q8ta_add, where inputs and outputs must share the same packed dimension but are allowed to use different memory layouts (e.g. input A uses PACKED_INT8_4W4C, input B uses PACKED_INT8_4C1W, output uses PACKED_INT8_4C1W). This diff introduces PackedDimInfo, a Python-side mirror of the C++ PackedDimInfo struct in Tensor.h, which captures the packed dimension and block size for each memory layout. The sync logic is rewritten so that synced tensors are constrained to have "compatible" packed dim info (same packed_dim and packed_dim_block_size) rather than identical memory layouts. This is achieved through three new TensorRepSet methods: has_same_packed_dim_info_set checks exact PDI equality, has_compatible_packed_dim_info_set checks superset containment, and filter_for_compatible_packed_dim_infos narrows a repset to only layouts with compatible PDIs. The OpRepSets initialization now stores individual repsets per arg/output instead of collapsing synced groups into a single object, and constraint propagation uses packed-dim filtering. The tag_memory_meta_pass is simplified to always call constrain_op_out_repset since the new OpRepSets sync logic handles propagation internally. Also renames make_filtered_tensor_repset to filter_invalid_reprs for clarity and adds comprehensive unit tests for TensorRepSet, TensorRepSetList, OpRepSets, and TensorReprList. Authored with Claude. Differential Revision: [D93768636](https://our.internmc.facebook.com/intern/diff/D93768636/) [ghstack-poisoned]
Stack from ghstack (oldest at bottom):
The tag_memory_meta_pass determines which storage type and memory layout to use for each tensor in the graph. Previously, OpRepSets enforced that "synced" tensors (e.g. all inputs to a binary op) use the exact same storage type AND memory layout by collapsing them into a single shared TensorRepSet. This was overly restrictive for quantized operators like q8ta_add, where inputs and outputs must share the same packed dimension but are allowed to use different memory layouts (e.g. input A uses PACKED_INT8_4W4C, input B uses PACKED_INT8_4C1W, output uses PACKED_INT8_4C1W).
This diff introduces PackedDimInfo, a Python-side mirror of the C++ PackedDimInfo struct in Tensor.h, which captures the packed dimension and block size for each memory layout. The sync logic is rewritten so that synced tensors are constrained to have "compatible" packed dim info (same packed_dim and packed_dim_block_size) rather than identical memory layouts. This is achieved through three new TensorRepSet methods: has_same_packed_dim_info_set checks exact PDI equality, has_compatible_packed_dim_info_set checks superset containment, and filter_for_compatible_packed_dim_infos narrows a repset to only layouts with compatible PDIs.
The OpRepSets initialization now stores individual repsets per arg/output instead of collapsing synced groups into a single object, and constraint propagation uses packed-dim filtering. The tag_memory_meta_pass is simplified to always call constrain_op_out_repset since the new OpRepSets sync logic handles propagation internally.
Also renames make_filtered_tensor_repset to filter_invalid_reprs for clarity and adds comprehensive unit tests for TensorRepSet, TensorRepSetList, OpRepSets, and TensorReprList.
Authored with Claude.
Differential Revision: D93768636