Vulkan: fix embedding_texture for non width-packed outputs - #22827
Open
msluszniak wants to merge 1 commit into
Open
msluszniak wants to merge 1 commit into
msluszniak wants to merge 1 commit into
Conversation
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/22827
Note: Links to docs will display an error until the docs builds have been completed. ❌ 1 New FailureAs of commit efafdef with merge base 161fbd5 ( NEW FAILURE - The following job has failed:
This comment was automatically generated by Dr. CI and updates every 15 minutes. |
Contributor
Author
|
@pytorchbot label "module: vulkan" |
Contributor
Author
|
@pytorchbot label "release notes: vulkan" |
msluszniak
added a commit
to software-mansion-labs/executorch
that referenced
this pull request
Sep 15, 2026
Backport of pytorch/executorch#22827, which fixes #22333. Above 16384 weight rows the memory layout pass picks a height-packed texture, where each texel holds 4 different weight rows rather than 4 elements of one row, and the shader returned the first row shifted. CLIP text at force_fp16 went cos 0.0625 -> 0.9999994.
embedding_texture.glsl assumed the output texel always packs along the embedding dim: it looked up one index per texel and then read 4 consecutive weight elements. When the output is height packed, which the memory layout pass picks once the weight has more than 16384 rows, each texel holds 4 different rows instead, so every group of 4 output rows got the first row's data shifted by one element. Branch on the output's packed dim and load each component from its own weight row when the packed dim is not the embedding dim. Fixes pytorch#22333. (cherry picked from commit 2e5b071)
msluszniak
force-pushed
the
ms/vulkan-embedding-texture-packed-dim
branch
from
September 17, 2026 15:35
2e5b071 to
efafdef
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
embedding_texture.glslassumed the output texel always packs along the embedding dim: it looked up one index per texel, then read 4 consecutive weight elements. When the output is height packed, which the memory layout pass picks once the weight has more than 16384 rows, each texel holds 4 different rows instead, so every group of 4 output rows got the first row's data shifted by one element.Branch on the output's packed dim and load each component from its own weight row when the packed dim is not the embedding dim.
Fixes #22333.
nn.Embedding(16385, 4), ids[[0, 1, 16384], [7, 16000, 12345]], Mali-G76, before:After: bit-exact against eager. CLIP text encoder at
force_fp16(vocab 49408) goes from cos 0.0625 to 0.9999995. Width-packed outputs are byte-identical before and after.cc @SS-JIA @manuelcandales @digantdesai @cbilgin