Skip to content

[ET-VK] Replace dynamic UBO indexing with safe_idx across shaders#18515

Merged
SS-JIA merged 1 commit intogh/SS-JIA/510/origfrom
gh/SS-JIA/511/orig
Mar 26, 2026
Merged

[ET-VK] Replace dynamic UBO indexing with safe_idx across shaders#18515
SS-JIA merged 1 commit intogh/SS-JIA/510/origfrom
gh/SS-JIA/511/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: #18512 by @SS-JIA
^ 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/SS-JIA/511/base
ghstack PR head: https://github.com/pytorch/executorch/tree/gh/SS-JIA/511/head
Merge bot PR base: https://github.com/pytorch/executorch/tree/gh/SS-JIA/510/orig
Merge bot PR head: https://github.com/pytorch/executorch/tree/gh/SS-JIA/511/orig
Differential Revision: D98220450
@diff-train-skip-merge

The Adreno 740 GPU driver crashes (SIGSEGV in vkCreateComputePipelines)
when GLSL shaders dynamically index a UBO-backed ivec4/ivec3 with a
specialization-constant-derived value. This was causing the skin
segmentation model to crash during pipeline creation on Samsung S23.

Fix all instances across 18 shader files by replacing patterns like
`meta.sizes[packed_dim]` with `safe_idx(meta.sizes, packed_dim)`, which
uses an if/else chain that the driver resolves at pipeline creation time.

Changes:
- Add safe_idx(ivec3) overload to indexing.glslh
- Fix transfer_texture.glsl, slice.glslh, select.glslh (transfer ops)
- Fix nchw_to_int8x4_buffer.glsl, full_texture.glsl (staging/utility)
- Fix gather, split, index_tensor, where, expand, pad, repeat, arange
  texture shaders (1-line fixes each)
- Fix softmax.glsl, reduce.glsl, reduce2d.glsl, var_texture3d.glsl
  (reduction shaders with multiple fixes + added indexing.glslh include)
- Remove unused ShaderNameUtils.h include from Slice.cpp

Differential Revision: [D98220450](https://our.internmc.facebook.com/intern/diff/D98220450/)

ghstack-source-id: 357844383
Pull Request resolved: #18512
@pytorchbot pytorchbot requested a review from SS-JIA as a code owner March 26, 2026 02:56
@pytorch-bot
Copy link
Copy Markdown

pytorch-bot bot commented Mar 26, 2026

🔗 Helpful Links

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

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 Mar 26, 2026
@SS-JIA SS-JIA merged commit de83a9f into gh/SS-JIA/510/orig Mar 26, 2026
149 of 159 checks passed
@SS-JIA SS-JIA deleted the gh/SS-JIA/511/orig branch March 26, 2026 03:00
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