Skip to content

Add UInt4Tensor with tensor subclass#117557

Closed
jerryzh168 wants to merge 1 commit into
gh/jerryzh168/839/basefrom
gh/jerryzh168/839/head
Closed

Add UInt4Tensor with tensor subclass#117557
jerryzh168 wants to merge 1 commit into
gh/jerryzh168/839/basefrom
gh/jerryzh168/839/head

Conversation

@jerryzh168

@jerryzh168 jerryzh168 commented Jan 16, 2024

Copy link
Copy Markdown
Contributor

Stack from ghstack (oldest at bottom):

Summary:
As a follow up from #117208, this PR added a UInt4Tensor
in python, it can be used to construct a uint4 tensor and supports some basic operations like
view, slice etc.

We can extend this to support different quantized tensors as mentioned in the previous PR.

Later

  • tensor factory support for uint4, and other sub byte dtypes
  • other sub byte tensor subclass support

Test Plan:
python test/test_tensors.py -k test_constructor

Reviewers:

Subscribers:

Tasks:

Tags:

Summary:
As a follow up from #117208, this PR added a UInt4Tensor
in python, it can be used to construct a uint4 tensor and supports some basic operations like
view, slice etc.

We can extend this to support different quantized tensors as mentioned in the previous PR.

Later
* tensor factory support for uint4, and other sub byte dtypes
* other sub byte tensor subclass support

Test Plan:
python test/test_tensors.py -k test_constructor

Reviewers:

Subscribers:

Tasks:

Tags:

[ghstack-poisoned]
@pytorch-bot pytorch-bot Bot added the release notes: quantization release notes category label Jan 16, 2024
@pytorch-bot

pytorch-bot Bot commented Jan 16, 2024

Copy link
Copy Markdown

🔗 Helpful Links

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

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

❌ 11 New Failures, 8 Unrelated Failures

As of commit 16fb02f with merge base 99e5474 (image):

NEW FAILURES - The following jobs have failed:

FLAKY - The following jobs failed but were likely due to flakiness present on trunk:

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

jerryzh168 added a commit that referenced this pull request Jan 16, 2024
Summary:
As a follow up from #117208, this PR added a UInt4Tensor
in python, it can be used to construct a uint4 tensor and supports some basic operations like
view, slice etc.

We can extend this to support different quantized tensors as mentioned in the previous PR.

Later
* tensor factory support for uint4, and other sub byte dtypes
* other sub byte tensor subclass support

Test Plan:
python test/test_tensors.py -k test_constructor

Reviewers:

Subscribers:

Tasks:

Tags:

ghstack-source-id: 7461060
Pull Request resolved: #117557
Comment thread torch/tensors/__init__.py
@@ -0,0 +1,5 @@
from .uint1_7 import UInt4Tensor

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Use torch._subclasses, it already exists

Comment thread torch/tensors/uint1_7.py
@@ -0,0 +1,215 @@
import torch

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

1_7 is a terrible name. How about sub_byte_uint or tiny_uint

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

OK, I can use sub_byte_uint

@ezyang ezyang left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I'm not really sure what the point of putting this into pytorch/pytorch right now is? There is a lot of build out you need, and you are not making use of being in pytorch/pytorch in any essential way. Get further along the implementation before requesting review, IMO.

[0x23, 0x45],
[0x23, 0x45],
], dtype=torch.uint8))
self.assertEqual(x[:, 2:6], expected)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Is this testing actually sufficient? Not convinced...

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

you mean for the entire subclass or just the slicing operation? we do have a lot more tests that I'm planning to put in torchao repo

@jerryzh168

Copy link
Copy Markdown
Contributor Author

I'm not really sure what the point of putting this into pytorch/pytorch right now is? There is a lot of build out you need, and you are not making use of being in pytorch/pytorch in any essential way. Get further along the implementation before requesting review, IMO.

oh OK sure, I can build this in torchao first

@albanD albanD removed their request for review January 24, 2024 19:43
@jerryzh168

Copy link
Copy Markdown
Contributor Author

will add this later

@jerryzh168 jerryzh168 closed this Feb 10, 2024
@github-actions github-actions Bot deleted the gh/jerryzh168/839/head branch March 12, 2024 01:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

release notes: quantization release notes category

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants