Skip to content

Commit 49c6a43

Browse files
committed
Update on "Adding uint4 dtype implementation"
Summary: We have a lot of interest for int4 dtypes, and we'd like to add the dtype out of PyTorch core. This PR added some preliminary support for uint4 through tensor subclass and we'll continue to iterate on this Test Plan: python test/dtypes/test_int4.py Reviewers: Subscribers: Tasks: Tags: [ghstack-poisoned]
1 parent c52b123 commit 49c6a43

File tree

1 file changed

+1
-10
lines changed

1 file changed

+1
-10
lines changed

torchao/dtypes/uint4.py

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -107,11 +107,6 @@ def __hash__(self):
107107
def __eq__(self, other):
108108
return torch.equal(self.elem, other.elem)
109109

110-
# def __getattribute__(self, name):
111-
# if name == "dtype":
112-
# return torch.uint4
113-
# return super().__getattribute__(name)
114-
115110
@classmethod
116111
def __torch_dispatch__(cls, func, types, args, kwargs=None):
117112
if func is torch.ops.aten.view.default:
@@ -272,10 +267,6 @@ def from_unpacked(cls, unpacked, scales):
272267

273268
@classmethod
274269
def __torch_dispatch__(cls, func, types, args, kwargs=None):
275-
# didin't hit this, there is a mysterious error if we try to go through this path
276-
# torch._dynamo.exc.BackendCompilerFailed: backend='inductor' raised:
277-
# Exception: Please convert all Tensors to FakeTensors first or
278-
# instantiate FakeTensorMode with 'allow_non_fake_inputs'
279270
if func is torch.ops.aten.addmm.default:
280271
bias, x, weight = args
281272
x_view = x.view(-1, x.shape[-1])
@@ -285,7 +276,7 @@ def __torch_dispatch__(cls, func, types, args, kwargs=None):
285276
y += bias
286277
return y
287278
elif func is torch.ops.aten.t.default:
288-
# assert False, "transpose is not properly implemented currently"
279+
# TODO: add proper support for transpose
289280
self, = args
290281
unpacked = unpack_uint4(self.elem)
291282
transposed = torch.ops.aten.t.default(unpacked)

0 commit comments

Comments
 (0)