[Fix] GLM 4.7 + NVFP4 + MTP (#17166)
This commit is contained in:
@@ -834,20 +834,29 @@ class ModelConfig:
|
||||
if self.quantization is None:
|
||||
self.quantization = quant_method
|
||||
elif self.quantization != quant_method:
|
||||
# Allow auto-detection of quantization from checkpoint for draft model
|
||||
# even if it differs from main model's quantization
|
||||
if self.is_draft_model:
|
||||
# Check if the CLI-specified quantization is compatible with HF config's quant_method
|
||||
is_compatible = (
|
||||
self.quantization in compatible_quantization_methods
|
||||
and quant_method
|
||||
in compatible_quantization_methods[self.quantization]
|
||||
)
|
||||
if is_compatible:
|
||||
# Keep the CLI-specified quantization (e.g., modelopt_fp4) even if
|
||||
# HF config says "modelopt" - they are compatible
|
||||
logger.info(
|
||||
f"Using CLI-specified quantization ({self.quantization}) which is "
|
||||
f"compatible with HF config quant_method ({quant_method})."
|
||||
)
|
||||
elif self.is_draft_model:
|
||||
# Allow auto-detection of quantization from checkpoint for draft model
|
||||
# only if the CLI quantization is not compatible
|
||||
logger.info(
|
||||
f"Draft model quantization ({quant_method}) differs from "
|
||||
f"main model quantization ({self.quantization}). "
|
||||
f"Using draft model's detected quantization: {quant_method}"
|
||||
)
|
||||
self.quantization = quant_method
|
||||
elif (
|
||||
self.quantization not in compatible_quantization_methods
|
||||
or quant_method
|
||||
not in compatible_quantization_methods[self.quantization]
|
||||
):
|
||||
else:
|
||||
raise ValueError(
|
||||
"Quantization method specified in the model config "
|
||||
f"({quant_method}) does not match the quantization "
|
||||
|
||||
Reference in New Issue
Block a user