Fix Vulkan subgroup size control crash by targeting Vulkan 1.3 core#20897
Fix Vulkan subgroup size control crash by targeting Vulkan 1.3 core#20897SS-JIA wants to merge 3 commits into
Conversation
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>
🔗 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. ✅ No FailuresAs of commit 24ee52a with merge base e16c048 ( This comment was automatically generated by Dr. CI and updates every 15 minutes. |
|
@SS-JIA has imported this pull request. If you are a Meta employee, you can view this in D111804927. |
This PR needs a
|
Summary
Fixes a native Vulkan compute pipeline creation crash (
-3 VK_ERROR_INITIALIZATION_FAILED) on Android 16 (API 36) drivers.VK_EXT_subgroup_size_controlwas 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 viavkGetPhysicalDeviceFeatures2. ChainingVkPhysicalDeviceSubgroupSizeControlFeaturesEXTintoVkDeviceCreateInfo.pNextwithout 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
apiVersionto Vulkan 1.3, capped at the loader-supported version and falling back to 1.1 on loaders that predatevkEnumerateInstanceVersion(select_instance_api_version()inDevice.cpp). This never fails on a 1.1+ loader and does not drop older devices — the instance version is a ceiling, not a floor.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.const_cast(take a mutablePhysicalDevice&) and add the missing#include <cstring>.The pipeline code and feature-detection code need no changes: the
...EXTstructs/enums they already use are aliases of the core Vulkan 1.3 types.Suggested review order
Device.cpp/Device.h— the loader-safeselect_instance_api_version()helper.Runtime.cpp— instanceapiVersionnow uses that helper.Adapter.cpp— per-device extension-or-core gating increate_logical_device.Test Plan
Fixes #11754.
Authored with Claude.
🤖 Generated with Claude Code
cc @manuelcandales @digantdesai @cbilgin