[AutoRound] Support WAN2.2 W4A16 quantization model (#3353)

Signed-off-by: lvliang-intel <liang1.lv@intel.com>
Signed-off-by: hyh_hh <huyinghong1@huawei.com>
Co-authored-by: hxhhhlalala <hyh_hh@163.com>
Co-authored-by: hyh_hh <huyinghong1@huawei.com>
This commit is contained in:
authored and GitHub committed 2026-05-21 17:54:41 +08:00
1 parent 474710dda9
commit 8297570c2b
9 files changed
+680 -8

No files matched your search

+40 -1
View File
@@ -99,6 +99,43 @@ _OVERRIDES: dict[str, Callable[..., QuantizationConfig]] = {
SUPPORTED_QUANTIZATION_METHODS: list[str] = list(dict.fromkeys(QUANTIZATION_METHODS + list(_OVERRIDES.keys())))
def _build_reverse_alias_map() -> dict[str, str]:
"""Build a mapping from normalized method aliases to canonical names.
All keys in _OVERRIDES that share the same builder function are considered
aliases of each other. The canonical name is the first key (in definition
order) that maps to a given builder — i.e. the one returned by
builder().get_name().
"""
builder_to_first_key: dict[Callable[..., QuantizationConfig], str] = {}
for key in _OVERRIDES:
builder = _OVERRIDES[key]
if builder not in builder_to_first_key:
builder_to_first_key[builder] = key
result: dict[str, str] = {}
for key, builder in _OVERRIDES.items():
canonical = builder_to_first_key[builder]
result[key.lower().replace("-", "_")] = canonical
return result
_CACHED_ALIAS_MAP: dict[str, str] | None = None
def _normalize_quant_method_alias(method: str | None) -> str | None:
"""Map a method name (or any of its aliases) to its canonical internal name.
Returns the input unchanged if it is not a known alias.
"""
if method is None:
return None
global _CACHED_ALIAS_MAP
if _CACHED_ALIAS_MAP is None:
_CACHED_ALIAS_MAP = _build_reverse_alias_map()
normalized = method.lower().replace("-", "_")
return _CACHED_ALIAS_MAP.get(normalized, normalized)
_MODEL_OPT_METHODS = {
"modelopt",
}
@@ -334,7 +371,9 @@ def resolve_quant_config_from_disk(
)
return build_quant_config(qc_method, **qc_kwargs)
if quant_config.get_name() != qc_method:
active_method = _normalize_quant_method_alias(quant_config.get_name())
disk_method = _normalize_quant_method_alias(qc_method)
if active_method != disk_method:
raise ValueError(
f"Checkpoint config.json declares quant_method={qc_method!r} but the "
f"active quantization config is {quant_config.get_name()!r}. "