Skip to content

Conversation

lucylq
Copy link
Contributor

@lucylq lucylq commented Sep 4, 2025

Stack from ghstack (oldest at bottom):

This diff introduces the PT2ArchiveDataMap, which reads the weights in .pt2 archive files.

  1. Open the archive file with miniz
  2. There are two json config files (weights_config.json, constants_config.json) with information on weight name -> {weight path, weight metadata}. Open and extract weight information into unordered_maps; then free the json blobs.
  3. For get_tensor_layout calls, return the json information.
  4. For get_data calls, use miniz to calculate the offset + size and then use data loader. PT2 archive files are not compressed (to allow mmap-ing), so this is fine.

PT2 archive format: https://docs.google.com/document/d/1xdx3I4zK6naPEWX3e49rCUccZeAC9zMLCFKXvUQFR7o/edit?tab=t.0

Serde: https://docs.google.com/document/d/11X-KsLPMJGdEr4sG4sCNLnGLhSKrc8utDGMQqFbZx9E/edit?tab=t.0#heading=h.tsw6d16xh497


TODO in subsequent diffs

  • convert stride to dim order
  • Additional testing; failure cases, model file with constants as well as weights, model with no weights.
  • CMake for OSS

Differential Revision: D81248896

This diff introduces the PT2ArchiveDataMap, which reads the weights in .pt2 archive files.

1. Open the archive file with miniz
2. There are two json config files (weights_config.json, constants_config.json) with information on weight name -> {weight path, weight metadata}. Open and extract weight information into unordered_maps; then free the json blobs.
3. For get_tensor_layout calls, return the json information.
4. For get_data calls, use miniz to calculate the offset + size and then use data loader. PT2 archive files are not compressed (to allow mmap-ing), so this is fine.

PT2 archive format: https://docs.google.com/document/d/1xdx3I4zK6naPEWX3e49rCUccZeAC9zMLCFKXvUQFR7o/edit?tab=t.0

Serde: https://docs.google.com/document/d/11X-KsLPMJGdEr4sG4sCNLnGLhSKrc8utDGMQqFbZx9E/edit?tab=t.0#heading=h.tsw6d16xh497
---

TODO in subsequent diffs
- convert stride to dim order
- Additional testing; failure cases, model file with constants as well as weights, model with no weights.
- CMake for OSS

Differential Revision: [D81248896](https://our.internmc.facebook.com/intern/diff/D81248896/)

[ghstack-poisoned]
lucylq added a commit that referenced this pull request Sep 4, 2025
This diff introduces the PT2ArchiveDataMap, which reads the weights in .pt2 archive files.

1. Open the archive file with miniz
2. There are two json config files (weights_config.json, constants_config.json) with information on weight name -> {weight path, weight metadata}. Open and extract weight information into unordered_maps; then free the json blobs.
3. For get_tensor_layout calls, return the json information.
4. For get_data calls, use miniz to calculate the offset + size and then use data loader. PT2 archive files are not compressed (to allow mmap-ing), so this is fine.

PT2 archive format: https://docs.google.com/document/d/1xdx3I4zK6naPEWX3e49rCUccZeAC9zMLCFKXvUQFR7o/edit?tab=t.0

Serde: https://docs.google.com/document/d/11X-KsLPMJGdEr4sG4sCNLnGLhSKrc8utDGMQqFbZx9E/edit?tab=t.0#heading=h.tsw6d16xh497
---

TODO in subsequent diffs
- convert stride to dim order
- Additional testing; failure cases, model file with constants as well as weights, model with no weights.
- CMake for OSS

Differential Revision: [D81248896](https://our.internmc.facebook.com/intern/diff/D81248896/)

ghstack-source-id: 307655657
Pull Request resolved: #13973
Copy link

pytorch-bot bot commented Sep 4, 2025

🔗 Helpful Links

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

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

❌ 2 New Failures, 2 Unrelated Failures

As of commit 16600d9 with merge base 151f3be (image):

NEW FAILURES - The following jobs have failed:

FLAKY - The following jobs failed but were likely due to flakiness present on trunk:

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 4, 2025
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D81248896

Copy link

github-actions bot commented Sep 4, 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.

@lucylq lucylq requested a review from JacobSzwejbka September 5, 2025 00:18
This diff introduces the PT2ArchiveDataMap, which reads the weights in .pt2 archive files.

1. Open the archive file with miniz
2. There are two json config files (weights_config.json, constants_config.json) with information on weight name -> {weight path, weight metadata}. Open and extract weight information into unordered_maps; then free the json blobs.
3. For get_tensor_layout calls, return the json information.
4. For get_data calls, use miniz to calculate the offset + size and then use data loader. PT2 archive files are not compressed (to allow mmap-ing), so this is fine.

PT2 archive format: https://docs.google.com/document/d/1xdx3I4zK6naPEWX3e49rCUccZeAC9zMLCFKXvUQFR7o/edit?tab=t.0

Serde: https://docs.google.com/document/d/11X-KsLPMJGdEr4sG4sCNLnGLhSKrc8utDGMQqFbZx9E/edit?tab=t.0#heading=h.tsw6d16xh497


---

TODO in subsequent diffs
- convert stride to dim order
- Additional testing; failure cases, model file with constants as well as weights, model with no weights.
- CMake for OSS

Differential Revision: [D81248896](https://our.internmc.facebook.com/intern/diff/D81248896/)

[ghstack-poisoned]
lucylq added a commit that referenced this pull request Sep 8, 2025
Pull Request resolved: #13973

This diff introduces the PT2ArchiveDataMap, which reads the weights in .pt2 archive files.

1. Open the archive file with miniz
2. There are two json config files (weights_config.json, constants_config.json) with information on weight name -> {weight path, weight metadata}. Open and extract weight information into unordered_maps; then free the json blobs.
3. For get_tensor_layout calls, return the json information.
4. For get_data calls, use miniz to calculate the offset + size and then use data loader. PT2 archive files are not compressed (to allow mmap-ing), so this is fine.

PT2 archive format: https://docs.google.com/document/d/1xdx3I4zK6naPEWX3e49rCUccZeAC9zMLCFKXvUQFR7o/edit?tab=t.0

Serde: https://docs.google.com/document/d/11X-KsLPMJGdEr4sG4sCNLnGLhSKrc8utDGMQqFbZx9E/edit?tab=t.0#heading=h.tsw6d16xh497
---

TODO in subsequent diffs
- convert stride to dim order
- Additional testing; failure cases, model file with constants as well as weights, model with no weights.
- CMake for OSS
ghstack-source-id: 308366584
@exported-using-ghexport

Differential Revision: [D81248896](https://our.internmc.facebook.com/intern/diff/D81248896/)
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D81248896

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. fb-exported
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants