Skip to content

[NV TensorRT RTX EP] Fix external tensorrt_plugins load path#26814

Merged
yuslepukhin merged 4 commits intomicrosoft:mainfrom
keshavv27:keshavv/fix_plugin_load_path
Jan 15, 2026
Merged

[NV TensorRT RTX EP] Fix external tensorrt_plugins load path#26814
yuslepukhin merged 4 commits intomicrosoft:mainfrom
keshavv27:keshavv/fix_plugin_load_path

Conversation

@keshavv27
Copy link
Contributor

Description

Load tensorrt_plugin library from EP library location instead of runtime library location.

Motivation and Context

Plugin library was being searched for in core ONNX Runtime library path, and not the EP library path. These paths are separate in case of WinML workflow.

@anskumar01
Copy link

@devang-ml , @chilo-ms , can you please review and merge this PR? It is required for current EP drop

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes the external tensorrt_plugins library loading path to use the EP (Execution Provider) library location instead of the runtime library location. This addresses an issue where the plugin library was being incorrectly searched for in the core ONNX Runtime library path, which is separate from the EP library path in WinML workflows.

Key changes:

  • Introduced a new GetEPLibraryDirectory() helper function to determine the EP library's directory path
  • Updated the plugin loading logic to use the EP library directory instead of the runtime path
  • Updated the error log message to reflect the correct search location

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

if (last_slash != std::string::npos) {
return PathString(so_path.substr(0, last_slash + 1));
}
return PathString(so_path);
Copy link

Copilot AI Dec 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On line 70, when last_slash is not found (npos), the function returns the entire path string. This would be incorrect because if there's no slash in the path, the function should return an empty string instead of the full path, since the purpose is to return the directory containing the library, not the library path itself. Consider returning an empty PathString when last_slash == std::string::npos.

Copilot uses AI. Check for mistakes.
// Get handle to the DLL executing this code
if (!GetModuleHandleExW(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS |
GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT,
reinterpret_cast<LPCWSTR>(&GetEPLibraryDirectory),
Copy link

Copilot AI Dec 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The reinterpret_cast to LPCWSTR is incorrect. GetModuleHandleExW expects the lpModuleName parameter to be a string (LPCWSTR) when GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS is not used, but when this flag is set, it expects a raw address (LPCVOID). The address of the function should be cast to LPCWSTR without going through the pointer, i.e., reinterpret_cast(GetEPLibraryDirectory) should be used, not reinterpret_cast(&GetEPLibraryDirectory).

Copilot uses AI. Check for mistakes.
if (lastSlash != std::wstring::npos) {
return PathString(path.substr(0, lastSlash + 1));
}
return PathString(path);
Copy link

Copilot AI Dec 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On line 56, when lastSlash is not found (npos), the function returns the entire path string. This would be incorrect because if there's no slash in the path, the function should return an empty string instead of the full path, since the purpose is to return the directory containing the library, not the library path itself. Consider returning an empty PathString when lastSlash == std::wstring::npos.

Copilot uses AI. Check for mistakes.
Copy link
Member

@yuslepukhin yuslepukhin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🕐

@yuslepukhin
Copy link
Member

Please, comment and resolve Copilot issues.

Copy link
Member

@yuslepukhin yuslepukhin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:shipit:

@chilo-ms chilo-ms closed this Jan 14, 2026
@chilo-ms chilo-ms reopened this Jan 14, 2026
@chilo-ms
Copy link
Contributor

/azp run Linux QNN CI Pipeline, Win_TRT_Minimal_CUDA_Test_CI,Windows ARM64 QNN CI Pipeline,Windows GPU Doc Gen CI Pipeline,Windows x64 QNN CI Pipeline

@azure-pipelines
Copy link

Azure Pipelines successfully started running 4 pipeline(s).

@yuslepukhin yuslepukhin merged commit 11dde2d into microsoft:main Jan 15, 2026
99 of 100 checks passed
alex-spacemit pushed a commit to spacemit-com/onnxruntime that referenced this pull request Jan 20, 2026
…ft#26814)

### Description
<!-- Describe your changes. -->
Load tensorrt_plugin library from EP library location instead of runtime
library location.


### Motivation and Context
<!-- - Why is this change required? What problem does it solve?
- If it fixes an open issue, please link to the issue here. -->
Plugin library was being searched for in core ONNX Runtime library path,
and not the EP library path. These paths are separate in case of WinML
workflow.
tianleiwu pushed a commit that referenced this pull request Jan 27, 2026
### Description
<!-- Describe your changes. -->
Load tensorrt_plugin library from EP library location instead of runtime
library location.


### Motivation and Context
<!-- - Why is this change required? What problem does it solve?
- If it fixes an open issue, please link to the issue here. -->
Plugin library was being searched for in core ONNX Runtime library path,
and not the EP library path. These paths are separate in case of WinML
workflow.
tianleiwu added a commit that referenced this pull request Jan 27, 2026
| Commit | Commit Title | Author |
| :--- | :--- | :--- |
| `11dde2d9e` | [NV TensorRT RTX EP] Fix external tensorrt_plugins load
path (#26814) | keshavv27 |
| `080d96818` | Move model compatibility checks ahead of session
initialization (#27037) | adrastogi |
| `ec4f6bfa1` | [QNN EP] Fix error messages being logged as VERBOSE
instead of ERROR (#24931) | Copilot |
| `0432e7125` | perftest: support plugin eps for compile_ep_context
(#27121) | Jaskaran Singh Nagi |
| `727db0d3d` | Engine compatibility validity API implementation
(#26774) | umangb-09 |
| `27013522f` | Deprecate transformers model examples (#27156) | Jambay
Kinley |
| `f83d4d06e` | [QNN-EP] Implement file mapped weights feature (#26952)
| quic-calvnguy |

---------

Co-authored-by: keshavv27 <165012837+keshavv27@users.noreply.github.com>
Co-authored-by: adrastogi <aditya.rastogi@microsoft.com>
Co-authored-by: Aditya Rastogi <adityar@ntdev.microsoft.com>
Co-authored-by: Copilot <198982749+Copilot@users.noreply.github.com>
Co-authored-by: vraspar <51386888+vraspar@users.noreply.github.com>
Co-authored-by: yuslepukhin <11303988+yuslepukhin@users.noreply.github.com>
Co-authored-by: Dmitri Smirnov <yuslepukhin@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Dmitri Smirnov <dmitrism@microsoft.com>
Co-authored-by: Jaskaran Singh Nagi <jaskaran.singh.nagi@intel.com>
Co-authored-by: umangb-09 <umangb@nvidia.com>
Co-authored-by: Jambay Kinley <jambaykinley@microsoft.com>
Co-authored-by: quic-calvnguy <quic_calvnguy@quicinc.com>
Co-authored-by: quic_calvnguy <quic_calvnguy@quic_inc.com>
@tianleiwu tianleiwu added cherry-picked Cherry-picked for a cherrypicks branch and removed release:1.24.0 labels Jan 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cherry-picked Cherry-picked for a cherrypicks branch

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants