OpenMOSS / OpenMOSS/MOSS

使用jittor加载模型的时候这个文件pytorch_model.bin.index.json是如何生成的?

Open
#348 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
12.3k
Forks
1.1k
PR merge metrics
No merged PRs in 30d

Description

def load_from_torch_shard_ckpt(model, ckpt_dir):
"""
Load sharded checkpoints directly from huggingface dir.
"""
with open(os.path.join(ckpt_dir, 'pytorch_model.bin.index.json')) as fp:
ckpt_index = json.load(fp)

total_size = ckpt_index['metadata']['total_size']
weight_map = ckpt_index['weight_map']

file_weight_map = {}
for key, value in weight_map.items():
    # key: param name; value: filename.
    if value not in file_weight_map:
        file_weight_map[value] = []
    file_weight_map[value].append(key)

load_from_map(model, ckpt_dir, file_weight_map)

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the load_from_torch_shard_ckpt function shown in the issue and trace how ckpt_dir is prepared before it is called. Determine which process creates pytorch_model.bin.index.json and how its metadata and weight_map relate to the shard files. Done means documenting that generation path clearly, including the relevant command or loading workflow if the repository contains one.

Written by the indexing model from the issue text.

Assessment

Tech stack
huggingface, python
Domain
machine-learning
Issue type
Documentation
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.