MCPcopy Create free account
hub / github.com/PaddlePaddle/FastDeploy / fn

Function fn

fastdeploy/model_executor/utils.py:163–194  ·  view source on GitHub ↗
(model_sublayer_name: str, param=None)

Source from the content-addressed store, hash-verified

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

Callers 1

inflight_taskMethod · 0.50

Calls 11

get_moe_methodFunction · 0.90
get_tensorFunction · 0.90
_can_skipFunction · 0.85
slice_fnFunction · 0.85
fd_castFunction · 0.85
is_fully_copiedMethod · 0.80
transposeMethod · 0.80
get_shapeMethod · 0.80
itemsMethod · 0.80
applyMethod · 0.45

Tested by

no test coverage detected