Skip to content

Speed up named data map + add uint32 support#17257

Merged
meta-codesync[bot] merged 1 commit intopytorch:mainfrom
metascroy:export-D92447071
Feb 7, 2026
Merged

Speed up named data map + add uint32 support#17257
meta-codesync[bot] merged 1 commit intopytorch:mainfrom
metascroy:export-D92447071

Conversation

@metascroy
Copy link
Contributor

Summary:
his diff significantly speeds up named data map insertion by switching from bytes(tensor.untyped_storage()) to tensor.numpy().tobytes() for converting tensors to bytes. The new _tensor_to_bytes() helper function provides a much faster conversion path, which should noticeably improve XNNPACK and Vulkan lowering times since these backends heavily use the named data store during serialization.

Additionally, this diff adds torch.uint32 to the ScalarType mapping, enabling support for unsigned 32-bit integer tensors in ExecuTorch.

Changes:
_named_data_store.py: Added _tensor_to_bytes() helper that uses numpy().tobytes() for fast tensor-to-bytes conversion, with special handling for bfloat16 (which numpy doesn't support natively)
tensor.py: Added torch.uint32 → ScalarType.UINT32 mapping

Differential Revision: D92447071

@pytorch-bot
Copy link

pytorch-bot bot commented Feb 5, 2026

🔗 Helpful Links

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

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

❌ 6 New Failures, 2 Pending, 2 Unrelated Failures

As of commit 4211221 with merge base fdb386c (image):

NEW FAILURES - The following jobs have failed:

BROKEN TRUNK - The following jobs failed but were present on the merge base:

👉 Rebase onto the `viable/strict` branch to avoid these failures

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

@meta-codesync
Copy link
Contributor

meta-codesync bot commented Feb 5, 2026

@metascroy has exported this pull request. If you are a Meta employee, you can view the originating Diff in D92447071.

@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 Feb 5, 2026
@github-actions
Copy link

github-actions bot commented Feb 5, 2026

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.

Copy link
Member

@GregoryComer GregoryComer left a comment

Choose a reason for hiding this comment

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

Nice find.

metascroy added a commit to metascroy/executorch that referenced this pull request Feb 6, 2026
Summary:

his diff significantly speeds up named data map insertion by switching from bytes(tensor.untyped_storage()) to tensor.numpy().tobytes() for converting tensors to bytes. The new _tensor_to_bytes() helper function provides a much faster conversion path, which should noticeably improve XNNPACK and Vulkan lowering times since these backends heavily use the named data store during serialization.

Additionally, this diff adds torch.uint32 to the ScalarType mapping, enabling support for unsigned 32-bit integer tensors in ExecuTorch.

Changes:
_named_data_store.py: Added _tensor_to_bytes() helper that uses numpy().tobytes() for fast tensor-to-bytes conversion, with special handling for bfloat16 (which numpy doesn't support natively)
tensor.py: Added torch.uint32 → ScalarType.UINT32 mapping

Reviewed By: GregoryComer

Differential Revision: D92447071
Summary:

his diff significantly speeds up named data map insertion by switching from bytes(tensor.untyped_storage()) to tensor.numpy().tobytes() for converting tensors to bytes. The new _tensor_to_bytes() helper function provides a much faster conversion path, which should noticeably improve XNNPACK and Vulkan lowering times since these backends heavily use the named data store during serialization.

Additionally, this diff adds torch.uint32 to the ScalarType mapping, enabling support for unsigned 32-bit integer tensors in ExecuTorch.

Changes:
_named_data_store.py: Added _tensor_to_bytes() helper that uses numpy().tobytes() for fast tensor-to-bytes conversion, with special handling for bfloat16 (which numpy doesn't support natively)
tensor.py: Added torch.uint32 → ScalarType.UINT32 mapping

Reviewed By: GregoryComer

Differential Revision: D92447071
@meta-codesync meta-codesync bot merged commit f655c51 into pytorch:main Feb 7, 2026
301 of 310 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ciflow/trunk CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. fb-exported meta-exported

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants