根据模型名字自动检测量化精度 - 如果模型名字包含 "int8" → "int8" - 如果模型名字包含 "fp8" 且设备支持 → "fp8" - 否则返回 None(表示不使用量化)
(model_name)
| 433 | |
| 434 | |
| 435 | def detect_quant_scheme(model_name): |
| 436 | """根据模型名字自动检测量化精度 |
| 437 | - 如果模型名字包含 "int8" → "int8" |
| 438 | - 如果模型名字包含 "fp8" 且设备支持 → "fp8" |
| 439 | - 否则返回 None(表示不使用量化) |
| 440 | """ |
| 441 | if not model_name: |
| 442 | return None |
| 443 | # 延迟导入避免循环依赖 |
| 444 | from utils.model_utils import is_fp8_supported_gpu |
| 445 | |
| 446 | name_lower = model_name.lower() |
| 447 | if "int8" in name_lower: |
| 448 | return "int8" |
| 449 | elif "fp8" in name_lower: |
| 450 | if is_fp8_supported_gpu(): |
| 451 | return "fp8" |
| 452 | else: |
| 453 | # 设备不支持fp8,返回None(使用默认精度) |
| 454 | return None |
| 455 | return None |
| 456 | |
| 457 | |
| 458 | def is_distill_model_from_name(model_name): |
no test coverage detected