Skip to content

Conversation

@javier-intel
Copy link

@javier-intel javier-intel commented Jun 18, 2025

Description

Report invalid binary when context model can't be imported by OV

Motivation and Context

Correctly communicate to ORT core the failure to import EpCtx

https://jira.devtools.intel.com/browse/CVS-167480

@javier-intel javier-intel force-pushed the jemartin/import_failure_error_code branch from 7dbe8e9 to faf1a6e Compare June 18, 2025 08:29
@javier-intel javier-intel requested a review from MayureshV1 June 18, 2025 08:29
Copy link

@MayureshV1 MayureshV1 left a comment

Choose a reason for hiding this comment

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

@javier-intel .. DO we have a way to trigger compatibility failure and ensure exception triggered by elf loader and UMD is caught here?

@MayureshV1 MayureshV1 requested a review from Copilot June 18, 2025 17:38

This comment was marked as outdated.

Copy link

@MayureshV1 MayureshV1 left a comment

Choose a reason for hiding this comment

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

LGTM !

@MayureshV1 MayureshV1 requested a review from Copilot June 24, 2025 07:59

This comment was marked as outdated.

@MayureshV1 MayureshV1 requested a review from Copilot June 24, 2025 17:32

This comment was marked as outdated.

@javier-intel javier-intel force-pushed the jemartin/import_failure_error_code branch from c75e346 to 64bcdad Compare June 24, 2025 22:27
@sfatimar
Copy link

@javier-intel can you please rebase this branch so I can merge it in. Mayuresh has already approved.

@sfatimar sfatimar requested a review from vthaniel July 14, 2025 04:50
@sfatimar
Copy link

sfatimar commented Aug 1, 2025

Why has this not been merged yet ? @javier-intel ?

@sfatimar
Copy link

sfatimar commented Aug 1, 2025

@MayureshV1 please merge PR if you are approving ..You must have permissions

@javier-intel
Copy link
Author

@sfatimar I think it flew under the radar. It's a simple change but will probably need careful rebase as it's been some time since it was implemented. This week as I'll be busy with traveling so either I do it next week or someone from your team picks it up.

@javier-intel javier-intel added the ovep_abi_1.0 PRs that need to go in ABI need to have this label. label Aug 14, 2025
@javier-intel javier-intel force-pushed the jemartin/import_failure_error_code branch 3 times, most recently from c3dc39d to 93a6e38 Compare August 23, 2025 01:14
@javier-intel
Copy link
Author

@MayureshV1 can you please review again? I just built, haven't tested :(

@MayureshV1 MayureshV1 requested a review from Copilot August 25, 2025 18:55
Copy link

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 introduces proper error handling for OpenVINO model import failures by creating typed exceptions that can communicate specific error codes back to the ONNX Runtime core, particularly for invalid binary errors during context model imports.

  • Enhanced exception handling with a new typed exception system that preserves error codes
  • Modified OvExceptionBoundary to support typed exceptions for model import operations
  • Added fallback logic for NPU compilation failures with better error reporting

Reviewed Changes

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

File Description
exceptions.h New exception class with error code parsing and Status conversion
ov_interface.cc Updated exception boundary template and ImportModel to use typed exceptions
openvino_execution_provider.cc Added exception handling wrapper in Compile method
backend_manager.cc Enhanced NPU fallback logic with typed exception handling

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Copy link

@MayureshV1 MayureshV1 left a comment

Choose a reason for hiding this comment

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

Backend Manager.cc has CPU fallback flow for NPU compile failure scenario. This logic was moved to basic_backedn.cc and needs to be adapted.

https://github.com/intel/onnxruntime/pull/723/files

@ankitm3k ankitm3k force-pushed the jemartin/import_failure_error_code branch from 5778e4f to 49fe713 Compare November 11, 2025 10:24
@ankitm3k ankitm3k changed the title Report import failure error code CVS-167480 : Report import failure error code Nov 11, 2025
Per MayureshV1's review comment, the NPU->CPU fallback logic was moved to basic_backend.cc in PR #723. This commit removes the duplicate implementation from backend_manager.cc constructor to avoid conflicts and maintain single responsibility.
@ankitm3k ankitm3k force-pushed the jemartin/import_failure_error_code branch from 1e8d394 to 3ca0979 Compare November 11, 2025 12:16
@ankitm3k
Copy link

Backend Manager.cc has CPU fallback flow for NPU compile failure scenario. This logic was moved to basic_backedn.cc and needs to be adapted.

https://github.com/intel/onnxruntime/pull/723/files

Fixed. We are ready to merge now

Copy link
Author

@javier-intel javier-intel left a comment

Choose a reason for hiding this comment

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

Just a small change

}

std::string error_message = "Unhandled exception type: " + std::to_string(static_cast<int>(type_));
return {category_ort, common::FAIL, error_message};
Copy link
Author

Choose a reason for hiding this comment

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

Change FAIL to common::EP_FAIL

@MayureshV1 MayureshV1 requested a review from Copilot November 14, 2025 01:35
Copy link

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

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


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

// Newer drivers
if ((type_ == type::import_model) &&
(error_code_ == 0x7800000f /* ZE_RESULT_ERROR_INVALID_NATIVE_BINARY */)) {
std::string message{error_name_ + ", code 0x" + std::to_string(error_code_) + "\nModel needs to be recompiled\n"};
Copy link

Copilot AI Nov 14, 2025

Choose a reason for hiding this comment

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

Using std::to_string() on a hexadecimal value converts it to decimal. Use a hex formatting approach (e.g., std::format or a stringstream with hex manipulator) to preserve the hexadecimal representation of error_code_.

Copilot uses AI. Check for mistakes.
return func();
} catch (const ov::Exception& e) {
ORT_THROW(log_tag + std::vformat(fmt.get(), std::make_format_args(args...)) + ": " + std::string(e.what()));
const auto message = log_tag + (args + ...) + ": " + std::string(e.what());
Copy link

Copilot AI Nov 14, 2025

Choose a reason for hiding this comment

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

The fold expression (args + ...) requires all args to be string-like types. If any argument is not a string, this will fail to compile. Consider using string concatenation with explicit conversions or std::format as in the original implementation.

Copilot uses AI. Check for mistakes.
Comment on lines 354 to 355
},
" Cannot access IE Blob for input number: {}", index);
Copy link

Copilot AI Nov 14, 2025

Choose a reason for hiding this comment

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

The format string and argument are passed but no longer used in the new implementation of OvExceptionBoundary. These arguments should be removed or the function signature needs to be updated to accept formatted messages.

Copilot uses AI. Check for mistakes.
Comment on lines 361 to 362
},
" Cannot set Remote Blob for output: {}", name);
Copy link

Copilot AI Nov 14, 2025

Choose a reason for hiding this comment

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

Similar to Comment 4: the format string and argument are passed but not utilized by the updated OvExceptionBoundary function.

Copilot uses AI. Check for mistakes.
OvExceptionBoundary<false>([&]() {
ovInfReq.infer();
},
"In Error Couldn't start Inference");
Copy link

Copilot AI Nov 14, 2025

Choose a reason for hiding this comment

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

The error message string is passed but not used by the new OvExceptionBoundary implementation.

Suggested change
"In Error Couldn't start Inference");
" In Error Couldn't start Inference");

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ovep_abi_1.0 PRs that need to go in ABI need to have this label.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants