Skip to content

[WebGPU] Enable subgroup matrix kernels on AMD GPUs - #32667

Merged
Jiajia Qin (qjia7) merged 1 commit into
microsoft:mainfrom
gyagp:webgpu-amd-subgroup-matrix
Sep 17, 2026
Merged

Jiajia Qin (qjia7) merged 1 commit into
microsoft:mainfrom
gyagp:webgpu-amd-subgroup-matrix

Conversation

@gyagp

Copy link
Copy Markdown
Contributor

Description

  • Update Dawn to v20260828.013844 and Agility SDK to 1.721.3-preview.
  • Support subgroup-matrix kernels on adapters that expose a variable subgroup-size range.
  • Require subgroup-size-control for variable-size adapters and request the selected configuration's subgroup size for prepack and multiplication shaders.
  • Add coverage for valid and invalid subgroup-size configurations.

Motivation and Context

AMD RDNA 3+ supports the FP16 16x16x16 subgroup-matrix configuration with a required subgroup size of 32, while the adapter exposes a variable subgroup-size range. The previous ORT check required the adapter's minimum and maximum subgroup sizes to exactly match the kernel size, so the optimized path was not selected.

The Dawn update is required in addition to the ORT changes. The previous Dawn revision:

  • depended solely on the global D3D12 LinAlg tier to expose subgroup matrices, although preview drivers can report valid operation-specific configurations when that tier is absent;
  • did not reject reported type combinations whose D3D12 operation SupportFlags lack the supported bit; and
  • did not forward enumerated subgroup-matrix configurations to Tint's HLSL lowering.

The newer Dawn revision evaluates the authoritative D3D12 capability data and supplies the configurations to Tint, allowing ORT to expose and compile the WebGPU subgroup-matrix path correctly.

Related Dawn issue: https://issues.chromium.org/issues/549226780

Testing

Windows D3D12 on AMD Radeon RX 9070 XT:

  • AMD preview driver 26.10.07.02 (32.0.31007.2064)
  • Agility SDK 721
  • SubgroupMatrixConfigTest.RequiredSubgroupSizeCompatibility: passed
  • MatMulNBits.Float16_4b_Accuracy4: passed
  • Confirmed FP16 16x16x16 shaders using subgroupMatrixLoad, subgroupMatrixMultiplyAccumulate, and subgroupMatrixStore.

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
There may be pipelines that require an authorized user to comment /azp run to run.

Allow subgroup matrix kernels to select their required subgroup size on adapters that expose a variable subgroup-size range. Require subgroup-size control in that case and request the selected configuration's size for prepack and multiplication shaders.

Update Dawn to v20260828.013844 and Agility SDK to 1.721.3-preview. The newer Dawn is required because the previous revision depended solely on the global D3D12 LinAlg tier, did not reject type combinations whose operation SupportFlags were unsupported, and did not forward the enumerated matrix configurations to Tint's HLSL lowering. AMD preview drivers can report valid operation-specific configurations even when the global tier is absent, so those fixes are needed to expose and compile the WebGPU subgroup-matrix feature correctly.

Tested on Windows D3D12 with an AMD Radeon RX 9070 XT, AMD driver 26.10.07.02 (32.0.31007.2064), and Agility SDK 721. MatMulNBits.Float16_4b_Accuracy4 passed while generating FP16 16x16x16 subgroup-matrix shaders. SubgroupMatrixConfigTest.RequiredSubgroupSizeCompatibility also passed.
@gyagp
Yang Gu (gyagp) force-pushed the webgpu-amd-subgroup-matrix branch from a0688c7 to 40f3518 Compare September 17, 2026 06:14
@gyagp

Yang Gu (gyagp) commented Sep 17, 2026 •

Copy link
Copy Markdown
Contributor Author

@microsoft-github-policy-service agree company="Microsoft"

@gyagp
Yang Gu (gyagp) marked this pull request as ready for review September 17, 2026 06:23
Copilot AI balanced review requested due to automatic review settings September 17, 2026 06:23
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
There may be pipelines that require an authorized user to comment /azp run to run.

@gyagp

Copy link
Copy Markdown
Contributor Author

/azp

@azure-pipelines

Copy link
Copy Markdown
Supported commands
  • help:
    • Get descriptions, examples and documentation about supported commands
    • Example: help "command_name"
  • list:
    • List all pipelines for this repository using a comment.
    • Example: "list"
  • run:
    • Run all pipelines or specific pipelines for this repository using a comment. Use this command by itself to trigger all related pipelines, or specify specific pipelines to run.
    • Example: "run" or "run pipeline_name, pipeline_name, pipeline_name"
  • where:
    • Report back the Azure DevOps orgs that are related to this repository and org
    • Example: "where"

See additional documentation.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

πŸ”΅ Needs a closer look

The vendor-specific GPU behavior and foundational Dawn dependency update require final human and hardware-backed validation.

Pull request overview

Enables WebGPU subgroup-matrix kernels on AMD GPUs with variable subgroup sizes.

Changes:

  • Selects and requests each kernel configuration’s required subgroup size.
  • Adds subgroup-size compatibility tests.
  • Updates Dawn and Direct3D Agility SDK dependencies.
File summaries
File Description
onnxruntime/test/providers/cpu/math/matmul_test.cc Tests fixed, variable, and invalid subgroup-size ranges.
onnxruntime/core/providers/webgpu/math/subgroup_matrix_matmul.cc Configures MatMul workgroups with the selected subgroup size.
onnxruntime/core/providers/webgpu/math/subgroup_matrix_gemm.cc Configures Gemm workgroups with the selected subgroup size.
onnxruntime/core/providers/webgpu/math/subgroup_matrix_config.h Defines required subgroup sizes and compatibility logic.
onnxruntime/core/providers/webgpu/math/subgroup_matrix_config.cc Validates adapter ranges and size-control support.
onnxruntime/contrib_ops/webgpu/quantization/subgroup_matrix_matmul_nbits.cc Pins prepack and multiplication shaders to the selected size.
cmake/patches/dawn/dawn_binskim.patch Rebases the warning-policy patch onto the new Dawn revision.
cmake/deps.txt Updates Dawn and Agility SDK pins.
Review details
  • Files reviewed: 8/8 changed files
  • Comments generated: 0
  • Review effort level: Balanced

πŸ’‘ Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@gyagp

Copy link
Copy Markdown
Contributor Author

Jiajia Qin (@qjia7), please help to review this PR to support subgroup matrix on AMD.
Jie Chen (@jchen10), please help to check if this will break Intel.

@gyagp

Copy link
Copy Markdown
Contributor Author

/run bots

@qjia7

Copy link
Copy Markdown
Contributor

The /run bots request was received from Yang Gu (@gyagp), but no CI run was started. No pending action-required workflow runs matched the current PR head.

@jchen10

Copy link
Copy Markdown
Contributor

Yang Gu (@gyagp) Just checked, no regression.

@gyagp

Copy link
Copy Markdown
Contributor Author

Yang Gu (Yang Gu (@gyagp)) Just checked, no regression.

Thanks, Jie Chen (@jchen10)!

@qjia7
Jiajia Qin (qjia7) enabled auto-merge (squash) September 17, 2026 08:55
@qjia7
Jiajia Qin (qjia7) merged commit bff4fcf into microsoft:main Sep 17, 2026
88 of 90 checks passed
kunal-vaishnavi pushed a commit that referenced this pull request Sep 17, 2026
### Description

- Update Dawn to `v20260828.013844` and Agility SDK to
`1.721.3-preview`.
- Support subgroup-matrix kernels on adapters that expose a variable
subgroup-size range.
- Require `subgroup-size-control` for variable-size adapters and request
the selected configuration's subgroup size for prepack and
multiplication shaders.
- Add coverage for valid and invalid subgroup-size configurations.

### Motivation and Context

AMD RDNA 3+ supports the FP16 16x16x16 subgroup-matrix configuration
with a required subgroup size of 32, while the adapter exposes a
variable subgroup-size range. The previous ORT check required the
adapter's minimum and maximum subgroup sizes to exactly match the kernel
size, so the optimized path was not selected.

The Dawn update is required in addition to the ORT changes. The previous
Dawn revision:

- depended solely on the global D3D12 LinAlg tier to expose subgroup
matrices, although preview drivers can report valid operation-specific
configurations when that tier is absent;
- did not reject reported type combinations whose D3D12 operation
`SupportFlags` lack the supported bit; and
- did not forward enumerated subgroup-matrix configurations to Tint's
HLSL lowering.

The newer Dawn revision evaluates the authoritative D3D12 capability
data and supplies the configurations to Tint, allowing ORT to expose and
compile the WebGPU subgroup-matrix path correctly.

Related Dawn issue: https://issues.chromium.org/issues/549226780

### Testing

Windows D3D12 on AMD Radeon RX 9070 XT:

- AMD preview driver `26.10.07.02` (`32.0.31007.2064`)
- Agility SDK 721
- `SubgroupMatrixConfigTest.RequiredSubgroupSizeCompatibility`: passed
- `MatMulNBits.Float16_4b_Accuracy4`: passed
- Confirmed FP16 16x16x16 shaders using `subgroupMatrixLoad`,
`subgroupMatrixMultiplyAccumulate`, and `subgroupMatrixStore`.
Ti-Tai Wang (titaiwangms) pushed a commit that referenced this pull request Sep 17, 2026
### Description

- Replace the transitive `compute_context.h` dependency in
`subgroup_matrix_config.h` with the Dawn type header and a forward
declaration of `ComputeContextBase`.
- Include `compute_context.h` in the implementation file where the
complete type is required.

### Motivation and Context

#32667 added `subgroup_matrix_config.h` to `matmul_test.cc`. In WebGPU
plugin builds, the old transitive include chain reached
`webgpu_execution_provider.h` without the EP adapter precompiled header,
so `onnxruntime::ep::adapter::Logger` was undeclared. This broke
`webgpu_plugin_build_x64_RelWithDebInfo` both on #32667 and on `main`.

Keeping the implementation dependency out of the public configuration
header fixes the plugin test build and avoids exposing the
execution-provider header to callers that only need subgroup matrix
configuration types.

Failing main run:
https://github.com/microsoft/onnxruntime/actions/runs/35204008069

### Testing

- `git diff --check`

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants