[Fix][NPU] Preserve existing packed_modules_mapping when merging model-level fused module mappings (#25755)
This commit is contained in:
@@ -131,6 +131,9 @@ class QuantizationConfig(ABC):
|
|||||||
# mapping is updated by models as they initialize
|
# mapping is updated by models as they initialize
|
||||||
self.packed_modules_mapping: Dict[str, List[str]] = dict()
|
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
|
@abstractmethod
|
||||||
def get_name(self) -> str:
|
def get_name(self) -> str:
|
||||||
"""Name of the quantization method."""
|
"""Name of the quantization method."""
|
||||||
|
|||||||
@@ -108,6 +108,9 @@ class ModelSlimConfig(QuantizationConfig):
|
|||||||
[npu_wrapper_rmsnorm_forward],
|
[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:
|
def get_linear_method(self) -> ModelSlimLinearMethod:
|
||||||
return ModelSlimLinearMethod(self)
|
return ModelSlimLinearMethod(self)
|
||||||
|
|
||||||
|
|||||||
@@ -2462,8 +2462,8 @@ class DeepseekV2ForCausalLM(nn.Module, DeepseekV2WeightLoaderMixin):
|
|||||||
# Quant configs like Quark may rely on the model to provide fused-module
|
# Quant configs like Quark may rely on the model to provide fused-module
|
||||||
# mappings so exclusion checks can unfuse derived names back to the
|
# mappings so exclusion checks can unfuse derived names back to the
|
||||||
# checkpoint's source layer names.
|
# checkpoint's source layer names.
|
||||||
if quant_config is not None and hasattr(quant_config, "packed_modules_mapping"):
|
if quant_config is not None:
|
||||||
quant_config.packed_modules_mapping = self.packed_modules_mapping
|
quant_config.update_packed_modules_mapping(self.packed_modules_mapping)
|
||||||
|
|
||||||
self.pp_group = get_pp_group()
|
self.pp_group = get_pp_group()
|
||||||
self.config = config
|
self.config = config
|
||||||
|
|||||||
Reference in New Issue
Block a user