[Feature] Improve weight loading log (#18651)
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
This commit is contained in:
co-authored by
gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
parent
9305f0e58d
commit
f7897def96
@@ -775,14 +775,36 @@ class ModelConfig:
|
||||
quant_algo = json_quant_configs.get("quant_algo", None)
|
||||
|
||||
if quant_algo == "MIXED_PRECISION":
|
||||
return {"quant_method": "w4afp8"}
|
||||
return {"quant_method": "w4afp8", "quant_algo": quant_algo}
|
||||
elif quant_algo and ("FP4" in quant_algo or "NVFP4" in quant_algo):
|
||||
return {"quant_method": "modelopt_fp4"}
|
||||
return {"quant_method": "modelopt_fp4", "quant_algo": quant_algo}
|
||||
elif quant_algo and "FP8" in quant_algo:
|
||||
return {"quant_method": "modelopt_fp8"}
|
||||
return {"quant_method": "modelopt_fp8", "quant_algo": quant_algo}
|
||||
else:
|
||||
return None
|
||||
|
||||
def get_quantization_config_log_str(self) -> Optional[str]:
|
||||
"""
|
||||
Get a concise string representation of the quantization config for logging.
|
||||
Returns something like "quant=fp8, fmt=e4m3" or "quant=gptq, bits=4".
|
||||
"""
|
||||
try:
|
||||
quant_cfg = self._parse_quant_hf_config()
|
||||
if not quant_cfg:
|
||||
return None
|
||||
|
||||
quant_method = quant_cfg.get("quant_method", "quantized")
|
||||
log_str = f"quant={quant_method}"
|
||||
|
||||
# Append interesting fields if they exist
|
||||
for field in ["bits", "quant_algo", "fmt"]:
|
||||
if field in quant_cfg:
|
||||
log_str += f", {field}={quant_cfg[field]}"
|
||||
|
||||
return log_str
|
||||
except Exception:
|
||||
return None
|
||||
|
||||
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)
|
||||
|
||||
Reference in New Issue
Block a user