|
22 | 22 | from paddleformers.utils.log import logger |
23 | 23 |
|
24 | 24 | from fastdeploy import envs |
| 25 | +from fastdeploy.model_executor.layers.backends.gcu.moe.fused_moe_method_gcu_backend import ( |
| 26 | + GCUWeightOnlyMoEMethod, |
| 27 | +) |
25 | 28 | from fastdeploy.model_executor.layers.utils import get_tensor |
26 | 29 | from fastdeploy.model_executor.utils import slice_fn |
27 | 30 | from fastdeploy.platforms import current_platform |
@@ -151,9 +154,10 @@ def __init__( |
151 | 154 | self.gate_correction_bias = gate_correction_bias |
152 | 155 | else: |
153 | 156 | self.gate_correction_bias = None |
154 | | - self.quant_method.create_weights( |
155 | | - self, weight_loader=self.weight_loader, model_format=fd_config.model_config.model_format |
156 | | - ) |
| 157 | + if not isinstance(self.quant_method, GCUWeightOnlyMoEMethod): |
| 158 | + self.quant_method.create_weights( |
| 159 | + self, weight_loader=self.weight_loader, model_format=fd_config.model_config.model_format |
| 160 | + ) |
157 | 161 |
|
158 | 162 | logger.info( |
159 | 163 | f"{moe_tag}MoE config is {num_experts=}[{expert_id_offset}, {expert_id_offset + self.num_local_experts}), \ |
@@ -476,11 +480,17 @@ def load_state_dict(self, state_dict, is_rearrange: bool = False): |
476 | 480 | load_state_dict function. |
477 | 481 | """ |
478 | 482 | if self.fd_config.model_config.is_quantized: |
| 483 | + if isinstance(self.quant_method, GCUWeightOnlyMoEMethod): |
| 484 | + self.quant_method.process_prequanted_weights(self, state_dict) |
| 485 | + return |
479 | 486 | if getattr(self.fd_config.quant_config, "is_permuted", True): |
480 | 487 | self.quant_method.process_prequanted_weights(self, state_dict, is_rearrange) |
481 | 488 | else: |
482 | 489 | self.quant_method.process_loaded_weights(self, state_dict) |
483 | 490 | else: |
| 491 | + if isinstance(self.quant_method, GCUWeightOnlyMoEMethod): |
| 492 | + self.quant_method.create_weights(self, state_dict) |
| 493 | + return |
484 | 494 | self.quant_method.process_loaded_weights(self, state_dict) |
485 | 495 |
|
486 | 496 | def forward(self, x: paddle.Tensor, gate: nn.Layer): |
|
0 commit comments