Skip to content

[executorch][webgpu] Preserve embedding packing on resize - #21468

Merged
JCNTH merged 2 commits into
gh/JCNTH/194/origfrom
gh/JCNTH/195/orig
Jul 29, 2026
Merged

[executorch][webgpu] Preserve embedding packing on resize#21468
JCNTH merged 2 commits into
gh/JCNTH/194/origfrom
gh/JCNTH/195/orig

Conversation

@pytorchbot

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: #21405 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/195/base
ghstack PR head: https://github.com/pytorch/executorch/tree/gh/JCNTH/195/head
Merge bot PR base: https://github.com/pytorch/executorch/tree/gh/JCNTH/194/orig
Merge bot PR head: https://github.com/pytorch/executorch/tree/gh/JCNTH/195/orig

@diff-train-skip-merge

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/)
@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/21468

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
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/)
@JCNTH
JCNTH merged commit 73171de into gh/JCNTH/194/orig Jul 29, 2026
24 of 25 checks passed
@JCNTH
JCNTH deleted the gh/JCNTH/195/orig branch July 29, 2026 17:47
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.

2 participants