-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Compile API: output model and initializer stream write functions #25455
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Conversation
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
…test_allocators.cc
… original initializer
yuslepukhin
requested changes
Aug 29, 2025
adrianlizarraga
commented
Sep 2, 2025
yuslepukhin
requested changes
Sep 2, 2025
csharp/src/Microsoft.ML.OnnxRuntime/OrtExternalInitializerInfo.shared.cs
Outdated
Show resolved
Hide resolved
yuslepukhin
requested changes
Sep 3, 2025
csharp/test/Microsoft.ML.OnnxRuntime.Tests.Common/CompileApiTests.cs
Outdated
Show resolved
Hide resolved
csharp/test/Microsoft.ML.OnnxRuntime.Tests.Common/CompileApiTests.cs
Outdated
Show resolved
Hide resolved
csharp/test/Microsoft.ML.OnnxRuntime.Tests.Common/CompileApiTests.cs
Outdated
Show resolved
Hide resolved
csharp/test/Microsoft.ML.OnnxRuntime.Tests.Common/CompileApiTests.cs
Outdated
Show resolved
Hide resolved
yuslepukhin
reviewed
Sep 4, 2025
yuslepukhin
reviewed
Sep 4, 2025
yuslepukhin
reviewed
Sep 4, 2025
yuslepukhin
approved these changes
Sep 4, 2025
tianleiwu
pushed a commit
that referenced
this pull request
Sep 4, 2025
) ### Description - Adds `ModelCompilationOptions_SetOutputModelWriteFunc` to the compile API to allow writing the output model ONNX bytes to a user-provided write function (i.e., for streaming). - Adds `ModelCompilationOptions_SetOutputModelHandleInitializerFunc` to the compile API to allow the user to write individual initializers to some destination. Also allows specifying if an initializer should be embedded within the ONNX model or written to a custom file. - Adds C++, Python, and C# bindings for the new APIs. A follow-up PR adds a write function for EPContext node binary data: #25471 ### Example `ModelCompilationOptions_SetOutputModelWriteFunc`: https://github.com/microsoft/onnxruntime/blob/c62ed23c328cbbfefd3083c1f7a6ced604772c19/onnxruntime/test/providers/qnn/qnn_ep_context_test.cc#L2075-L2131 `ModelCompilationOptions_SetOutputModelHandleInitializerFunc`: https://github.com/microsoft/onnxruntime/blob/c62ed23c328cbbfefd3083c1f7a6ced604772c19/onnxruntime/test/providers/qnn/qnn_ep_context_test.cc#L2160-L2292 ### Motivation and Context Add output streaming capabilities when saving compiled models.
jywu-msft
pushed a commit
that referenced
this pull request
Sep 5, 2025
### Description Cherry-pick the following PRs: #25943 #25937 #25917 #25909 #25898 #25897 #25888 #25881 #25830 #25619 #25575 #25572 #25558 #25530 #25474 #25455 #25110 Also two dependent PRs for qMoE cpu: #25877 #25822 --------- Co-authored-by: xiaomsft <[email protected]> Co-authored-by: Xiaoyan Hu <[email protected]> Co-authored-by: Akshay Sonawane <[email protected]> Co-authored-by: Kunal Vaishnavi <[email protected]> Co-authored-by: Pradeep Sakhamoori <[email protected]> Co-authored-by: mingyue <[email protected]> Co-authored-by: Maximilian Müller <[email protected]> Co-authored-by: Adrian Lizarraga <[email protected]> Co-authored-by: Dmitri Smirnov <[email protected]> Co-authored-by: Emmanuel <[email protected]> Co-authored-by: Emmanuel Assumang <[email protected]> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: praneshgo <[email protected]> Co-authored-by: Hariharan Seshadri <[email protected]> Co-authored-by: Jing Fang <[email protected]> Co-authored-by: Ishwar Raut <[email protected]>
adrianlizarraga
added a commit
that referenced
this pull request
Oct 31, 2025
…#26439) ### Description Fixes #26294 When using the old model compilation approach (session option configuration), ORT should verify that the generated output model does not already exist. Importantly, this check should be done _before_ calling an EP's compile() method. This PR fixes this check, which was unintentionally disabled by a [previous PR.](#25455). Note that this check also (correctly) happens _after_ calling the EP's compile() method, but it is better to catch it early if we can. ### Motivation and Context Fixes a regression in the older compilation workflow.
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
ModelCompilationOptions_SetOutputModelWriteFuncto the compile API to allow writing the output model ONNX bytes to a user-provided write function (i.e., for streaming).ModelCompilationOptions_SetOutputModelHandleInitializerFuncto the compile API to allow the user to write individual initializers to some destination. Also allows specifying if an initializer should be embedded within the ONNX model or written to a custom file.A follow-up PR adds a write function for EPContext node binary data: #25471
Example
ModelCompilationOptions_SetOutputModelWriteFunc:onnxruntime/onnxruntime/test/providers/qnn/qnn_ep_context_test.cc
Lines 2075 to 2131 in c62ed23
ModelCompilationOptions_SetOutputModelHandleInitializerFunc:onnxruntime/onnxruntime/test/providers/qnn/qnn_ep_context_test.cc
Lines 2160 to 2292 in c62ed23
Motivation and Context
Add output streaming capabilities when saving compiled models.