Skip to content

Conversation

metascroy
Copy link
Contributor

No description provided.

Copy link

pytorch-bot bot commented Sep 5, 2025

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/13984

Note: Links to docs will display an error until the docs builds have been completed.

❌ 1 New Failure

As of commit 11ca5b3 with merge base 76a8906 (image):

NEW FAILURE - The following job has failed:

This comment was automatically generated by Dr. CI and updates every 15 minutes.

@meta-cla meta-cla bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Sep 5, 2025
Copy link

github-actions bot commented Sep 5, 2025

This PR needs a release notes: label

If your change should be included in the release notes (i.e. would users of this library care about this change?), please use a label starting with release notes:. This helps us keep track and include your important work in the next release notes.

To add a label, you can comment to pytorchbot, for example
@pytorchbot label "release notes: none"

For more information, see
https://github.com/pytorch/pytorch/wiki/PyTorch-AutoLabel-Bot#why-categorize-for-release-notes-and-how-does-it-work.

Comment on lines 111 to 143
index_path = os.path.join(input_dir, "pytorch_model.bin.index.json")
if os.path.exists(index_path):
# Sharded checkpoint.
with open(index_path, "r") as f:
index = json.load(f)
weight_map = index["weight_map"]
checkpoint_shards = sorted(set(weight_map.values()))

# Load all the shards into memory
shard_to_weights = {}
for shard in checkpoint_shards:
shard_to_weights[shard] = torch.load(
os.path.join(input_dir, shard),
weights_only=True,
map_location=torch.device("cpu"),
)

# Merge tensors into consolidated state dict.
merged_state_dict = {}
for weight_name, shard in weight_map.items():
tensor = shard_to_weights[shard][weight_name]
merged_state_dict[weight_name] = tensor
return merged_state_dict

# Single checkpoint
model_path = os.path.join(input_dir, "pytorch_model.bin")
if os.path.exists(model_path):
state_dict = torch.load(
model_path, weights_only=True, map_location=torch.device("cpu")
)
return state_dict

raise FileNotFoundError(f"Could not find pytorch_model checkpoint in {input_dir}")
Copy link
Contributor

Choose a reason for hiding this comment

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

should you make this a utilty function to deduplicate logic?

@metascroy metascroy merged commit 61b0070 into main Sep 8, 2025
115 of 116 checks passed
@metascroy metascroy deleted the support-pytorch-bin branch September 8, 2025 16:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants