Skip to content

Vulkan: add the missing int32 -> uint8 view_convert variant - #22321

Open
msluszniak wants to merge 1 commit into
pytorch:mainfrom
msluszniak:ms/vulkan-int32-uint8-shader
Open

Vulkan: add the missing int32 -> uint8 view_convert variant#22321
msluszniak wants to merge 1 commit into
pytorch:mainfrom
msluszniak:ms/vulkan-int32-uint8-shader

Conversation

@msluszniak

@msluszniak msluszniak commented Aug 30, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes #22320.

The view_convert combo lists generate uint8 -> int32 but not the reverse, so a graph containing an int32 -> uint8 view_convert lowers cleanly through VulkanPartitioner and then aborts on device:

Could not find ShaderInfo with name view_convert_buffer_int32_uint8
(ShaderRegistry.cpp:54, (it != listings_.end()) is false)

The partitioner has no visibility into which dtype pairs were generated, so the node is accepted at AOT and the failure only appears at run time. sentence-transformers/all-MiniLM-L6-v2 hits this through its attention mask on any graph lowered with VulkanPartitioner.

view_convert is a plain elementwise OUT_T(t_inp[...]) cast, so the pair needs nothing beyond being listed in the buffer and texture variant lists.

Test plan

On a Galaxy S26 Ultra (Adreno 840), arm64-v8a, NDK 27.1, main @ c27baa8:

Before, executor_runner aborts loading the model with the error above. After, all-MiniLM-L6-v2 loads and runs, and its embedding matches the eager reference:

minilm  vulkan vs torch ref   max|dev| 4.0e-04   cosine 0.99999726
minilm  replay 0 vs replay 29 max|dev| 0.0       cosine 1.00000000

Bit-identical across 90 in-process replays (3 rounds x 30 executions), so the added cast is stable as well as correct. Median 7.76 ms/iteration against 8.38 ms for the same model on XNNPACK.

cc @SS-JIA @manuelcandales @digantdesai @cbilgin

The view_convert combo lists generate uint8 -> int32 but not the reverse,
so a graph containing an int32 -> uint8 view_convert lowers cleanly and
then aborts at run time:

  Could not find ShaderInfo with name view_convert_buffer_int32_uint8
  (ShaderRegistry.cpp:54, (it != listings_.end()) is false)

The partitioner has no visibility into which dtype pairs were generated,
so this surfaces as a crash on device rather than the node being left on
host. sentence-transformers/all-MiniLM-L6-v2 hits it through its
attention mask on any graph lowered with VulkanPartitioner.

view_convert is a plain elementwise OUT_T(in) cast, so the pair needs
nothing beyond being listed. Verified on a Galaxy S26 Ultra (Adreno 840):
with this variant generated, all-MiniLM-L6-v2 runs and its embedding
matches the eager reference to cosine 0.99999726 (max abs deviation
4.0e-04), bit-identical across 90 in-process replays.
@msluszniak
msluszniak requested a review from SS-JIA as a code owner August 30, 2026 08:21
@pytorch-bot pytorch-bot Bot added the module: vulkan Issues related to the Vulkan delegate and code under backends/vulkan/ label Aug 30, 2026
@pytorch-bot

pytorch-bot Bot commented Aug 30, 2026

Copy link
Copy Markdown

🔗 Helpful Links

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

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

⚠️ 15 Awaiting Approval

As of commit add7363 with merge base c27baa8 (image):

AWAITING APPROVAL - The following workflows need approval before CI can run:

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 Aug 30, 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.

msluszniak added a commit to software-mansion-labs/executorch that referenced this pull request Aug 30, 2026
The combo lists carried [uint8, int32] but not the reverse, so a graph
needing an int32 to uint8 view lowered cleanly and then aborted at
runtime with "Could not find ShaderInfo with name
view_convert_buffer_int32_uint8". all-MiniLM-L6-v2 hits this through its
attention mask.

Backport of upstream pytorch/executorch#22321.
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.

[Vulkan] Missing int32 -> uint8 view_convert variant: lowers cleanly, aborts at run time

2 participants