onnxruntime
bbb0cd0d - Fix plugin EP profiling timestamp skew on macOS (#27994)

Commit
54 days ago
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.
Author
Parents
Loading