Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions mindone/transformers/modeling_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -3057,7 +3057,7 @@ def _find_mismatched_keys(
if state_dict is not None:
# Whole checkpoint
# checkpoint mapping from pt to hf
matching = [s for s in key_renaming_mapping.keys() if "LayerNorm.gamma" in s]
matching = key_renaming_mapping.keys()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里是为什么去掉了 layernorm.gamma 的判断,是之前写多了吗?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

目前这个判断会导致qwen25vl 权重读取失败。去掉这个判断可以正确读取权重,具体修复待 @wcrzlh 分析

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

此修改会造成其他模型加载权重有问题,需进一步验证才能合入。

if matching:
# Fix the key names when model weight names contain LayerNorm.gamma/LayerNorm.beta
state_dict = {key_renaming_mapping[k]: v for k, v in state_dict.items() if k in key_renaming_mapping}
Expand Down Expand Up @@ -3090,7 +3090,7 @@ def _find_mismatched_keys(
for shard_file in resolved_archive_file:
state_dict = load_state_dict(shard_file)
# checkpoint mapping from pt to hf
matching = [s for s in key_renaming_mapping.keys() if "LayerNorm.gamma" in s]
matching = key_renaming_mapping.keys()
if matching:
# Fix the key names when model weight names contain LayerNorm.gamma/LayerNorm.beta
state_dict = {
Expand Down
Loading