Skip to content

Comments

[ET-VK][export] Update tensor representation sync logic to allow for flexibility in memory layouts#17564

Open
SS-JIA wants to merge 5 commits intogh/SS-JIA/438/basefrom
gh/SS-JIA/438/head
Open

[ET-VK][export] Update tensor representation sync logic to allow for flexibility in memory layouts#17564
SS-JIA wants to merge 5 commits intogh/SS-JIA/438/basefrom
gh/SS-JIA/438/head

Conversation

@SS-JIA
Copy link
Contributor

@SS-JIA SS-JIA commented Feb 19, 2026

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

…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]
@pytorch-bot
Copy link

pytorch-bot bot commented Feb 19, 2026

🔗 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 Failure

As of commit e5de1ee with merge base 1056c34 (image):

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.

@github-actions
Copy link

This PR needs a release notes: label

If your change should be included in the release notes (i.e. would users of this library care about this change?), please use a label starting with release notes:. This helps us keep track and include your important work in the next release notes.

To add a label, you can comment to pytorchbot, for example
@pytorchbot label "release notes: none"

For more information, see
https://github.com/pytorch/pytorch/wiki/PyTorch-AutoLabel-Bot#why-categorize-for-release-notes-and-how-does-it-work.

ssjia added 4 commits February 20, 2026 15:58
… 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]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. fb-exported meta-exported

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants