Skip to content

[executorch][vulkan] Add payload-bounded constant sharding - #21467

Merged
JCNTH merged 5 commits into
mainfrom
gh/JCNTH/194/orig
Jul 29, 2026
Merged

[executorch][vulkan] Add payload-bounded constant sharding#21467
JCNTH merged 5 commits into
mainfrom
gh/JCNTH/194/orig

Conversation

@pytorchbot

@pytorchbot pytorchbot commented Jul 29, 2026

Copy link
Copy Markdown
Collaborator

This PR was created by the merge bot to help merge the original PR into the main branch.
ghstack PR number: #21404 by @JCNTH
^ Please use this as the source of truth for the PR details, comments, and reviews
ghstack PR base: https://github.com/pytorch/executorch/tree/gh/JCNTH/194/base
ghstack PR head: https://github.com/pytorch/executorch/tree/gh/JCNTH/194/head
Merge bot PR base: https://github.com/pytorch/executorch/tree/main
Merge bot PR head: https://github.com/pytorch/executorch/tree/gh/JCNTH/194/orig

@diff-train-skip-merge

cc @SS-JIA @manuelcandales @digantdesai @cbilgin

Pull Request resolved: #21404

**Enable deterministic payload-bounded Vulkan constant sharding**

**Problem**
Large Vulkan exports can make inline PTE named data exceed downstream artifact limits, but `NamedDataStore` cannot externalize that data into bounded groups.

**Solution**
- **Before:** Vulkan constants remain inline with no payload-bounded externalization option.
- **After:** an opt-in `uint64` raw-data cap externalizes constants after graph construction into deterministic shards.

**Implementation**
- `NamedDataStore.externalize_pte_data` groups aliases by backing buffer, preserves existing tags, and rejects oversize buffers or collisions atomically.
- `parse_compile_options` and `parse_compile_spec` transport `external_constants_max_data_bytes` as a strict positive `uint64`.
- `VulkanBackend.preprocess` applies sharding only when the option is present.

**Constraints**
The default path is unchanged; buffers are not copied or split. The cap bounds unique raw buffer bytes per external tag, not final `FlatTensor` file size including alignment and header overhead.

Co-authored-with: Claude Code.
ghstack-source-id: 407350478
@exported-using-ghexport

Differential Revision: [D113608555](https://our.internmc.facebook.com/intern/diff/D113608555/)
@pytorch-bot pytorch-bot Bot added the module: vulkan Issues related to the Vulkan delegate and code under backends/vulkan/ label Jul 29, 2026
@pytorch-bot

pytorch-bot Bot commented Jul 29, 2026

Copy link
Copy Markdown

🔗 Helpful Links

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

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

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 Jul 29, 2026
@github-actions

Copy link
Copy Markdown

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.

JCNTH added 2 commits July 29, 2026 10:47
Pull Request resolved: #21405

**Dynamic Q4 embedding reuse now preserves the complete packing configuration.**

A resize used to rebuild the uniform field by field, which dropped `is_linear_weight`. The resize hook now captures the fully initialized `EmbeddingParams` and rewrites only `num_indices` and `total_blocks`.

Key changes:
- `EmbeddingQ4gsw.cpp` — pass a 32-byte base parameter struct by value through the resize callback.
- Resize recomputation updates only dynamic counts, so current and future invariant fields are preserved by construction.
- Mirrors Vulkan `EmbeddingQ4gsw.cpp`, which retains `is_linear_weight` in push-constant state across resize.

Static and nonlinear embedding behavior is unchanged.

Co-authored-with: Claude Code.
ghstack-source-id: 407350572
@exported-using-ghexport

Differential Revision: [D113627870](https://our.internmc.facebook.com/intern/diff/D113627870/)
Pull Request resolved: #21406

**Dynamic-shape coverage now locks linear-packed Q4 embedding reuse.**

The fixture exports a discriminating linear-packed model and reuses one loaded graph across N=16,8,1,16, covering the resize transition that previously reset nibble order.

Key changes:
- `test_dynamic_shape_export.py` — export deterministic true-packing artifacts and torch goldens for N=16,8,1.
- `test_dynamic_shape.cpp` — add one-graph linear-packed reuse coverage while preserving the nonlinear control.

The explicit true-vs-false output guard prevents a non-discriminating fixture.

Co-authored-with: Claude Code.
ghstack-source-id: 407350695
@exported-using-ghexport

Differential Revision: [D113627869](https://our.internmc.facebook.com/intern/diff/D113627869/)
Copilot finished work on behalf of JCNTH July 29, 2026 18:58
Copilot AI requested a review from JCNTH July 29, 2026 18:58

@JCNTH JCNTH left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Revert changes

@JCNTH
JCNTH merged commit 22778f7 into main Jul 29, 2026
188 of 189 checks passed
@JCNTH
JCNTH deleted the gh/JCNTH/194/orig branch July 29, 2026 19: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. module: vulkan Issues related to the Vulkan delegate and code under backends/vulkan/

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants