[NvTensorRTRTX EP] Skip GPU JIT during compile-only sessions - #28503
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR introduces an internal compile-only session flag (session.compile_only) that is set by OrtCompileAPI::CompileModel() to let EPs (specifically NvTensorRTRTX) skip expensive GPU engine deserialization and execution context creation during compile-only sessions that are never used for inference.
Changes:
- Set internal session config
session.compile_only=1whenCompileModel()creates the temporaryInferenceSession. - Plumb the flag into NvTensorRTRTX EP option parsing and provider state (
compile_only_mode_). - In NvTensorRTRTX EP, skip
deserializeCudaEngine()/createExecutionContext()during graph compilation and register a stub compute function for compile-only sessions.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| onnxruntime/core/session/utils.cc | Clones session options in CompileModel() and sets session.compile_only for the compilation-only session. |
| include/onnxruntime/core/session/onnxruntime_session_options_config_keys.h | Adds the internal kOrtSessionOptionCompileOnly config key string. |
| onnxruntime/core/providers/nv_tensorrt_rtx/nv_execution_provider_info.h | Adds compile_only_mode to EP info struct. |
| onnxruntime/core/providers/nv_tensorrt_rtx/nv_execution_provider_info.cc | Reads session.compile_only from session config into compile_only_mode. |
| onnxruntime/core/providers/nv_tensorrt_rtx/nv_execution_provider.h | Adds compile_only_mode_ member to the EP instance. |
| onnxruntime/core/providers/nv_tensorrt_rtx/nv_execution_provider.cc | Skips GPU deserialization/context creation in compile-only mode and returns a stub NodeComputeInfo. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
chilo-ms
reviewed
May 26, 2026
chilo-ms
approved these changes
Jun 1, 2026
chilo-ms
enabled auto-merge (squash)
June 1, 2026 15:45
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 an internal session config entry,
"session.compile_only", set byCompileModel()beforesession initialization. The NvTensorRTRTX EP reads it in
NvExecutionProviderInfo::FromProviderOptions()and, when set, skipsdeserializeCudaEngine()/createExecutionContext()inCreateNodeComputeInfoFromGraph().The EP context node is still saved — that path uses the serialized engine buffer directly and does
not depend on the deserialized engine. A stub compute function is registered to satisfy the
framework; it returns
NOT_IMPLEMENTEDif called, which cannot happen in practice becausecompile-only sessions are destroyed without inference.
Motivation and Context
OrtCompileAPI::CompileModel()creates anInferenceSessionsolely to driveEP::Compile()andwrite out the EPContext model, then destroys it without running inference. During that session, the
NvTensorRTRTX EP was performing a full
deserializeCudaEngine()andcreateExecutionContext()—uploading engine weights to the GPU and JIT-ing the engine, only to free everything when the session
was destroyed.
When the user then loads the EPContext model in a real session, the same JIT and upload happen again.
Net effect on the typical "compile, then load and run" flow:
JIT and GPU upload run twice.