Skip to content

Fix Vulkan subgroup size control crash by targeting Vulkan 1.3 core#20897

Open
SS-JIA wants to merge 1 commit into
mainfrom
fix-vulkan-subgroup-target-1_3
Open

Fix Vulkan subgroup size control crash by targeting Vulkan 1.3 core#20897
SS-JIA wants to merge 1 commit into
mainfrom
fix-vulkan-subgroup-target-1_3

Conversation

@SS-JIA

@SS-JIA SS-JIA commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes a native Vulkan compute pipeline creation crash (-3 VK_ERROR_INITIALIZATION_FAILED) on Android 16 (API 36) drivers.

VK_EXT_subgroup_size_control was promoted to core in Vulkan 1.3, so those drivers no longer advertise it as a separate device extension. ExecuTorch requested a Vulkan 1.1 instance, where the feature is neither core nor available as an extension — yet the physical device still reports it as supported via vkGetPhysicalDeviceFeatures2. Chaining VkPhysicalDeviceSubgroupSizeControlFeaturesEXT into VkDeviceCreateInfo.pNext without a valid enable route is invalid usage and crashes device/pipeline creation.

This is a fuller fix than simply disabling the feature (cf. #20762): it keeps subgroup size control working on modern devices by using the core route.

Approach

  • Raise the requested instance apiVersion to Vulkan 1.3, capped at the loader-supported version and falling back to 1.1 on loaders that predate vkEnumerateInstanceVersion (select_instance_api_version() in Device.cpp). This never fails on a 1.1+ loader and does not drop older devices — the instance version is a ceiling, not a floor.
  • Gate subgroup size control per device in create_logical_device: enable it only when the extension is enabled, or when both the instance and the physical device are at 1.3+. Otherwise clear the related capability flags so downstream shader dispatch does not request an unsupported subgroup size.
  • Drop the const_cast (take a mutable PhysicalDevice&) and add the missing #include <cstring>.

The pipeline code and feature-detection code need no changes: the ...EXT structs/enums they already use are aliases of the core Vulkan 1.3 types.

Suggested review order

  1. Device.cpp / Device.h — the loader-safe select_instance_api_version() helper.
  2. Runtime.cpp — instance apiVersion now uses that helper.
  3. Adapter.cpp — per-device extension-or-core gating in create_logical_device.

Test Plan

  • Export and run a Vulkan-delegated model on an Android 16 (API 36) device; confirm compute pipelines create successfully and subgroup size control is used via the core path.
  • Verify on a Vulkan 1.1 device that the feature falls back cleanly without crashing.

Fixes #11754.

Authored with Claude.

🤖 Generated with Claude Code

cc @manuelcandales @digantdesai @cbilgin

Summary:

Fixes a native Vulkan compute pipeline creation crash
(-3 VK_ERROR_INITIALIZATION_FAILED) on Android 16 (API 36) drivers.
VK_EXT_subgroup_size_control was promoted to core in Vulkan 1.3, so those
drivers no longer advertise it as a separate device extension. ExecuTorch
targeted a Vulkan 1.1 instance, where the feature is neither core nor
available as an extension, yet the physical device still reported it as
supported. Chaining VkPhysicalDeviceSubgroupSizeControlFeaturesEXT into
VkDeviceCreateInfo.pNext without a valid enable route is invalid usage and
crashes device/pipeline creation.

This raises the requested instance apiVersion to Vulkan 1.3 (capped at the
loader-supported version, falling back to 1.1) so the feature can be used via
the core path, and gates subgroup size control per device: it is enabled only
when the extension is enabled, or when both the instance and the physical
device are at 1.3+. Otherwise the related capability flags are cleared so
downstream shader dispatch does not request an unsupported subgroup size.

On Android 16 devices this restores subgroup size control via the core route
rather than disabling it.

Authored with Claude.

Fixes #11754.

Test Plan:

Export and run a Vulkan-delegated model on an Android 16 (API 36) device and
confirm compute pipelines create successfully. Also verify on a Vulkan 1.1
device that the feature falls back cleanly without crashing.

Reviewers:

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@pytorch-bot pytorch-bot Bot added the module: vulkan Issues related to the Vulkan delegate and code under backends/vulkan/ label Jul 13, 2026
@pytorch-bot

pytorch-bot Bot commented Jul 13, 2026

Copy link
Copy Markdown

🔗 Helpful Links

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

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 13, 2026
@meta-codesync

meta-codesync Bot commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

@SS-JIA has imported this pull request. If you are a Meta employee, you can view this in D111804927.

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.

Android native crash when running DeepLabV3Demo with vulkan backend in Android 16

1 participant