Skip to content

Conversation

@xhan65
Copy link
Contributor

@xhan65 xhan65 commented Jan 6, 2026

Description

This PR adds new C API for querying hardware device and execution provider (EP) compatibility/incompatibility reasons. The API allows applications to determine why a specific EP may not be compatible with a given hardware device before attempting to use it. The EP implementor decides how device compatibility is defined for their stack and communicates this via the possible states in the OrtDeviceEpIncompatibilityDetails struct.

New API Functions

  • GetHardwareDeviceEPIncompatibilityReasons - Query incompatibility reasons between an EP and a hardware device
  • DeviceEpIncompatibilityDetails_GetReasonsBitmask - Get a bitmask of incompatibility reasons
  • DeviceEpIncompatibilityDetails_GetErrorCode - Get an EP-specific error code
  • DeviceEpIncompatibilityDetails_GetNotes - Get optional human-readable notes about incompatibility
  • ReleaseDeviceEpIncompatibilityDetails - Release the details object

New Types

  • OrtDeviceEpIncompatibilityDetails - Opaque type holding incompatibility information
  • OrtDeviceEpIncompatibilityReason - Enum defining standard incompatibility reason flags

Testing

  • Added unit tests in hardware_device_compatibility_test.cc for the new C API functions
  • Added plugin EP compatibility tests in test_execution.cc
    . Tests verify both compatible (CPU device with CPU-supporting EP) and incompatible (GPU device with CPU-only EP) scenarios
  • Updated example plugin EP to implement the compatibility checking interface

Motivation and Context

Applications using ONNX Runtime need a way to understand why an execution provider cannot run on a particular hardware device. This is especially important for:

  • User feedback - Providing meaningful error messages when hardware is incompatible
  • EP selection - Choosing the best available EP based on compatibility
  • Diagnostics - Understanding driver/dependency requirements

Previously, there was no standardized way to query this information. EPs would simply fail at session creation/model load/inference time without providing actionable feedback.

@xhan65 xhan65 force-pushed the user/xiha/compat_api branch 2 times, most recently from ad78f56 to 80f9953 Compare January 7, 2026 02:05
@adrianlizarraga
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

@azure-pipelines
Copy link

Azure Pipelines successfully started running 4 pipeline(s).

@xhan65 xhan65 marked this pull request as ready for review January 12, 2026 04:26
@adrianlizarraga
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

@azure-pipelines
Copy link

Azure Pipelines successfully started running 4 pipeline(s).

edgchen1
edgchen1 previously approved these changes Jan 13, 2026
adrastogi
adrastogi previously approved these changes Jan 13, 2026
@xhan65 xhan65 closed this Jan 14, 2026
@xhan65 xhan65 reopened this Jan 14, 2026
@xhan65
Copy link
Contributor Author

xhan65 commented Jan 14, 2026

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

@azure-pipelines
Copy link

Commenter does not have sufficient privileges for PR 26922 in repo microsoft/onnxruntime

@adrianlizarraga
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

@azure-pipelines
Copy link

Azure Pipelines successfully started running 4 pipeline(s).

@xhan65 xhan65 dismissed stale reviews from adrastogi, edgchen1, and adrianlizarraga via 62fdfe3 January 14, 2026 05:38
@xhan65 xhan65 force-pushed the user/xiha/compat_api branch from 9de6ce8 to 62fdfe3 Compare January 14, 2026 05:38
@adrianlizarraga
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

@azure-pipelines
Copy link

Azure Pipelines successfully started running 4 pipeline(s).

@adrianlizarraga adrianlizarraga enabled auto-merge (squash) January 14, 2026 06:57
@adrianlizarraga adrianlizarraga merged commit 081633e into microsoft:main Jan 14, 2026
88 checks passed
alex-spacemit pushed a commit to spacemit-com/onnxruntime that referenced this pull request Jan 20, 2026
### Description
<!-- Describe your changes. -->
This PR adds new C API for querying hardware device and execution
provider (EP) compatibility/incompatibility reasons. The API allows
applications to determine why a specific EP may not be compatible with a
given hardware device before attempting to use it. The EP implementor
decides how device compatibility is defined for their stack and
communicates this via the possible states in the
OrtDeviceEpIncompatibilityDetails struct.

New API Functions
- GetHardwareDeviceEPIncompatibilityReasons - Query incompatibility
reasons between an EP and a hardware device
- DeviceEpIncompatibilityDetails_GetReasonsBitmask - Get a bitmask of
incompatibility reasons
- DeviceEpIncompatibilityDetails_GetErrorCode - Get an EP-specific error
code
- DeviceEpIncompatibilityDetails_GetNotes - Get optional human-readable
notes about incompatibility
- ReleaseDeviceEpIncompatibilityDetails - Release the details object

New Types
- OrtDeviceEpIncompatibilityDetails - Opaque type holding
incompatibility information
- OrtDeviceEpIncompatibilityReason - Enum defining standard
incompatibility reason flags

Testing
- Added unit tests in hardware_device_compatibility_test.cc for the new
C API functions
- Added plugin EP compatibility tests in test_execution.cc
. Tests verify both compatible (CPU device with CPU-supporting EP) and
incompatible (GPU device with CPU-only EP) scenarios
- Updated example plugin EP to implement the compatibility checking
interface

### Motivation and Context

Applications using ONNX Runtime need a way to understand why an
execution provider cannot run on a particular hardware device. This is
especially important for:

- User feedback - Providing meaningful error messages when hardware is
incompatible
- EP selection - Choosing the best available EP based on compatibility
- Diagnostics - Understanding driver/dependency requirements

Previously, there was no standardized way to query this information. EPs
would simply fail at session creation/model load/inference time without
providing actionable feedback.
@rwinterton
Copy link

Determining the optimal EP for execution requires inputs from the application, the OS, and the EP driver. To establish priority, the application must provide the OS with a deadline. While the OS retains exclusive control over thread scheduling, the hardware manages frequency and thermal constraints. Ultimately, the API should be simple yet provide enough data for each component to make the correct decision.

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.

6 participants