Skip to content

Commit

Permalink
quick fix from pretrained. (#8486)
Browse files Browse the repository at this point in the history
  • Loading branch information
ZHUI committed May 27, 2024
1 parent d8e1a6b commit 773497e
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions paddlenlp/transformers/model_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -797,7 +797,7 @@ def _load_state_dict_into_meta_model(

dtype = convert_np_dtype_to_dtype_(dtype)
error_msgs = []

model_state_dict = model.state_dict()
for param_name, param in state_dict.items():
# First part of the test is always true as loaded_state_dict_keys always contains state_dict keys.
if param_name not in loaded_state_dict_keys or param_name not in expected_keys:
Expand Down Expand Up @@ -832,7 +832,7 @@ def _load_state_dict_into_meta_model(
if old_param is not None:
param = param.astype(dtype=old_param.dtype)
with paddle.no_grad():
model.state_dict()[param_name].get_tensor()._share_data_with(param.value().get_tensor())
model_state_dict[param_name].get_tensor()._share_data_with(param.value().get_tensor())
param.value().get_tensor()._clear()
return error_msgs

Expand Down Expand Up @@ -1918,7 +1918,7 @@ def _fuse_or_split_keys(
if (
shard_file.endswith(".safetensors")
and config.tensor_parallel_degree > 1
and "tp" not in shard_file
and "tp" not in os.path.spilt(shard_file)[-1]
):
pre_tensor_parallel_split = True
assert loaded_keys is not None, "loaded_keys is not None."
Expand Down

0 comments on commit 773497e

Please sign in to comment.