Skip to content

PTQ-Level Efficiency, QAT-Level Accuracy | 训练后量化的效率,量化感知训练的精度

[bug fix] force ignore mlp.gate (#1501)

Xin Hef5f6b05940e6
diff --git a/auto_round/special_model_handler.py b/auto_round/special_model_handler.py
index 2371941f5..f051b9673 100644
--- a/auto_round/special_model_handler.py
+++ b/auto_round/special_model_handler.py
@@ -19,7 +19,7 @@ import torch
from auto_round.formats import OutputFormat
from auto_round.modeling.fused_moe.replace_modules import apply_replacements, release_original_module_
-from auto_round.utils import logger
+from auto_round.utils import is_moe_model_via_config, logger
mllms_with_limited_bs = ("llava", "qwen2_vl", "phi3_v", "mllama") # Limitations on batch_size
@@ -217,34 +217,6 @@ def register_ignore_layers(
_PRE_DEFINED_IGNORE_LAYERS.append(rule)
-register_ignore_layers(
- matchers=[
- ModelTypeMatcher(r"qwen3_vl_moe", mode="full"),
- ],
- ignore_layers=[
- "mlp.gate", # vllm inference issue
- ],
-)
-
-register_ignore_layers(
- matchers=[
- ModelTypeMatcher(r"qwen3_moe", mode="full"),
- ],
- ignore_layers=[
- "mlp.gate", # vllm inference issue
- ],
-)
-
-register_ignore_layers(
- matchers=[
- ModelTypeMatcher(r"qwen3_5_moe", mode="full"),
- ],
- ignore_layers=[
- "mlp.gate", # vllm inference issue
- ],
-)
-
-
# longcat
register_ignore_layers(
matchers=[
@@ -298,10 +270,8 @@ def get_predefined_ignore_layers(model: torch.nn.Module) -> list[str]:
else:
layers.extend(res)
break
- if not layers:
- if hasattr(model, "config") and hasattr(model.config, "model_type"):
- model_type = model.config.model_type
- if "moe" in model_type: # Append gate which usually cause vllm issue
- layers.append("mlp.gate")
+ config = getattr(model, "config", None)
+ if not layers and is_moe_model_via_config(config):
+ layers.append("mlp.gate")
return list(dict.fromkeys(layers))