Safetensors
qwen2

Fix missing `metadata` in `model.safetensors.index.json`

#1
by Zihao-Li - opened

Description:

This PR fixes the missing "metadata.total_size" field in model.safetensors.index.json, which was causing a KeyError: 'metadata' when loading the model with transformers.

Reproduction:

from transformers import AutoTokenizer, AutoModelForCausalLM
model = AutoModelForCausalLM.from_pretrained("AIDC-AI/Marco-LLM-GLO")

Error:

---------------------------------------------------------------------------
KeyError                                  Traceback (most recent call last)
<ipython-input-2-73061392afe9> in <cell line: 0>()
----> 1 model = AutoModelForCausalLM.from_pretrained("AIDC-AI/Marco-LLM-GLO")

2 frames
/usr/local/lib/python3.11/dist-packages/transformers/utils/hub.py in get_checkpoint_shard_files(pretrained_model_name_or_path, index_filename, cache_dir, force_download, proxies, resume_download, local_files_only, token, user_agent, revision, subfolder, _commit_hash, **deprecated_kwargs)
   1076 
   1077     shard_filenames = sorted(set(index["weight_map"].values()))
-> 1078     sharded_metadata = index["metadata"]
   1079     sharded_metadata["all_checkpoint_keys"] = list(index["weight_map"].keys())
   1080     sharded_metadata["weight_map"] = index["weight_map"].copy()

KeyError: 'metadata'

Changes Made:

  • Added "metadata": { "total_size": 15231271760 } to model.safetensors.index.json
Ready to merge
This branch is ready to get merged automatically.
Your need to confirm your account before you can post a new comment.

Sign up or log in to comment