Skip to content

Commit d53ba36

Browse files
committed
cleanup, logging
Signed-off-by: Kyle Sayers <[email protected]>
1 parent 199f274 commit d53ba36

File tree

2 files changed

+16
-11
lines changed

2 files changed

+16
-11
lines changed

src/compressed_tensors/quantization/lifecycle/initialize.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ def initialize_module_for_quantization(
104104
if scheme.input_activations is not None:
105105
base_name = "input"
106106
args = scheme.input_activations
107-
observed_shape = (1, weight.size(-1))
107+
observed_shape = (1, weight.shape[-1])
108108
observed_dtype = weight.dtype
109109

110110
if scheme.weights is not None:
@@ -185,7 +185,7 @@ def _initialize_scale_zero_point(
185185
if len(observed_shape) < 1:
186186
raise ValueError("Channel quant requires at least 1 observed dimension")
187187

188-
expected_shape = (observed_shape[-1], 1)
188+
expected_shape = (observed_shape[-2], 1)
189189

190190
elif strategy in (QuantizationStrategy.GROUP, QuantizationStrategy.TENSOR_GROUP):
191191
assert quantization_args.group_size is not None

src/compressed_tensors/quantization/quant_scheme.py

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
QuantizationType,
2525
)
2626
from pydantic import BaseModel, ConfigDict, model_validator
27+
from loguru import logger
2728

2829

2930
__all__ = [
@@ -60,15 +61,19 @@ def validate_model_after(model: "QuantizationScheme") -> "QuantizationScheme":
6061
format = model.format
6162

6263
if inputs is not None:
63-
if inputs.strategy not in (
64-
QuantizationStrategy.TOKEN,
65-
QuantizationStrategy.TENSOR,
66-
QuantizationStrategy.GROUP,
67-
QuantizationStrategy.TENSOR_GROUP,
68-
):
69-
raise NotImplementedError(
70-
f"Using {inputs.strategy} strategy is not supported for "
71-
"activation quantization"
64+
if inputs.strategy == QuantizationStrategy.CHANNEL:
65+
raise ValueError(
66+
"Channel-wise activation quantization is equivalent to "
67+
"tensor/token-wise activation quantization, please use one of "
68+
"those. If you mean to quantize each activation value "
69+
"individually, please use group quantization with `group_size = 1`"
70+
)
71+
72+
if inputs.strategy == QuantizationStrategy.BLOCK:
73+
raise ValueError(
74+
"Block-wise activation quantization is not supported. If you mean "
75+
"to quantize each activation value individually, please use group "
76+
"quantization with `group_size = 1`"
7277
)
7378

7479
if inputs.actorder is not None:

0 commit comments

Comments
 (0)