Update modelopt quantization config parsing (#13919)

Signed-off-by: Zhiyu Cheng <zhiyuc@nvidia.com>
This commit is contained in:
Zhiyu
2026-02-12 11:08:29 +08:00
committed by GitHub
parent b2d7fd5c87
commit 7e262b6496
2 changed files with 19 additions and 0 deletions
+17
View File
@@ -626,6 +626,17 @@ class ModelConfig:
# adapted from https://github.com/vllm-project/vllm/blob/v0.6.4.post1/vllm/config.py
def _parse_quant_hf_config(self):
quant_cfg = getattr(self.hf_config, "quantization_config", None)
if quant_cfg is not None and not isinstance(quant_cfg, dict):
quant_cfg = quant_cfg.to_dict()
if quant_cfg is not None:
# Identify modelopt quantization
if "quant_method" not in quant_cfg:
parsed_cfg = self._parse_modelopt_quant_config(
{"quantization": quant_cfg}
)
if parsed_cfg:
quant_cfg.update(parsed_cfg)
if quant_cfg is None:
# compressed-tensors uses a "compression_config" key
quant_cfg = getattr(self.hf_config, "compression_config", None)
@@ -736,6 +747,12 @@ class ModelConfig:
def _is_already_quantized(self) -> bool:
"""Check if the model is already quantized based on config files."""
# Check for quantization in hf_config (config.json)
if getattr(self.hf_config, "quantization_config", None) or getattr(
self.hf_config, "compression_config", None
):
return True
# Check for HuggingFace quantization config
from sglang.srt.utils import has_hf_quant_config