Skip to content
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

Refactor Affine Quantized Tensor #1234

Open
wants to merge 17 commits into
base: main
Choose a base branch
from
Open

Refactor Affine Quantized Tensor #1234

wants to merge 17 commits into from

Conversation

jainapurva
Copy link
Contributor

@jainapurva jainapurva commented Nov 7, 2024

Move Dtype Layout / TensorImpl class and dispatcher check-impl to their respective layout files

  • Affine_quantized_tensor_ops.py contains
    • aten.ops implementations for aqt
    • Dispatch registration and dtype kernels impl/check imports
  • Dtype Layout files
    • torchao/dtypes/floatx
      • Float8_layout.py
      • Floatx_tensor_core_layout.py
    • torchao/dtypes/uintx
      • Block_sparse_layout.py
      • Marlin_sparse_layout.py
      • Plain_layout.py
      • Semi_sparse_layout.py
      • Tensor_core_tiled_layout.py
      • Uint4_layout.py
      • uintx_layout.py
      • marlin_qqq_layout.py

Test Plan: Pass all external and internal tests

Copy link

pytorch-bot bot commented Nov 7, 2024

🔗 Helpful Links

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

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

❗ 1 Active SEVs

There are 1 currently active SEVs. If your PR is affected, please view them below:

✅ No Failures

As of commit d992432 with merge base 06ad55a (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 Nov 7, 2024
drisspg and others added 6 commits November 6, 2024 23:05
Ruff format and lint on some high traffic files
Update pre-commit to match CI/CD
stack-info: PR: #1228, branch: drisspg/stack/19
* add module swap UX

* update

* fix typing. add small notes

* try NF4 support

* fix

* fix unpacking

* fix

* update nf4 integration

* update backward pass
@jainapurva jainapurva added the topic: not user facing Use this tag if you don't want this PR to show up in release notes label Nov 12, 2024
@jainapurva jainapurva marked this pull request as ready for review November 14, 2024 00:41
@@ -12,4 +13,6 @@
"to_scaled_tc_floatx",
"from_scaled_tc_floatx",
"_SPLIT_K_MAP",
"Float8AQTTensorImpl",
Copy link
Contributor

Choose a reason for hiding this comment

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

if this is not used by other people, maybe we can remove, this is supposed to be internal mostly I think

@@ -12,4 +31,11 @@
"UintxAQTTensorImpl",
"to_uintx",
"_DTYPE_TO_BIT_WIDTH",
"_BIT_WIDTH_TO_DTYPE",
"UInt4Tensor",
"PlainAQTTensorImpl",
Copy link
Contributor

Choose a reason for hiding this comment

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

probably don't need to expose this one

@@ -12,4 +31,11 @@
"UintxAQTTensorImpl",
Copy link
Contributor

Choose a reason for hiding this comment

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

we can probably remove this one as well

@@ -36,7 +36,7 @@
to_affine_quantized_floatx_static,
to_affine_quantized_intx,
)
from torchao.dtypes.uintx.uintx import UintxLayout
from torchao.dtypes.uintx.uintx_layout import UintxLayout
Copy link
Contributor

Choose a reason for hiding this comment

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

we can import from torchao.dtypes for now I think

Copy link
Contributor

Choose a reason for hiding this comment

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

should be a follow up: this is not used actually, I think we can move this to prototype

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Will do this in separate PR

@@ -1,13 +1,9 @@
from . import affine_quantized_tensor_ops

# from ..prototype.dtypes.uint2 import UInt2Tensor, BitnetTensor
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: we can remove this I think

from .utils import (
Layout,
PlainLayout,
)

# from ..prototype.dtypes.uint2 import UInt2Tensor, BitnetTensor
Copy link
Contributor

Choose a reason for hiding this comment

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

same for this line

@@ -1,12 +1,7 @@
import unittest
import torch
from torchao.dtypes.affine_quantized_tensor import (
to_affine_quantized_intx,
from torchao.quantization.quant_primitives import (
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: maybe we can just import from torchao.quantization now

)
from torchao.quantization.quant_primitives import (
Copy link
Contributor

Choose a reason for hiding this comment

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

same here

Copy link
Contributor

@jerryzh168 jerryzh168 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, thanks! please import to fbcode and check if there is any internal failures

@jainapurva jainapurva added the topic: bc-breaking Use this tag if this PR breaks backward compatibility label Nov 15, 2024
@pytorch pytorch deleted a comment from facebook-github-bot Nov 15, 2024
@pytorch pytorch deleted a comment from facebook-github-bot Nov 15, 2024
@pytorch pytorch deleted a comment from facebook-github-bot Nov 15, 2024
@pytorch pytorch deleted a comment from facebook-github-bot Nov 15, 2024
@facebook-github-bot
Copy link

@jainapurva has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

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: bc-breaking Use this tag if this PR breaks backward compatibility 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.

5 participants