Commit bbb0cd0
authored
Fix plugin EP profiling timestamp skew on macOS (#27994)
## Description
This fixes a flaky failure in the plugin EP profiling tests on macOS,
where reconstructed plugin event timestamps could land a few
microseconds outside the correlated ORT parent event interval.
The current example plugin profiler reconstructs EP-relative timestamps
by combining ORT's profiling-start offset with elapsed time from the EP
clock. That reconstruction is close but not exact across clocks, and on
macOS the skew was enough to fail the strict containment checks in
`KernelPluginEp_SessionProfiling` with cases like `ep_start <
parent_start` by a small margin.
Instead of weakening the test, this change keeps the strict contract and
fixes the profiler output so child EP events are always emitted within
the correlated ORT parent event interval.
## Key Changes
| File | Change |
|------|--------|
|
`onnxruntime/test/autoep/library/example_plugin_ep_kernel_registry/ep_profiling.h`
| Stores the correlated ORT parent event start timestamp and duration on
each collected EP event, and adds the helper signature updates needed to
propagate that metadata. |
|
`onnxruntime/test/autoep/library/example_plugin_ep_kernel_registry/ep_profiling.cc`
| Captures parent event timing from `Ort::ConstProfilingEvent`, attaches
it to EP events during `StopEventImpl`, and clamps the reconstructed EP
start/end interval to the parent ORT interval before emitting the final
profiling event. |
## Why This Change Is Needed
- The plugin EP profiling tests intentionally require strict nesting: EP
child events must stay within the ORT parent event interval.
- The existing implementation reconstructs EP timestamps from two
different clocks, which can drift by a few microseconds depending on
platform timing behavior.
- macOS exposed that drift often enough to make
`KernelPluginEp_SessionProfiling` flaky even though the logical event
ordering was correct.
- Clamping the emitted child interval to the already-correlated parent
interval preserves the expected semantics and removes the
platform-specific skew from the final profiling output.
## Testing
- `ninja -C build/cuda/Debug onnxruntime_autoep_test`
- `cd build/cuda/Debug && ./onnxruntime_autoep_test
--gtest_filter=OrtEpLibrary.KernelPluginEp_SessionProfiling`
- `cd build/cuda/Debug && ./onnxruntime_autoep_test
--gtest_filter=OrtEpLibrary.KernelPluginEp_RunProfiling`
## Notes For Reviewers
- This is intentionally scoped to the example plugin EP profiling path
used by the AutoEP tests.
- The change avoids relaxing any assertions in `test_execution.cc`; it
fixes the emitted profiling data instead.1 parent 58a87dc commit bbb0cd0
2 files changed
Lines changed: 29 additions & 4 deletions
File tree
- onnxruntime/test/autoep/library/example_plugin_ep_kernel_registry
Lines changed: 24 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
| 4 | + | |
4 | 5 | | |
5 | 6 | | |
6 | 7 | | |
| |||
59 | 60 | | |
60 | 61 | | |
61 | 62 | | |
62 | | - | |
| 63 | + | |
| 64 | + | |
63 | 65 | | |
64 | 66 | | |
65 | 67 | | |
| |||
77 | 79 | | |
78 | 80 | | |
79 | 81 | | |
| 82 | + | |
| 83 | + | |
80 | 84 | | |
81 | 85 | | |
82 | 86 | | |
| |||
169 | 173 | | |
170 | 174 | | |
171 | 175 | | |
| 176 | + | |
| 177 | + | |
172 | 178 | | |
173 | 179 | | |
174 | | - | |
| 180 | + | |
175 | 181 | | |
176 | 182 | | |
177 | 183 | | |
| |||
209 | 215 | | |
210 | 216 | | |
211 | 217 | | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
212 | 234 | | |
213 | 235 | | |
214 | 236 | | |
| |||
Lines changed: 5 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
68 | 68 | | |
69 | 69 | | |
70 | 70 | | |
71 | | - | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
72 | 74 | | |
73 | 75 | | |
74 | 76 | | |
| |||
82 | 84 | | |
83 | 85 | | |
84 | 86 | | |
85 | | - | |
| 87 | + | |
| 88 | + | |
86 | 89 | | |
87 | 90 | | |
88 | 91 | | |
| |||
0 commit comments