-
Notifications
You must be signed in to change notification settings - Fork 259
Description
🐛 Describe the bug
AdvancedSmoothQuantParameters(matmul=alpha_v) for alpha_v in itertools.product(alpha_values) |
I think that this line is currently subtly broken.
Right now, _get_smooth_quant_param_grid()
returns
{
'advanced_parameters:smooth_quant_alphas': [
AdvancedSmoothQuantParameters(convolution=-1, matmul=(0.15,)),
AdvancedSmoothQuantParameters(convolution=-1, matmul=(0.25,)),
AdvancedSmoothQuantParameters(convolution=-1, matmul=(0.5,)),
AdvancedSmoothQuantParameters(convolution=-1, matmul=(0.75,)),
AdvancedSmoothQuantParameters(convolution=-1, matmul=(0.95,))
]
}
Notice that the matmul
values are wrapped in an extra tuple
instead of just being plain floats
like they are supposed to. This is happening because itertools.product(*iterables)
will always return tuples of length len(iterables)
even when there is only 1 argument.
These tuple
values will then cause a crash in create_ptq_pipeline
:
File "/.../site-packages/nncf/quantization/algorithms/post_training/pipeline.py", line 97, in create_ptq_pipeline
if model_type == ModelType.TRANSFORMER and (sq_params.convolution >= 0 or sq_params.matmul >= 0):
TypeError: '>=' not supported between instances of 'tuple' and 'int'
Environment
NNCF 2.17.0
OpenVINO 2025.2.0
Torch 2.7.1
ONNX 1.18.0
OS Ubuntu 22.04.3 LTS
Python 3.10.12
Install PyPI
Minimal Reproducible Example
I don't have a proper MRE right now, but I think that any quantization pipeline with enabled hyperparameter tuning should demonstrate the crash. So, something along the lines of:
nncf.quantize_with_accuracy_control(
model=openvino_model,
...,
advanced_accuracy_restorer_parameters=nncf.AdvancedAccuracyRestorerParameters(
tune_hyperparams=True,
...,
),
)
Also, I think that the issue if fairly obvious from the _get_smooth_quant_param_grid
code mentioned above. I was able to fix the issue by adding the missing tuple unpacking
- AdvancedSmoothQuantParameters(matmul=alpha_v) for alpha_v in itertools.product(alpha_values)
+ AdvancedSmoothQuantParameters(matmul=alpha_v) for alpha_v, in itertools.product(alpha_values)
Are you going to submit a PR?
- Yes I'd like to help by submitting a PR!