Skip to content

Fix plugin EP test failure when host ORT lacks newer data types#28659

Merged
tianleiwu merged 2 commits into
microsoft:mainfrom
tianleiwu:tlwu/fix_plugin_test
May 26, 2026
Merged

Fix plugin EP test failure when host ORT lacks newer data types#28659
tianleiwu merged 2 commits into
microsoft:mainfrom
tianleiwu:tlwu/fix_plugin_test

Conversation

@tianleiwu

Copy link
Copy Markdown
Contributor

Description

Fix the CUDA plugin EP package test pipeline failure where the plugin is built with the latest code (which includes float8e8m0 and other newer data types), but the host ORT 1.26 release does not support these types. When the plugin attempts to register kernel type constraints containing unsupported types, GetTensorDataType fails and the plugin load crashes.

Motivation and Context

The plugin EP architecture allows plugins to be built against a newer version of the ONNX Runtime headers while being loaded into an older host ORT. However, the existing KernelDefBuilder::TypeConstraint methods call GetTensorType (which throws on unsupported types), making it impossible for a forward-compatible plugin to register kernels that include newer data types in their type constraint lists.

Changes

  • Add TryGetTensorType() — a non-throwing variant of GetTensorType() that returns nullptr when the host ORT does not recognize a tensor element type.
  • Add TryMLDataTypeToOrtDataType() — a non-throwing variant of MLDataTypeToOrtDataType() that returns nullptr instead of asserting/throwing.
  • Update KernelDefBuilder::TypeConstraint (both vector and single-type overloads) to use the Try variants and gracefully skip unsupported types rather than failing.

Impact

  • Plugins built with newer headers can now load into older host ORT releases without crashing on unknown data types.
  • If all types in a constraint list are unsupported, the constraint is simply not registered (the kernel will not match, which is the correct fallback behavior).
  • No behavioral change when the host supports all types — the code path is identical to before.

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.

Pull request overview

This PR aims to make plugin Execution Providers forward-compatible when built against newer ONNX Runtime headers but loaded into an older host ORT that lacks newly added tensor element types (e.g., float8 variants). It does so by introducing non-throwing type-conversion helpers and changing kernel type-constraint registration to skip types the host does not recognize.

Changes:

  • Add TryGetTensorType() as a non-throwing variant of GetTensorType() that returns nullptr on failure.
  • Add TryMLDataTypeToOrtDataType() as a non-throwing variant of MLDataTypeToOrtDataType() that returns nullptr when conversion isn’t possible.
  • Update KernelDefBuilder::TypeConstraint overloads to use the Try* helpers and omit unsupported types.

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

Comment thread include/onnxruntime/ep/adapter/kernel_def_builder.h
Comment thread include/onnxruntime/ep/adapter/kernel_def_builder.h Outdated
Comment thread include/onnxruntime/ep/adapter/kernel_def_builder.h Outdated
Comment thread include/onnxruntime/ep/adapter/kernel_def_builder.h
Comment thread include/onnxruntime/ep/adapter/kernel_def_builder.h

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.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

Comment thread include/onnxruntime/ep/adapter/kernel_def_builder.h
@sanaa-hamel-microsoft

sanaa-hamel-microsoft commented May 26, 2026

Copy link
Copy Markdown
Contributor

Mildly irked by the duplication in (Try)?MLDataTypeToOrtDataType, but should be fine.

@tianleiwu tianleiwu enabled auto-merge (squash) May 26, 2026 17:59
@tianleiwu tianleiwu merged commit 2c4a0c1 into microsoft:main May 26, 2026
88 checks passed
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