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

Add unsigned integer dtypes to PyTorch #116594

Closed
wants to merge 6 commits into from

Conversation

Copy link

pytorch-bot bot commented Jan 2, 2024

🔗 Helpful Links

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

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

✅ No Failures

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

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

ezyang added a commit that referenced this pull request Jan 2, 2024
Signed-off-by: Edward Z. Yang <ezyang@meta.com>

ghstack-source-id: 0a0a53bc66a27201601da0de0d6361f00a71943e
Pull Request resolved: #116594
Copy link
Collaborator

@albanD albanD left a comment

Choose a reason for hiding this comment

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

nit on the c++ API naming but sounds good.
it might be good to collect a full list on the issue of the todos for these dtype (python binding, op support, testing support, serialization, etc) so that we can ensure we have a clear "current state" for them somewhere.

@@ -424,6 +454,10 @@ static inline bool isBitsType(ScalarType t) {
t == ScalarType::Bits16;
}

static inline bool isBarebonesUnsignedType(ScalarType t) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should UInt8 be in here as well?
I guess not given how you use it for the type promotion checks. But this might be a confusing API for our c++ devs?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Bare bones here is defined to be "we have only minimal kernel support in traditional C++ eager mode". Since uint8 is grandfathered from Lua days to have lots of kernels, it shouldn't be included.

Copy link
Collaborator

Choose a reason for hiding this comment

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

What is the plan to document that to make sure user expectations for these are appropriate?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The most logical place to document that these are bare bones is in torch.Tensor where we list supported dtypes. Note that the f8 dtypes are not documented right now, so we could also keep it under the radar undocumented until enough stuff is working. I am also half expecting to end up having a select few eager kernels sprout arbitrary unsigned support, especially gather-like operations I think is what people are most likely to want.

Copy link
Collaborator

Choose a reason for hiding this comment

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

One could argue that fp8 dtypes are not very well documented and shouldn't be the example here. Also there is a strong alignment there that we will not implement any arithmetic op for these dtypes (no scale means no compute with the value).
These dtypes could contain the full thing so we most likely want to have some details about that?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll post a proposed doc PR and we can discuss it there

Copy link
Contributor Author

Choose a reason for hiding this comment

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

c10/core/ScalarType.h Outdated Show resolved Hide resolved
[ghstack-poisoned]
ezyang added a commit that referenced this pull request Jan 2, 2024
Signed-off-by: Edward Z. Yang <ezyang@meta.com>

ghstack-source-id: c57e37ed810903053c39d39938c8a474e45d2ec2
Pull Request resolved: #116594
@vadimkantorov
Copy link
Contributor

a new era for pytorch in 2024! :)

[ghstack-poisoned]
ezyang added a commit that referenced this pull request Jan 3, 2024
Signed-off-by: Edward Z. Yang <ezyang@meta.com>

ghstack-source-id: cdd5bc9d8c2d674dcbc81ab0068350036151b5b5
Pull Request resolved: #116594
The dtypes are very useless right now (not even fill works), but it makes torch.uint16, uint32 and uint64 available as a dtype.

Towards #58734

Signed-off-by: Edward Z. Yang <ezyangmeta.com>

[ghstack-poisoned]
ezyang added a commit that referenced this pull request Jan 3, 2024
Signed-off-by: Edward Z. Yang <ezyang@meta.com>

ghstack-source-id: ea80c197bc2da1a11aebe3b69bd7a61fd3feaf2c
Pull Request resolved: #116594
@ezyang ezyang mentioned this pull request Jan 3, 2024
The dtypes are very useless right now (not even fill works), but it makes torch.uint16, uint32 and uint64 available as a dtype.

Towards #58734

Signed-off-by: Edward Z. Yang <ezyangmeta.com>

[ghstack-poisoned]
The dtypes are very useless right now (not even fill works), but it makes torch.uint16, uint32 and uint64 available as a dtype.

Towards #58734

Signed-off-by: Edward Z. Yang <ezyangmeta.com>

[ghstack-poisoned]
@ezyang ezyang added release notes: python_frontend release notes category topic: new features topic category labels Jan 6, 2024
@ezyang
Copy link
Contributor Author

ezyang commented Jan 7, 2024

@pytorchbot merge

@pytorch-bot pytorch-bot bot added the ciflow/trunk Trigger trunk jobs on your pull request label Jan 7, 2024
@pytorchmergebot
Copy link
Collaborator

Merge started

Your change will be merged once all checks pass (ETA 0-4 Hours).

Learn more about merging in the wiki.

Questions? Feedback? Please reach out to the PyTorch DevX Team

Advanced Debugging
Check the merge workflow status
here

@vadimkantorov
Copy link
Contributor

Will reinterpret int16_tensor.view(torch.uint16) and reverse be supported out of the box?

Another useful thing to support for unsigned tensors are more bit ops: #105465 as more bit ops are clearly defined for unsigned types and do not need any special behavior for negative operands

@ezyang
Copy link
Contributor Author

ezyang commented Jan 7, 2024

Yeah, I didn't test it but the mechanism is dtype agnostic.

We probably will end up negotiating some sort of basic set of ops which we will provide in eager mode, I'm thinking of letting the current binary size changes settle first before moving on.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ciflow/trunk Trigger trunk jobs on your pull request Merged release notes: python_frontend release notes category topic: new features topic category
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants