Skip to content

[ET-VK] Plumb subgroup property queries + VK_EXT_subgroup_size_control#19403

Merged
meta-codesync[bot] merged 1 commit intogh/SS-JIA/530/basefrom
gh/SS-JIA/530/head
May 8, 2026
Merged

[ET-VK] Plumb subgroup property queries + VK_EXT_subgroup_size_control#19403
meta-codesync[bot] merged 1 commit intogh/SS-JIA/530/basefrom
gh/SS-JIA/530/head

Conversation

@SS-JIA
Copy link
Copy Markdown
Contributor

@SS-JIA SS-JIA commented May 8, 2026

Stack from ghstack (oldest at bottom):

Adds infrastructure for querying GPU subgroup capabilities and pinning required subgroup size at pipeline creation time, sourced from the existing SUBGROUP_SIZE yaml template parameter. This is the foundation for writing subgroup-using shaders (e.g. cooperative GEMV variants) that remain portable across GPUs with different subgroup widths (Adreno=64, Mali=16, NVIDIA=32, etc.).

PhysicalDevice now chains VkPhysicalDeviceSubgroupProperties and VkPhysicalDeviceSubgroupSizeControlProperties into vkGetPhysicalDeviceProperties2, plus VkPhysicalDeviceSubgroupSizeControlFeatures into vkGetPhysicalDeviceFeatures2. The Adapter exposes accessors for subgroup_size, supported subgroup ops/stages, [min,max] subgroup size range, and whether the driver supports per-pipeline required subgroup size for the COMPUTE stage. VK_EXT_subgroup_size_control is added to the requested extension list and the size-control features are chained into device-create pNext when supported.

ComputePipeline::Descriptor gains a required_subgroup_size field that, when nonzero, chains VkPipelineShaderStageRequiredSubgroupSizeCreateInfoEXT into pipeline creation (both the on-demand retrieve path and the batch create_pipelines path). The pipeline cache key includes the field so pipelines compiled for different subgroup widths cache independently. ShaderInfo carries the same field so it can be plumbed from shader yaml through to the pipeline descriptor.

The existing SUBGROUP_SIZE yaml template parameter is now the single source of truth: gen_vulkan_spv.py substitutes it into GLSL as before AND emits it as ShaderInfo::required_subgroup_size. At dispatch, vkapi::resolve_required_subgroup_size validates the value is within the adapter's [min, max] range and throws ShaderNotSupportedError if the extension is unsupported or the value is out of range, surfacing a clear failure rather than silently miscompiling a shader whose algorithm depends on the pinned subgroup width.

No shader yamls are modified by this change; subsequent commits opt their shaders into the pinning by declaring SUBGROUP_SIZE in their yamls.

Differential Revision: D104456803

Adds infrastructure for querying GPU subgroup capabilities and pinning required subgroup size at pipeline creation time, sourced from the existing `SUBGROUP_SIZE` yaml template parameter. This is the foundation for writing subgroup-using shaders (e.g. cooperative GEMV variants) that remain portable across GPUs with different subgroup widths (Adreno=64, Mali=16, NVIDIA=32, etc.).

`PhysicalDevice` now chains `VkPhysicalDeviceSubgroupProperties` and `VkPhysicalDeviceSubgroupSizeControlProperties` into `vkGetPhysicalDeviceProperties2`, plus `VkPhysicalDeviceSubgroupSizeControlFeatures` into `vkGetPhysicalDeviceFeatures2`. The `Adapter` exposes accessors for subgroup_size, supported subgroup ops/stages, [min,max] subgroup size range, and whether the driver supports per-pipeline required subgroup size for the COMPUTE stage. `VK_EXT_subgroup_size_control` is added to the requested extension list and the size-control features are chained into device-create pNext when supported.

`ComputePipeline::Descriptor` gains a `required_subgroup_size` field that, when nonzero, chains `VkPipelineShaderStageRequiredSubgroupSizeCreateInfoEXT` into pipeline creation (both the on-demand `retrieve` path and the batch `create_pipelines` path). The pipeline cache key includes the field so pipelines compiled for different subgroup widths cache independently. `ShaderInfo` carries the same field so it can be plumbed from shader yaml through to the pipeline descriptor.

The existing `SUBGROUP_SIZE` yaml template parameter is now the single source of truth: `gen_vulkan_spv.py` substitutes it into GLSL as before AND emits it as `ShaderInfo::required_subgroup_size`. At dispatch, `vkapi::resolve_required_subgroup_size` validates the value is within the adapter's `[min, max]` range and throws `ShaderNotSupportedError` if the extension is unsupported or the value is out of range, surfacing a clear failure rather than silently miscompiling a shader whose algorithm depends on the pinned subgroup width.

No shader yamls are modified by this change; subsequent commits opt their shaders into the pinning by declaring `SUBGROUP_SIZE` in their yamls.

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

[ghstack-poisoned]
@pytorch-bot
Copy link
Copy Markdown

pytorch-bot Bot commented May 8, 2026

🔗 Helpful Links

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

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

⏳ No Failures, 1 Pending, 1 Unclassified Failure

As of commit 230de70 with merge base c564936 (image):
💚 Looks good so far! There are no failures yet. 💚

UNCLASSIFIED FAILURE - DrCI could not classify the following job because the workflow did not run on the merge base. The failure may be pre-existing on trunk or introduced by this PR:

  • Check Labels (gh) (this job did not run on the merge base, so DrCI cannot tell whether the failure is pre-existing)

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 May 8, 2026
@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 8, 2026

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.

@meta-codesync meta-codesync Bot merged commit 1f8a6e6 into gh/SS-JIA/530/base May 8, 2026
177 of 181 checks passed
@meta-codesync meta-codesync Bot deleted the gh/SS-JIA/530/head branch May 8, 2026 23:25
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. fb-exported meta-exported

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants