Skip to content

[WebGPU] Refactor MatMul algorithm selection - #32630

Draft
Jiajia Qin (qjia7) wants to merge 10 commits into
mainfrom
codex/webgpu-matmul-algorithm-scheduler
Draft

Jiajia Qin (qjia7) wants to merge 10 commits into
mainfrom
codex/webgpu-matmul-algorithm-scheduler

Conversation

@qjia7

Copy link
Copy Markdown
Contributor

Description

  • Introduce explicit WebGPU MatMul algorithm enums for subgroup matrix, naive, Intel subgroup, packed, and packed Split-K implementations.
  • Add a common rule-based scheduler plus Intel-specific vendor scheduling while preserving the existing selection order.
  • Add the test-only ep.webgpuexecutionprovider.forceMatmulAlgorithm session option and hard-prerequisite validation.
  • Dispatch ComputeMatMul directly from the selected enum and add unit/integration coverage for every algorithm.
  • Support Vulkan-only Dawn builds on Windows without built DXC/HLSL generation and load Vulkan through the system component path.

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:

  • Vulkan-only onnxruntime_provider_test build with D3D12 disabled
  • MatMul scheduler and forced-algorithm tests: 16/16 passed
  • Existing MatMul regression tests: 4/4 passed
  • Forced FP16 subgroup-matrix execution passed on Intel Arc 140V with Vulkan cooperative-matrix support

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.

🟡 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.

Comment thread onnxruntime/test/providers/webgpu/matmul_large_test.cc

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.

🟡 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.
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.

2 participants