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

Method load_weight

fastdeploy/model_executor/layers/linear.py:211–226  ·  view source on GitHub ↗

Load the weight from the state dictionary. Args: state_dict (dict): A dictionary containing the weights

(self, state_dict: dict)

Source from the content-addressed store, hash-verified

209 self.quant_method.process_prequanted_weights(self, state_dict)
210
211 def load_weight(self, state_dict: dict):
212 """
213 Load the weight from the state dictionary.
214
215 Args:
216 state_dict (dict): A dictionary containing the weights
217 """
218 if "qkv_a_proj_with_mqa" in self.weight_key:
219 self.weight_key_q = self.weight_key.replace("qkv_a_proj_with_mqa", "q_a_proj")
220 self.weight_key_kv = self.weight_key.replace("qkv_a_proj_with_mqa", "kv_a_proj_with_mqa")
221 q_weight_tensor = get_tensor(state_dict.pop(self.weight_key_q))
222 kv_weight_tensor = get_tensor(state_dict.pop(self.weight_key_kv))
223 weight_tensor = paddle.concat([q_weight_tensor, kv_weight_tensor], axis=-1)
224 else:
225 weight_tensor = get_tensor(state_dict.pop(self.weight_key))
226 self.quant_method.process_loaded_weights(self, weight_tensor)
227
228 def load_state_dict(self, state_dict: dict):
229 """

Callers 2

load_prequant_weightMethod · 0.95
load_state_dictMethod · 0.95

Calls 3

get_tensorFunction · 0.85
popMethod · 0.80

Tested by

no test coverage detected