Skip to content

Conversation

gedoensmax
Copy link
Contributor

Description

This change respects initializers that are external but already loaded in memory. This is required due to an optimization that leaves it to the backend to read a mapped memory area.

@chilo-ms can you help run the CI and merge this change ?

@gedoensmax
Copy link
Contributor Author

Can we get this into 1.23 since it is a fix on top of #25409.

Copy link
Contributor

@Copilot 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 an issue in the TensorRT execution provider where external initializers (weights) that are already loaded in memory were not being handled correctly for large models. The fix ensures that initializers with external data in memory are properly recognized and processed alongside those with raw data.

  • Converts TensorrtUserWeights from struct to class with proper accessors to improve encapsulation
  • Adds handling for external initializers that are already loaded in memory using HasExternalDataInMemory checks
  • Updates serialization logic to exclude external data from graph proto when include_initializer_data is false

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
tensorrt_execution_provider.h Converts TensorrtUserWeights to class with proper encapsulation and accessor methods
tensorrt_execution_provider.cc Adds external data handling logic and updates weight processing to use new class interface
graph_proto_serializer.cc Updates serialization condition to handle external data in memory alongside raw data

@jywu-msft
Copy link
Member

/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

Copy link

Azure Pipelines successfully started running 5 pipeline(s).

@jywu-msft
Copy link
Member

/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

Copy link

Azure Pipelines successfully started running 5 pipeline(s).

@jywu-msft
Copy link
Member

there are build errors (warnings as errors)
/onnxruntime_src/onnxruntime/core/providers/tensorrt/tensorrt_execution_provider.h:173:3: error: type qualifiers ignored on function return type [-Werror=ignored-qualifiers]
173 | const int64_t Size() const {
| ^~~~~
cc1plus: all warnings being treated as errors

@gedoensmax
Copy link
Contributor Author

Thanks, should be fixed now. I also fixed some test usage and improved the logging.

@jywu-msft
Copy link
Member

/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

Copy link

Azure Pipelines successfully started running 5 pipeline(s).

@gedoensmax
Copy link
Contributor Author

The failing CI seems tobe unrelated to my changes but had some network outage or builder crashes.

@jywu-msft jywu-msft merged commit 0905c56 into microsoft:main Jul 25, 2025
90 of 100 checks passed
@snnn
Copy link
Member

snnn commented Jul 25, 2025

Hi there! We haven't cut the release branch for this version yet, so I'm removing the release:1.23.0 label for now to keep things tidy. Thanks so much for your contribution! We'll make sure this gets included when the release is prepared. 🤖

sanketkaleoss pushed a commit to sanketkaleoss/onnxruntime that referenced this pull request Aug 11, 2025
…t are not correctly excluded (microsoft#25502)

### Description

This change respects initializers that are external but already loaded
in memory. This is required due to an optimization that leaves it to the
backend to read a mapped memory area.

@chilo-ms can you help run the CI and merge this change ?

---------

Co-authored-by: Copilot <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants