@@ -76,7 +76,12 @@ def create_asymmetric_quant_config(
76
76
(QuantizationStrategy .CHANNEL , None ),
77
77
],
78
78
)
79
- def test_end_to_end_asymmetric_quantization (strategy , group_size ):
79
+ def test_end_to_end_asymmetric_quantization (
80
+ strategy ,
81
+ group_size ,
82
+ mock_per_group_calibration ,
83
+ mock_per_channel_calibration ,
84
+ ):
80
85
"""
81
86
Test end-to-end workflow: quantize -> compress -> save -> load -> decompress -> use
82
87
"""
@@ -95,6 +100,13 @@ def test_end_to_end_asymmetric_quantization(strategy, group_size):
95
100
group_size = group_size
96
101
)
97
102
apply_quantization_config (model , quant_config )
103
+
104
+ if strategy == QuantizationStrategy .GROUP :
105
+ mock_per_group_calibration (model .layer1 , "weight" , model .layer1 .weight , group_size )
106
+ mock_per_group_calibration (model .layer2 , "weight" , model .layer2 .weight , group_size )
107
+ else :
108
+ mock_per_channel_calibration (model .layer1 , "weight" , model .layer1 .weight )
109
+ mock_per_channel_calibration (model .layer2 , "weight" , model .layer2 .weight )
98
110
99
111
100
112
@@ -146,7 +158,7 @@ def test_end_to_end_asymmetric_quantization(strategy, group_size):
146
158
147
159
148
160
@pytest .mark .parametrize ("num_bits" , [4 , 8 ])
149
- def test_asymmetric_quantization_accuracy (num_bits ):
161
+ def test_asymmetric_quantization_accuracy (num_bits , mock_per_group_calibration ):
150
162
"""
151
163
Test that asymmetric quantization with zero-point preserves accuracy better
152
164
than symmetric quantization for biased weight distributions.
@@ -173,6 +185,7 @@ def __init__(self):
173
185
174
186
with torch .no_grad ():
175
187
model .layer .weight .copy_ (biased_weights )
188
+ mock_per_group_calibration (model .layer , "weight" , model .layer .weight , 128 )
176
189
177
190
compressor = PackedQuantizationCompressor (config = quant_config )
178
191
quantized_modules_to_scheme = {"layer" : quant_config .config_groups ["group_1" ]}
0 commit comments