[Fix][NPU] Preserve existing packed_modules_mapping when merging model-level fused module mappings (#25755)

This commit is contained in:
Kurkur
2026-05-29 09:11:36 +08:00
committed by GitHub
parent a8cfae0b30
commit fffdfb6fcb
3 changed files with 8 additions and 2 deletions
@@ -131,6 +131,9 @@ class QuantizationConfig(ABC):
# mapping is updated by models as they initialize
self.packed_modules_mapping: Dict[str, List[str]] = dict()
def update_packed_modules_mapping(self, mapping: Dict[str, List[str]]) -> None:
self.packed_modules_mapping = mapping
@abstractmethod
def get_name(self) -> str:
"""Name of the quantization method."""
@@ -108,6 +108,9 @@ class ModelSlimConfig(QuantizationConfig):
[npu_wrapper_rmsnorm_forward],
)
def update_packed_modules_mapping(self, mapping: Dict[str, List[str]]) -> None:
self.packed_modules_mapping.update(mapping)
def get_linear_method(self) -> ModelSlimLinearMethod:
return ModelSlimLinearMethod(self)
+2 -2
View File
@@ -2462,8 +2462,8 @@ class DeepseekV2ForCausalLM(nn.Module, DeepseekV2WeightLoaderMixin):
# 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
if quant_config is not None:
quant_config.update_packed_modules_mapping(self.packed_modules_mapping)
self.pp_group = get_pp_group()
self.config = config