[WebGPU] Refactor MatMul algorithm selection - #32630
Draft
Jiajia Qin (qjia7) wants to merge 10 commits into
Draft
Jiajia Qin (qjia7) wants to merge 10 commits into
Jiajia Qin (qjia7) wants to merge 10 commits into
Conversation
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Intel eligibility misses a shape constraint, and hardware-specific tests do not skip unsupported adapters.
Get a fresh assessment by requesting another Copilot review.
Pull request overview
Centralizes WebGPU MatMul algorithm selection and enables explicit path testing.
Changes:
- Adds enum-based common and Intel-specific scheduling.
- Adds forced-algorithm configuration and coverage.
- Supports Vulkan-only Dawn builds on Windows.
File summaries
| File | Description |
|---|---|
onnxruntime/test/providers/webgpu/matmul_large_test.cc |
Adds forced-path integration tests. |
onnxruntime/test/providers/webgpu/matmul_algorithm_scheduler_test.cc |
Tests parsing, scheduling, and prerequisites. |
onnxruntime/core/providers/webgpu/webgpu_provider_options.h |
Declares the forcing option. |
onnxruntime/core/providers/webgpu/webgpu_provider_factory.cc |
Parses and validates the option. |
onnxruntime/core/providers/webgpu/webgpu_execution_provider.h |
Stores forced selection state. |
onnxruntime/core/providers/webgpu/webgpu_execution_provider.cc |
Initializes forced selection state. |
onnxruntime/core/providers/webgpu/vendor/intel/math/matmul.h |
Exposes Intel capability detection. |
onnxruntime/core/providers/webgpu/vendor/intel/math/matmul.cc |
Separates capability from heuristics. |
onnxruntime/core/providers/webgpu/vendor/intel/math/matmul_algorithm_scheduler.h |
Implements Intel scheduling policy. |
onnxruntime/core/providers/webgpu/math/subgroup_matrix_matmul.cc |
Separates applicability from execution. |
onnxruntime/core/providers/webgpu/math/matmul.h |
Extends implementation and scheduler caches. |
onnxruntime/core/providers/webgpu/math/matmul.cc |
Implements scheduling and direct dispatch. |
onnxruntime/core/providers/webgpu/math/matmul_algorithm.h |
Defines algorithm identities and conversion. |
onnxruntime/core/providers/webgpu/math/matmul_algorithm_scheduler.h |
Defines common scheduling and prerequisites. |
onnxruntime/core/providers/webgpu/compute_context.h |
Exposes forced selection to kernels. |
docs/superpowers/specs/2026-09-16-webgpu-matmul-algorithm-scheduler-design.md |
Documents the design. |
docs/superpowers/plans/2026-09-16-webgpu-matmul-algorithm-scheduler.md |
Records the implementation plan. |
cmake/external/onnxruntime_external_deps.cmake |
Configures Vulkan-only Windows Dawn builds. |
Review details
- Files reviewed: 15/18 changed files
- Comments generated: 1
- Review effort level: Balanced (auto)
Note
Copilot is running an experiment and ran this review at Balanced.
💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Forced Intel dispatch can accept small shapes that violate the subgroup kernel’s vec4-load invariant.
Get a fresh assessment by requesting another Copilot review.
Review details
- Files reviewed: 15/18 changed files
- Comments generated: 2
- Review effort level: Balanced (auto)
Note
Copilot is running an experiment and ran this review at Balanced.
Comment on lines
+39
to
+40
| case MatMulAlgorithm::IntelSubgroup: | ||
| return prerequisites.has_intel_subgroup_capability; |
| set(TINT_BUILD_HLSL_WRITER OFF CACHE BOOL "" FORCE) | ||
| set(DAWN_ENABLE_D3D12 OFF CACHE BOOL "" FORCE) | ||
| endif() | ||
| # We are currently always using the D3D12 backend. |
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.
Description
ep.webgpuexecutionprovider.forceMatmulAlgorithmsession option and hard-prerequisite validation.ComputeMatMuldirectly from the selected enum and add unit/integration coverage for every algorithm.Motivation and Context
MatMul currently chooses among several implementations through distributed conditionals. This makes each implementation difficult to test directly and makes vendor-specific selection rules difficult to maintain. Centralizing selection in an explicit scheduler makes the policy testable and allows vendor schedulers to extend the common rules.
Validation:
onnxruntime_provider_testbuild with D3D12 disabled