Repository navigation
Promote EPContext data callbacks to stable API - #32265
Merged
Gopalakrishnan Nallasamy (GopalakrishnanN) merged 20 commits intoOct 5, 2026
Merged
Gopalakrishnan Nallasamy (GopalakrishnanN) merged 20 commits into
Gopalakrishnan Nallasamy (GopalakrishnanN) merged 20 commits into
Conversation
Promote named-buffer EPContext callbacks to the stable C and C++ APIs with a required finite read-size policy. Add immutable EP config snapshots, strict participating-EP support negotiation, V28 compatibility shims, hardened sample helpers, example plugin adoption, documentation, and focused API/auto-EP tests.
Copilot started reviewing on behalf of
Gopalakrishnan Nallasamy (GopalakrishnanN)
August 25, 2026 21:50
This was referenced Aug 25, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
Promotes EPContext callback transport to the stable ONNX Runtime 1.30 APIs with bounded reads and EP capability negotiation.
Changes:
- Adds stable C/C++ callback registration, configuration snapshots, and compatibility shims.
- Enforces read-size limits and READ/WRITE support advertisement.
- Migrates the example EP and expands compatibility and failure-path tests.
Reviewed changes
Copilot reviewed 38 out of 38 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
onnxruntime/test/shared_lib/test_ep_context_legacy_header.c |
Checks legacy C header compatibility. |
onnxruntime/test/shared_lib/test_ep_context_data_api.cc |
Tests stable and legacy APIs. |
onnxruntime/test/autoep/test_execution.cc |
Tests support negotiation end-to-end. |
onnxruntime/test/autoep/library/example_plugin_ep/ep.h |
Declares stable config and support hook. |
onnxruntime/test/autoep/library/example_plugin_ep/ep.cc |
Advertises callback support. |
onnxruntime/test/autoep/library/example_plugin_ep/ep_test_hooks.h |
Adds support-advertisement test option. |
onnxruntime/test/autoep/library/example_plugin_ep/ep_factory.cc |
Configures support and stable snapshot. |
onnxruntime/test/autoep/library/ep_context_data_utils.h |
Enforces bounded reads. |
onnxruntime/test/autoep/ep_context_data_utils_test.cc |
Tests oversized payload rejection. |
onnxruntime/core/session/provider_bridge_ort.cc |
Bridges callback configuration. |
onnxruntime/core/session/plugin_ep/ep_plugin_provider_interfaces.h |
Declares plugin support query. |
onnxruntime/core/session/plugin_ep/ep_plugin_provider_interfaces.cc |
Implements versioned support query. |
onnxruntime/core/session/plugin_ep/ep_api.h |
Declares stable EP APIs. |
onnxruntime/core/session/plugin_ep/ep_api.cc |
Implements EP config snapshots. |
onnxruntime/core/session/ort_apis.h |
Declares stable read setter. |
onnxruntime/core/session/onnxruntime_c_api.cc |
Appends the read setter. |
onnxruntime/core/session/inference_session.cc |
Passes callback state to partitioning. |
onnxruntime/core/session/experimental_c_api.cc |
Forwards legacy APIs. |
onnxruntime/core/session/compile_api.h |
Declares stable write setter. |
onnxruntime/core/session/compile_api.cc |
Implements and registers write setter. |
onnxruntime/core/session/abi_session_options.cc |
Stores and exposes callback policy. |
onnxruntime/core/session/abi_session_options_impl.h |
Declares callback accessor. |
onnxruntime/core/providers/shared_library/provider_wrappedtypes.h |
Wraps provider callback access. |
onnxruntime/core/providers/shared_library/provider_interfaces.h |
Extends provider-host bridge. |
onnxruntime/core/framework/session_options.h |
Stores maximum read size. |
onnxruntime/core/framework/graph_partitioner.h |
Adds callback-registration input. |
onnxruntime/core/framework/graph_partitioner.cc |
Enforces EP support flags. |
onnxruntime/core/framework/ep_context_options.h |
Defines callback snapshot data. |
include/onnxruntime/core/session/onnxruntime_experimental_cxx_api.h |
Aliases deprecated C++ wrapper. |
include/onnxruntime/core/session/onnxruntime_experimental_c_api.inc |
Deprecates V28 lookup APIs. |
include/onnxruntime/core/session/onnxruntime_experimental_c_api.h |
Redirects types to stable API. |
include/onnxruntime/core/session/onnxruntime_ep_c_api.h |
Adds EP config and support APIs. |
include/onnxruntime/core/session/onnxruntime_cxx_inline.h |
Implements stable C++ wrappers. |
include/onnxruntime/core/session/onnxruntime_cxx_api.h |
Declares stable C++ wrappers. |
include/onnxruntime/core/session/onnxruntime_c_api.h |
Defines stable callback contracts. |
include/onnxruntime/core/framework/execution_provider.h |
Adds default support query. |
docs/design/Compiled_Model_Encryption.md |
Documents the stable contract. |
cmake/onnxruntime_unittests.cmake |
Builds the legacy-header test. |
💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Mark the strict-read flag unused when ONNX partitioning is excluded, and preserve the V28 EPContext config shims directly in minimal builds where the plugin EP API implementation is intentionally not linked.
This was referenced Aug 26, 2026
Contributor
Author
|
Python binding follow-up: #32271 |
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Gopalakrishnan Nallasamy (GopalakrishnanN)
requested review from
Edward Chen (edgchen1)
and
a balanced review from Copilot
August 28, 2026 11:51
Copilot started reviewing on behalf of
Gopalakrishnan Nallasamy (GopalakrishnanN)
August 28, 2026 11:51
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Scott McKay (skottmckay)
added a commit
that referenced
this pull request
Sep 8, 2026
Pulls minimal pieces from #32265 so that should be checked in first.
This was referenced Oct 14, 2026
This was referenced Oct 21, 2026
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
Promotes the experimental EPContext named-buffer callback transport to the stable ONNX Runtime 1.31 C and C++ APIs.
max_data_sizeand the proposed read-options type, constructor, getter, setter, and release APIs. Registration and retrieval carry only callback/state pointers.GetEpContextDataCallbackSupportREAD/WRITE advertisement, gated on plugin API version 31. Unsupported participating EPs are rejected beforeCompile(), including the ORT-format read path. Registered callbacks cannot silently fall back to filesystem I/O.Compile(), with VitisAI's direct-assignment lifecycle rationale documented.routing_recordwithrouting_snapshot_in onnxruntime/contrib_ops/cuda/moe/moe_quantization.cc. #32932 and the previously approved 2 KiB Android size-budget adjustment.Provider/binding adoption follows in QNN (#32266), OpenVINO (#32267), C# (#32270), and Python (#32271). Those follow-ups need to use the finalized callback/state-only signatures.
Motivation and Context
This graduates the transport introduced experimentally by #28624 and refined by #29294 and #31195. Applications can keep external EPContext data in encrypted or application-managed storage without silently falling back to plaintext filesystem I/O.
Following the payload-policy review, the stable contract is limited to transport, ownership, and support negotiation. Centralized result-size validation would not itself prevent allocation inside the callback; passing a limit to the callback would still depend on callback/EP enforcement. Removing the policy avoids permanent API surface for a guarantee ORT does not provide.
Testing
Windows VS18 builds:
cmake --build build\WindowsEpContextStable\RelWithDebInfo --config RelWithDebInfo --parallel 8 --target onnxruntime_shared_lib_test onnxruntime_autoep_test onnxruntime_test_all— passed.cmake --build build\WindowsEpContextMinimal\MinSizeRel --config MinSizeRel --parallel 4 --target onnxruntime_shared_lib_test— passed; minimal configuration disables exceptions, RTTI, and ML ops.Tests run from
build\WindowsEpContextStable\RelWithDebInfo\RelWithDebInfo:.\onnxruntime_shared_lib_test.exe --gtest_filter=EpContextDataApiTest.*— 14 passed, including immutable snapshots, cloning/lifetime, unchanged error outputs, and callback clearing..\onnxruntime_autoep_test.exe --gtest_filter=*EpContext*— 25 passed, 2 skipped for unavailable Windows symlink privileges. Covers strict support negotiation, callback/file paths, and EP-selected helper size-limit boundaries..\onnxruntime_test_all.exe --gtest_filter=InternalTestingEP.*EpContext*:InternalTestingEP.Nhwc*— 19 passed.Tests run from
build\WindowsEpContextMinimal\MinSizeRel\MinSizeRel:.\onnxruntime_shared_lib_test.exe --gtest_filter=EpContextDataApiTest.*— 2 passed.Formatting and
git diff --checkpassed. No references to the removed read-options API or runtime size fields remain in tracked files.Not validated locally: GPU/Android builds, VitisAI/VAIP hardware behavior, other hardware EP integrations, or the full suite. The VitisAI lifecycle discussion remains open for reviewer confirmation.