-
Notifications
You must be signed in to change notification settings - Fork 185
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix dimension issues for int4 weight only quant path (#330)
Summary: Currently the accepted dimension of _quantized_linear is not clear, this PR fixes the issue. Currently the "tensor_core_tiled" layout tensor does not do repacking in view operation, which is incorrect, this PR removes the view support (which is not needed right now), and restrict the use case to transpose op, and records the transpose status of the tensor instead of doing repacking for performance. Test Plan: python test/quantization/test_quant_api.py python test/integration/test_integration.py Reviewers: Subscribers: Tasks: Tags:
- Loading branch information
1 parent
c38fc4a
commit 79f2c7f
Showing
3 changed files
with
74 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
from torch.testing._internal.common_utils import ( | ||
TestCase, | ||
run_tests, | ||
) | ||
from torchao.quantization.quant_api import get_apply_int4wo_quant | ||
import torch | ||
import unittest | ||
|
||
|
||
class TestAQ(TestCase): | ||
@unittest.skipIf(not torch.cuda.is_available(), "Need CUDA available") | ||
def test_tensor_core_layout_transpose(self): | ||
t = torch.rand(128, 256, dtype=torch.bfloat16, device="cuda") | ||
shape = t.shape | ||
apply_int4wo_quant = get_apply_int4wo_quant(groupsize=32) | ||
aqt = apply_int4wo_quant(t) | ||
aqt_shape = aqt.shape | ||
self.assertEqual(aqt_shape, shape) | ||
|
||
# transpose shape test | ||
for _ in range(10): | ||
t = t.t() | ||
aqt = aqt.t() | ||
shape = t.shape | ||
aqt_shape = aqt.shape | ||
self.assertEqual(aqt_shape, shape) | ||
|
||
if __name__ == "__main__": | ||
run_tests() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters