Skip to content

Commit

Permalink
"#35049 fix path for num_shard 1"
Browse files Browse the repository at this point in the history
  • Loading branch information
strangiato committed Dec 5, 2024
1 parent 3129967 commit 8208593
Showing 1 changed file with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,11 @@ def write_model(

print(f"Fetching all parameters from the checkpoint at {input_base_path}...")
if num_shards == 1:
loaded = [torch.load(os.path.join(input_base_path, "consolidated.pth"), map_location="cpu", mmap=True)]
if os.path.exists(os.path.join(input_base_path, "consolidated.00.pth")):
path = os.path.join(input_base_path, "consolidated.00.pth")
else:
path = os.path.join(input_base_path, "consolidated.pth")
loaded = [torch.load(path, map_location="cpu", mmap=True)]
else:
loaded = [
torch.load(os.path.join(input_base_path, f"consolidated.{i:02d}.pth"), map_location="cpu", mmap=True)
Expand Down

0 comments on commit 8208593

Please sign in to comment.