Skip to content

[WebGPU EP] Disable Split-K when use_deterministic_compute is true#27086

Merged
guschmue merged 6 commits intomicrosoft:mainfrom
Jiawei-Shao:impl-deterministic-flag
Feb 5, 2026
Merged

[WebGPU EP] Disable Split-K when use_deterministic_compute is true#27086
guschmue merged 6 commits intomicrosoft:mainfrom
Jiawei-Shao:impl-deterministic-flag

Conversation

@Jiawei-Shao
Copy link
Contributor

@Jiawei-Shao Jiawei-Shao commented Jan 21, 2026

Description

This patch disables Split-K when the onnxruntime session is created with use_deterministic_compute set to true in SessionOptions, which is set to false by default right now.

In onnxruntime_provider_tests, we can add so.use_deterministic_compute to true in the BaseTester::Run() to require the result must be deterministic with same input.

Motivation and Context

Current implementation of Split-K only relies on atomic operations which will cause non-deterministic answers, so we shouldn't use Split-K when we always want deterministic output with same input.

See #27003 for more details.

This patch disables `Split-K` when the onnxruntime session is
created with `use_deterministic_compute` being true in `SessionOptions`
as current implementation of `Split-K` only relies on atomic operations
which will cause non-deterministic answers.
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This pull request disables the Split-K optimization in WebGPU execution provider when the session option use_deterministic_compute is set to true. Split-K uses atomic operations which produce non-deterministic results due to the random order of partial result summation, so this change ensures deterministic outputs when required.

Changes:

  • Modified UseSplitK method to accept a ComputeContext parameter and check deterministic compute settings
  • Updated all call sites to pass the context parameter

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.

File Description
onnxruntime/core/providers/webgpu/webgpu_utils.h Added forward declaration of ComputeContext and updated UseSplitK signature to include context parameter
onnxruntime/core/providers/webgpu/webgpu_utils.cc Added include for compute_context.h and implemented deterministic compute check in UseSplitK
onnxruntime/core/providers/webgpu/math/matmul.cc Updated UseSplitK call to pass context parameter
onnxruntime/core/providers/webgpu/math/gemm_packed.cc Updated UseSplitK call to pass context parameter with address-of operator

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@qjia7 qjia7 requested review from fs-eire and guschmue January 21, 2026 06:16
@Jiawei-Shao
Copy link
Contributor Author

@fs-eire @guschmue PTAL, thanks!

@guschmue guschmue added the ep:WebGPU ort-web webgpu provider label Jan 26, 2026
@guschmue
Copy link
Contributor

/azp run Linux QNN CI Pipeline,Win_TRT_Minimal_CUDA_Test_CI,Windows ARM64 QNN CI Pipeline,Windows GPU Doc Gen CI Pipeline

@azure-pipelines
Copy link

Azure Pipelines successfully started running 4 pipeline(s).

@Jiawei-Shao Jiawei-Shao requested a review from fs-eire February 3, 2026 03:24
@guschmue
Copy link
Contributor

guschmue commented Feb 4, 2026

/azp run Linux QNN CI Pipeline,Win_TRT_Minimal_CUDA_Test_CI,Windows ARM64 QNN CI Pipeline,Windows GPU Doc Gen CI Pipeline

@azure-pipelines
Copy link

Azure Pipelines successfully started running 4 pipeline(s).

@fs-eire
Copy link
Contributor

fs-eire commented Feb 4, 2026

change looks good but need to wait for the CI fix (#27235). May need sync to latest main once it's merged.

@guschmue guschmue enabled auto-merge (squash) February 4, 2026 17:43
@fs-eire
Copy link
Contributor

fs-eire commented Feb 4, 2026

/azp run Linux QNN CI Pipeline,Win_TRT_Minimal_CUDA_Test_CI,Windows ARM64 QNN CI Pipeline,Windows GPU Doc Gen CI Pipeline

@azure-pipelines
Copy link

Azure Pipelines successfully started running 4 pipeline(s).

@guschmue guschmue merged commit 1ca9746 into microsoft:main Feb 5, 2026
88 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ep:WebGPU ort-web webgpu provider

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants