[AMD] Enable shared-experts fusion with new KIMI-K2.5-MXFP4 model. (#25390)
This commit is contained in:
@@ -71,7 +71,13 @@ class QuarkConfig(QuantizationConfig):
|
||||
return "quark"
|
||||
|
||||
def apply_weight_name_mapper(self, hf_to_sglang_mapper):
|
||||
self.exclude_layers = hf_to_sglang_mapper.apply_list(self.exclude_layers)
|
||||
mapped = hf_to_sglang_mapper.apply_list(self.exclude_layers)
|
||||
expanded = []
|
||||
for name in mapped:
|
||||
expanded.append(name)
|
||||
if name.startswith("language_model."):
|
||||
expanded.append(name.removeprefix("language_model."))
|
||||
self.exclude_layers = list(dict.fromkeys(expanded))
|
||||
|
||||
def get_quant_method(
|
||||
self, layer: torch.nn.Module, prefix: str
|
||||
|
||||
@@ -2369,6 +2369,12 @@ class DeepseekV2ForCausalLM(nn.Module, DeepseekV2WeightLoaderMixin):
|
||||
"kv_a_proj_with_mqa",
|
||||
]
|
||||
|
||||
# Quant configs like Quark may rely on the model to provide fused-module
|
||||
# mappings so exclusion checks can unfuse derived names back to the
|
||||
# checkpoint's source layer names.
|
||||
if quant_config is not None and hasattr(quant_config, "packed_modules_mapping"):
|
||||
quant_config.packed_modules_mapping = self.packed_modules_mapping
|
||||
|
||||
self.pp_group = get_pp_group()
|
||||
self.config = config
|
||||
self.tp_size = get_tensor_model_parallel_world_size()
|
||||
@@ -2436,7 +2442,11 @@ class DeepseekV2ForCausalLM(nn.Module, DeepseekV2WeightLoaderMixin):
|
||||
disable_reason = "DeepEP: fusion off by default (use --enforce-shared-experts-fusion to enable)."
|
||||
elif (
|
||||
self.config.architectures[0] != architecture
|
||||
or self.config.n_routed_experts != 256
|
||||
# Allow-list of n_routed_experts values that have been validated
|
||||
# for shared-experts fusion under this code path. Currently:
|
||||
# 256 -> DeepSeek-V3 / R1
|
||||
# 384 -> Kimi-K2.5 (text_config wraps DeepseekV3ForCausalLM)
|
||||
or self.config.n_routed_experts not in (256, 384)
|
||||
or self.config.n_shared_experts != 1
|
||||
):
|
||||
disable_reason = "Config does not support fused shared expert(s)."
|
||||
|
||||
Reference in New Issue
Block a user