-
Notifications
You must be signed in to change notification settings - Fork 321
Adds Q/DQ layout support for embedding quantization with IntxWeightOnlyConfig #1972
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,7 +19,7 @@ | |
Int8DynamicActivationIntxWeightConfig, | ||
SharedEmbeddingQuantizer, | ||
) | ||
from torchao.quantization.granularity import PerGroup, PerRow | ||
from torchao.quantization.granularity import PerAxis, PerGroup, PerRow | ||
from torchao.quantization.quant_api import quantize_ | ||
|
||
|
||
|
@@ -68,7 +68,7 @@ def test_accuracy(self): | |
|
||
def test_export_compile_aoti(self): | ||
weight_dtype = torch.int4 | ||
granularity = PerRow() | ||
granularity = PerAxis(0) | ||
embedding_dim = 4096 | ||
num_embeddings = 131 | ||
model = torch.nn.Sequential( | ||
|
@@ -113,7 +113,6 @@ def test_export_compile_aoti(self): | |
|
||
def test_shared_embedding(self): | ||
weight_dtype = torch.int4 | ||
granularity = PerRow() | ||
has_weight_zeros = True | ||
embedding_dim = 4096 | ||
num_embeddings = 131 | ||
|
@@ -134,14 +133,14 @@ def test_shared_embedding(self): | |
quantized_model_reference = copy.deepcopy(model) | ||
EmbeddingQuantizer( | ||
weight_dtype=weight_dtype, | ||
granularity=granularity, | ||
granularity=PerAxis(0), | ||
has_weight_zeros=has_weight_zeros, | ||
).quantize(quantized_model_reference) | ||
quantize_( | ||
quantized_model_reference, | ||
Int8DynamicActivationIntxWeightConfig( | ||
weight_dtype=weight_dtype, | ||
granularity=granularity, | ||
granularity=PerRow(), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. should this be PerAxis as well There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It can't be because that's controlled by Int8DynamicActivationIntxWeightConfig, which uses PerRow until #1968 lands |
||
has_weight_zeros=has_weight_zeros, | ||
round_weight_scale_to_bf16=False, | ||
layout=PackedLinearInt8DynamicActivationIntxWeightLayout( | ||
|
@@ -155,7 +154,7 @@ def test_shared_embedding(self): | |
quantized_model = copy.deepcopy(model) | ||
SharedEmbeddingQuantizer( | ||
weight_dtype=weight_dtype, | ||
granularity=granularity, | ||
granularity=PerRow(), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. and this |
||
has_weight_zeros=has_weight_zeros, | ||
).quantize(quantized_model) | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why does line 299 only dequantizes weight bu tnot actually run embedding op?