Skip to content

Move more utils to TorchAOBaseTensor #784

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

Merged
merged 6 commits into from
Sep 3, 2024
Merged

Conversation

jerryzh168
Copy link
Contributor

Summary:
This moves over implements, dispatch__torch_dispatch, dispatch__torch_function_, _register_layout_cls and _get_layout_tensor_constructor to TorchAOBaseTensor so when people inherit from this, they can get these utils directly

Test Plan:
python test/quantization/test_quant_api.py
python test/integration/test_integration.py

rely on CI for other tests

Reviewers:

Subscribers:

Tasks:

Tags:

Copy link

pytorch-bot bot commented Aug 30, 2024

🔗 Helpful Links

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

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

✅ No Failures

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

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

@facebook-github-bot facebook-github-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 30, 2024
Summary:
This moves over _implements, _dispatch__torch_dispatch__, _dispatch__torch_function__, _register_layout_cls and _get_layout_tensor_constructor
to `TorchAOBaseTensor` so when people inherit from this, they can get these utils directly

Test Plan:
python test/quantization/test_quant_api.py
python test/integration/test_integration.py

rely on CI for other tests

Reviewers:

Subscribers:

Tasks:

Tags:
@HDCharles
Copy link
Contributor

can this handle the other ones from #710?

feels like there should be a way to set it up so that things like detach are handlable with a combination of tensor_flatten and the constructor?

Copy link
Contributor

@HDCharles HDCharles left a comment

Choose a reason for hiding this comment

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

looks good otherwise

@jerryzh168
Copy link
Contributor Author

can this handle the other ones from #710?

feels like there should be a way to set it up so that things like detach are handlable with a combination of tensor_flatten and the constructor?

yeah will do in a future PR

@jerryzh168 jerryzh168 merged commit 9db1660 into pytorch:main Sep 3, 2024
17 checks passed
@jerryzh168 jerryzh168 deleted the base-class branch September 3, 2024 23:47
@@ -75,7 +75,7 @@ def test_quantize_4bit_with_qmap_compile(self, device):


class TestOptim(TestCase):
@pytest.mark.skipif(not TORCH_VERSION_AT_LEAST_2_3, reason="requires PyTorch >= 2.3")
@pytest.mark.skipif(not TORCH_VERSION_AT_LEAST_2_4, reason="requires PyTorch >= 2.3")
Copy link
Contributor Author

@jerryzh168 jerryzh168 Sep 3, 2024

Choose a reason for hiding this comment

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

cc @gau-nernst multiple levels of inheritance breaks pytorch 2.3 version (https://github.com/pytorch/ao/actions/runs/10689912664/job/29633120953?pr=784), so I had to use 2.4+ for this

Copy link
Collaborator

Choose a reason for hiding this comment

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

Personally I would prefer to keep supporting PyTorch 2.3 for low-bit optimizers. @msaroufim What do you think?

From the CI link you show, it seems like only 4-bit optim breaks, while 8-bit and Fp8 optim still work? Anyway, if we keep this change, also need to update the docs.

Copy link
Collaborator

Choose a reason for hiding this comment

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

After some investigation, the errors only happen to 4-bit optim, and because 4-bit optim uses dynamic-shape compile. Some strange interactions between inheritance and dynamic-shape 🤔. Might have some fix soon..

jerryzh168 added a commit to jerryzh168/ao that referenced this pull request Sep 4, 2024
* Move more utils to TorchAOBaseTensor

Summary:
This moves over _implements, _dispatch__torch_dispatch__, _dispatch__torch_function__, _register_layout_cls and _get_layout_tensor_constructor
to `TorchAOBaseTensor` so when people inherit from this, they can get these utils directly

Test Plan:
python test/quantization/test_quant_api.py
python test/integration/test_integration.py

rely on CI for other tests

Reviewers:

Subscribers:

Tasks:

Tags:
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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants