Fix Vulkan subgroup size control crash by targeting Vulkan 1.3 core#20897
Open
SS-JIA wants to merge 1 commit into
Open
Fix Vulkan subgroup size control crash by targeting Vulkan 1.3 core#20897SS-JIA wants to merge 1 commit into
SS-JIA wants to merge 1 commit 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. This comment was automatically generated by Dr. CI and updates every 15 minutes. |
Contributor
|
@SS-JIA has imported this pull request. If you are a Meta employee, you can view this in D111804927. |
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.
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