Skip to content

Support optional_tensor_names in TorchAOBaseTensor #2710

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: jerryzh168/stack/16
Choose a base branch
from

Conversation

jerryzh168
Copy link
Contributor

@jerryzh168 jerryzh168 commented Aug 7, 2025

Stacked PRs:


Support optional_tensor_names in TorchAOBaseTensor

Summary:
Allows subclasses inheriting from TorchAOBaseTensor to have optional tensor attributes, updated
all common util functions to support optional_tensor_names list, including __tensor_flatten__, __tensor_unflatten__, ops like aten._to_copy, contiguous, alias etc.

Test Plan:
python test/test_utils.py

Reviewers:

Subscribers:

Tasks:

Tags:

Copy link

pytorch-bot bot commented Aug 7, 2025

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/ao/2710

Note: Links to docs will display an error until the docs builds have been completed.

✅ No Failures

As of commit b6b0d9f with merge base c086ade (image):
💚 Looks good so far! There are no failures yet. 💚

This comment was automatically generated by Dr. CI and updates every 15 minutes.

jerryzh168 added a commit that referenced this pull request Aug 7, 2025
Summary:
Allows subclasses inheriting from TorchAOBaseTensor to have optional tensor attributes, updated
all common util functions to support `optional_tensor_names` list, including `__tensor_flatten__`, `__tensor_unflatten__`, ops like aten._to_copy, contiguous, alias etc.

Test Plan:
python test/test_utils.py

Reviewers:

Subscribers:

Tasks:

Tags:

stack-info: PR: #2710, branch: jerryzh168/stack/17
@jerryzh168 jerryzh168 force-pushed the jerryzh168/stack/17 branch from 650b1e5 to a258628 Compare August 7, 2025 02:57
@meta-cla meta-cla bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Aug 7, 2025
@jerryzh168 jerryzh168 force-pushed the jerryzh168/stack/16 branch from aee3dbb to 4a50bf7 Compare August 7, 2025 02:58
jerryzh168 added a commit that referenced this pull request Aug 7, 2025
Summary:
Allows subclasses inheriting from TorchAOBaseTensor to have optional tensor attributes, updated
all common util functions to support `optional_tensor_names` list, including `__tensor_flatten__`, `__tensor_unflatten__`, ops like aten._to_copy, contiguous, alias etc.

Test Plan:
python test/test_utils.py

Reviewers:

Subscribers:

Tasks:

Tags:

stack-info: PR: #2710, branch: jerryzh168/stack/17
@jerryzh168 jerryzh168 added the topic: not user facing Use this tag if you don't want this PR to show up in release notes label Aug 7, 2025
@jerryzh168 jerryzh168 force-pushed the jerryzh168/stack/17 branch from a258628 to 4a0d944 Compare August 7, 2025 02:58
@jerryzh168 jerryzh168 changed the base branch from jerryzh168/stack/16 to main August 7, 2025 03:37
jerryzh168 added a commit that referenced this pull request Aug 7, 2025
Summary:
Allows subclasses inheriting from TorchAOBaseTensor to have optional tensor attributes, updated
all common util functions to support `optional_tensor_names` list, including `__tensor_flatten__`, `__tensor_unflatten__`, ops like aten._to_copy, contiguous, alias etc.

Test Plan:
python test/test_utils.py

Reviewers:

Subscribers:

Tasks:

Tags:

stack-info: PR: #2710, branch: jerryzh168/stack/17
@jerryzh168 jerryzh168 force-pushed the jerryzh168/stack/17 branch from 4a0d944 to 1f4d77f Compare August 7, 2025 03:37
@jerryzh168 jerryzh168 changed the base branch from main to jerryzh168/stack/16 August 7, 2025 03:37
@jerryzh168 jerryzh168 requested review from vkuzo and drisspg August 7, 2025 03:46
@jerryzh168 jerryzh168 changed the base branch from jerryzh168/stack/16 to main August 7, 2025 03:51
jerryzh168 added a commit that referenced this pull request Aug 7, 2025
Summary:
Allows subclasses inheriting from TorchAOBaseTensor to have optional tensor attributes, updated
all common util functions to support `optional_tensor_names` list, including `__tensor_flatten__`, `__tensor_unflatten__`, ops like aten._to_copy, contiguous, alias etc.

Test Plan:
python test/test_utils.py

Reviewers:

Subscribers:

Tasks:

Tags:

stack-info: PR: #2710, branch: jerryzh168/stack/17
@jerryzh168 jerryzh168 force-pushed the jerryzh168/stack/17 branch from 1f4d77f to bf8894c Compare August 7, 2025 03:51
@jerryzh168 jerryzh168 changed the base branch from main to jerryzh168/stack/16 August 7, 2025 03:51
@jerryzh168 jerryzh168 changed the base branch from jerryzh168/stack/16 to main August 7, 2025 04:29
jerryzh168 added a commit that referenced this pull request Aug 7, 2025
Summary:
Allows subclasses inheriting from TorchAOBaseTensor to have optional tensor attributes, updated
all common util functions to support `optional_tensor_names` list, including `__tensor_flatten__`, `__tensor_unflatten__`, ops like aten._to_copy, contiguous, alias etc.

Test Plan:
python test/test_utils.py

Reviewers:

Subscribers:

Tasks:

Tags:

stack-info: PR: #2710, branch: jerryzh168/stack/17
@jerryzh168 jerryzh168 force-pushed the jerryzh168/stack/17 branch from bf8894c to 9045759 Compare August 7, 2025 04:29
@jerryzh168 jerryzh168 changed the base branch from main to jerryzh168/stack/16 August 7, 2025 04:29
@jerryzh168 jerryzh168 changed the base branch from jerryzh168/stack/16 to main August 7, 2025 20:56
@jerryzh168 jerryzh168 force-pushed the jerryzh168/stack/17 branch from 9045759 to 08670aa Compare August 7, 2025 20:56
jerryzh168 added a commit that referenced this pull request Aug 7, 2025
Summary:
Allows subclasses inheriting from TorchAOBaseTensor to have optional tensor attributes, updated
all common util functions to support `optional_tensor_names` list, including `__tensor_flatten__`, `__tensor_unflatten__`, ops like aten._to_copy, contiguous, alias etc.

Test Plan:
python test/test_utils.py

Reviewers:

Subscribers:

Tasks:

Tags:

stack-info: PR: #2710, branch: jerryzh168/stack/17
@jerryzh168 jerryzh168 changed the base branch from main to jerryzh168/stack/16 August 7, 2025 20:56
@jerryzh168 jerryzh168 force-pushed the jerryzh168/stack/16 branch from e84a76d to 8983652 Compare August 7, 2025 23:08
jerryzh168 added a commit that referenced this pull request Aug 7, 2025
Summary:
Allows subclasses inheriting from TorchAOBaseTensor to have optional tensor attributes, updated
all common util functions to support `optional_tensor_names` list, including `__tensor_flatten__`, `__tensor_unflatten__`, ops like aten._to_copy, contiguous, alias etc.

Test Plan:
python test/test_utils.py

Reviewers:

Subscribers:

Tasks:

Tags:

stack-info: PR: #2710, branch: jerryzh168/stack/17
@jerryzh168 jerryzh168 force-pushed the jerryzh168/stack/17 branch from 08670aa to ad5988a Compare August 7, 2025 23:08
@jerryzh168 jerryzh168 force-pushed the jerryzh168/stack/16 branch from 8983652 to abcddcf Compare August 7, 2025 23:21
jerryzh168 added a commit that referenced this pull request Aug 7, 2025
Summary:
Allows subclasses inheriting from TorchAOBaseTensor to have optional tensor attributes, updated
all common util functions to support `optional_tensor_names` list, including `__tensor_flatten__`, `__tensor_unflatten__`, ops like aten._to_copy, contiguous, alias etc.

Test Plan:
python test/test_utils.py

Reviewers:

Subscribers:

Tasks:

Tags:

stack-info: PR: #2710, branch: jerryzh168/stack/17
@jerryzh168 jerryzh168 force-pushed the jerryzh168/stack/17 branch from ad5988a to a389ba8 Compare August 7, 2025 23:21
Copy link
Contributor

@drisspg drisspg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you update the doc block for AoBaseTensor I think having class types so that users know what types it contains e.g. you can have optional_tensor_data_names: Optional[List[Tensor]]

so w/ a description of why you want to populate this field, what functions it can help you implement, etc...

@jerryzh168 jerryzh168 changed the base branch from jerryzh168/stack/16 to main August 8, 2025 01:45
jerryzh168 added a commit that referenced this pull request Aug 8, 2025
Summary:
Allows subclasses inheriting from TorchAOBaseTensor to have optional tensor attributes, updated
all common util functions to support `optional_tensor_names` list, including `__tensor_flatten__`, `__tensor_unflatten__`, ops like aten._to_copy, contiguous, alias etc.

Test Plan:
python test/test_utils.py

Reviewers:

Subscribers:

Tasks:

Tags:

stack-info: PR: #2710, branch: jerryzh168/stack/17
@jerryzh168 jerryzh168 force-pushed the jerryzh168/stack/17 branch from a389ba8 to bdd9ac6 Compare August 8, 2025 01:45
@jerryzh168 jerryzh168 changed the base branch from main to jerryzh168/stack/16 August 8, 2025 01:45
@jerryzh168
Copy link
Contributor Author

jerryzh168 commented Aug 8, 2025

can you update the doc block for AoBaseTensor I think having class types so that users know what types it contains e.g. you can have optional_tensor_data_names: Optional[List[Tensor]]

so w/ a description of why you want to populate this field, what functions it can help you implement, etc...

sg, updated the doc, we can't add these fields by default since it's optional to define these fields

Summary:
Allows subclasses inheriting from TorchAOBaseTensor to have optional tensor attributes, updated
all common util functions to support `optional_tensor_names` list, including `__tensor_flatten__`, `__tensor_unflatten__`, ops like aten._to_copy, contiguous, alias etc.

Test Plan:
python test/test_utils.py

Reviewers:

Subscribers:

Tasks:

Tags:

stack-info: PR: #2710, branch: jerryzh168/stack/17
@jerryzh168 jerryzh168 changed the base branch from jerryzh168/stack/16 to main August 8, 2025 04:18
@jerryzh168 jerryzh168 force-pushed the jerryzh168/stack/17 branch from bdd9ac6 to b6b0d9f Compare August 8, 2025 04:18
@jerryzh168 jerryzh168 changed the base branch from main to jerryzh168/stack/16 August 8, 2025 04:23
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. topic: not user facing Use this tag if you don't want this PR to show up in release notes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants