(model_sublayer_name: str, param=None)
| 161 | """ |
| 162 | |
| 163 | def fn(model_sublayer_name: str, param=None): |
| 164 | from fastdeploy.model_executor.layers.linear import ( |
| 165 | KVBatchLinear, |
| 166 | UnquantizedLinearMethod, |
| 167 | ) |
| 168 | from fastdeploy.model_executor.layers.moe.moe import get_moe_method |
| 169 | |
| 170 | if model_sublayer_name not in sublayers_dict: |
| 171 | return |
| 172 | model_sublayer = sublayers_dict[model_sublayer_name] |
| 173 | if isinstance(model_sublayer, KVBatchLinear): |
| 174 | model_sublayer.process_weights_after_loading() |
| 175 | if fd_config.quant_config and not fd_config.quant_config.is_checkpoint_bf16: |
| 176 | # skip for offline quantization |
| 177 | return |
| 178 | if hasattr(model_sublayer, "quant_method"): |
| 179 | quant_method = getattr(model_sublayer, "quant_method", None) |
| 180 | unquant_moe_layer = get_moe_method() |
| 181 | if unquant_moe_layer is None: |
| 182 | unquant_moe_cls = object |
| 183 | else: |
| 184 | unquant_moe_cls = type(unquant_moe_layer) |
| 185 | if type(quant_method) is UnquantizedLinearMethod or type(quant_method) is unquant_moe_cls: |
| 186 | # skip unquantized linear |
| 187 | return |
| 188 | if not hasattr(quant_method, "process_weights_after_loading"): |
| 189 | return |
| 190 | if param is not None and hasattr(param, "tensor_track") and param.tensor_track is None: |
| 191 | return |
| 192 | if param is not None and hasattr(param, "tensor_track") and not param.tensor_track.is_fully_copied(): |
| 193 | return |
| 194 | quant_method.process_weights_after_loading(model_sublayer) |
| 195 | |
| 196 | return fn |
| 197 |
no test coverage detected