Skip to content

Clarify external initializer and EP context path interaction - #32442

Merged
Jambay Kinley (jambayk) merged 3 commits into
mainfrom
jambayk/external-cb
Sep 9, 2026
Merged

Jambay Kinley (jambayk) merged 3 commits into
mainfrom
jambayk/external-cb

Conversation

@jambayk

Copy link
Copy Markdown
Contributor

Description

  • Clarify how session.model_external_initializers_file_folder_path interacts with ep.context_file_path.
  • Add actionable OpenVINO and QNN errors when an external EP context binary is resolved from the external-initializer directory.
  • Add OpenVINO failure/recovery coverage and strengthen the existing QNN missing-context-file assertion.
  • Preserve the existing file-path support and option semantics.

Motivation

session.model_external_initializers_file_folder_path overrides the model directory used internally to resolve ONNX external initializer data. For an EPContext model with embed_mode = 0, an EP can consequently search that directory for the external context binary unless ep.context_file_path identifies the EPContext model location. The previous errors reported only the unresolved file path and did not explain the option interaction.

Testing

  • lintrunner -a on all changed files
  • Built onnxruntime_test_all and onnxruntime_shared_lib_test in the available CPU configuration
  • onnxruntime_shared_lib_test --gtest_filter=CApiTest.TestLoadModelFromPathWithExternalInitializersViaSetExternalDataPath (1 test passed)

The local build has OpenVINO and QNN disabled, so the provider-specific tests were added but could not be executed locally.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 76e0b1ed-6661-452c-b1a2-7505883de415

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟑 Changes recommended

Both enhanced diagnostics are unreachable because path validation reports missing files first, causing the new assertions to fail.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

Clarifies EPContext path resolution when external initializer directories override model locations.

Changes:

  • Documents the interaction between both session options.
  • Adds QNN/OpenVINO diagnostics and regression coverage.
  • Verifies OpenVINO recovery when ep.context_file_path is set.
File summaries
File Description
onnxruntime/test/providers/qnn/qnn_ep_context_test.cc Strengthens missing-context diagnostics assertions.
onnxruntime/test/providers/openvino/openvino_ep_context_test.cc Tests failure and recovery path resolution.
onnxruntime/core/providers/qnn/builder/onnx_ctx_model_helper.cc Adds QNN guidance to missing-file errors.
onnxruntime/core/providers/openvino/onnx_ctx_model_helper.cc Adds OpenVINO guidance to missing-file errors.
include/onnxruntime/core/session/onnxruntime_session_options_config_keys.h Documents option interaction and semantics.
Review details
  • Files reviewed: 5/5 changed files
  • Comments generated: 2
  • Review effort level: Balanced

πŸ’‘ Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 76e0b1ed-6661-452c-b1a2-7505883de415

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

πŸ”΅ Needs a closer look

The OpenVINO error exposes an internal invariant expression instead of preserving the prior user-facing status diagnostic.

Review details

Suppressed comments (1)

onnxruntime/core/providers/openvino/onnx_ctx_model_helper.cc:123

  • ORT_ENFORCE turns this expected user-input failure into an invariant-style diagnostic, so the public exception includes the internal text validate_status.IsOK() was false. Preserve the validation status while augmenting its message, then throw that status as before.
    ORT_ENFORCE(validate_status.IsOK(), validate_status.ErrorMessage(), path_resolution_guidance);
  • Files reviewed: 5/5 changed files
  • Comments generated: 0 new
  • Review effort level: Balanced

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 76e0b1ed-6661-452c-b1a2-7505883de415
@jambayk
Jambay Kinley (jambayk) enabled auto-merge (squash) September 9, 2026 20:46
@jambayk
Jambay Kinley (jambayk) merged commit 2e3c24d into main Sep 9, 2026
94 of 97 checks passed
@jambayk
Jambay Kinley (jambayk) deleted the jambayk/external-cb branch September 9, 2026 20:48
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