Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update ckpt conversion flow to use the new sharded ckpt path structure #332

Merged
merged 1 commit into from
Nov 21, 2023
Merged
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: 1 addition & 3 deletions optimum/neuron/distributed/checkpointing.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,11 @@ def consolidate_tensor_parallel_checkpoints(checkpoint_dir: Union[str, Path]) ->

state_dicts = []

for sharded_checkpoint in checkpoint_dir.glob("tp_rank_*"):
for sharded_checkpoint in sorted(checkpoint_dir.glob("tp_rank_*/checkpoint.pt")):
Copy link
Member

Choose a reason for hiding this comment

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

This will only work for TP right?
It will need to be updated for TP + PP. That's not an issue, just checking.

if not sharded_checkpoint.is_file():
continue
state_dicts.append(torch.load(sharded_checkpoint))

state_dicts = sorted(state_dicts, key=lambda d: d["tp_rank"])

parameter_names = state_dicts[0]["model"].keys()
sharded_metadatas = {
name: [
Expand Down
Loading