[WebGPU] Fix profiling timestamp alignment with ORT profiler - #29021
Merged
Guenther Schmuelling (guschmue) merged 2 commits intoJun 24, 2026
Merged
Conversation
Contributor
Author
Jiajia Qin (qjia7)
previously approved these changes
Jun 15, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adjusts WebGPU GPU profiling timestamps to better align with ONNX Runtime’s profiler time base (microseconds since profiling start), avoiding GPU events that previously appeared to start at time 0 and were hard to correlate with CPU events in trace viewers.
Changes:
- Store the ORT profiler’s
profiling_start_timeinWebGpuProfilerand pass it down to the WebGPU context for session-level profiling. - Track a CPU-side offset for the first GPU submission and add it to GPU event timestamps when emitting
profiling::EventRecords. - Reset profiling alignment state (
gpu_timestamp_offset_, first-submit CPU offset) each time profiling starts.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| onnxruntime/core/providers/webgpu/webgpu_profiler.h | Exposes session profiling start time and stores it in the profiler. |
| onnxruntime/core/providers/webgpu/webgpu_profiler.cc | Captures the profiling start time provided by ORT. |
| onnxruntime/core/providers/webgpu/webgpu_execution_provider.cc | Passes session profiling start time into the context when starting profiling. |
| onnxruntime/core/providers/webgpu/webgpu_context.h | Updates StartProfiling API to accept an explicit TimePoint and stores alignment state. |
| onnxruntime/core/providers/webgpu/webgpu_context.cc | Computes CPU offset for the first submit and applies it to GPU event timestamps. |
Guenther Schmuelling (guschmue)
previously approved these changes
Jun 15, 2026
Guenther Schmuelling (guschmue)
enabled auto-merge (squash)
June 15, 2026 17:23
auto-merge was automatically disabled
June 16, 2026 00:53
Head branch was pushed to by a user without write access
Jianhui Dai (daijh)
dismissed stale reviews from Guenther Schmuelling (guschmue) and Jiajia Qin (qjia7)
via
June 16, 2026 00:53
08441be
Add CPU time offset to WebGPU GPU profiling timestamps so they align with the ORT profiler's time base (microseconds since profiling start). Previously GPU events started from 0, causing misalignment in trace viewers.
Run-level profiling previously called context_.StartProfiling() with the default now() timepoint, captured in OnRunStart. That is later than the profiling_start_time captured in Profiler::StartProfiling, so the GPU CPU-offset was measured from a different origin than ORT's CPU events, shifting all GPU events for run-level profiling. Route the framework's profiling_start_time through WebGpuContext: the WebGpuProfiler (the single hook that receives it for both session- and run-level profiling) now pushes it via SetProfilingStartTime, and StartProfiling() no longer takes a timepoint. This reaches the run-level case, whose temporary profiler OnRunStart cannot access directly.
Jianhui Dai (daijh)
force-pushed
the
webgpu-profiler
branch
from
June 23, 2026 04:22
08441be to
a5031fb
Compare
Contributor
Author
|
Rebase |
Jiajia Qin (qjia7)
approved these changes
Jun 23, 2026
Guenther Schmuelling (guschmue)
approved these changes
Jun 24, 2026
Guenther Schmuelling (guschmue)
merged commit Jun 24, 2026
cb16936
into
microsoft:main
85 checks passed
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
Add CPU time offset to WebGPU GPU profiling timestamps so they align with the ORT profiler's time base (microseconds since profiling start). Previously GPU events started from 0, causing misalignment in trace viewers.
Motivation and Context
See above.