Skip to content

Fix builds with newer installed ONNX versions - #33259

Open
Rui Chen (chenrui333) wants to merge 1 commit into
microsoft:mainfrom
chenrui333:fix-supported-tensor-element-sizes
Open

Rui Chen (chenrui333) wants to merge 1 commit into
microsoft:mainfrom
chenrui333:fix-supported-tensor-element-sizes

Conversation

@chenrui333

Copy link
Copy Markdown

Description

Restrict the TensorProto element-size table and the ONNX-to-ORT bijection check to the types supported by ONNX Runtime, through INT2. Extend the constexpr and runtime conversion tests to verify that newer ONNX types remain unsupported.

Motivation and Context

Building ONNX Runtime 1.31.0 against installed ONNX 1.23.2 fails two static assertions because ONNX adds FLOAT6E2M3 and FLOAT6E3M2. The existing conversion helpers already return zero or UNDEFINED for unsupported types. Preserve that behavior while checking completeness and bijectivity for supported types; this does not add FLOAT6 or opset 28 support.

Both original checks fail focused compilation against ONNX 1.23.2. The patched current-main headers pass the updated constexpr checks on macOS arm64.

ONNX Runtime 1.31.0 builds from source against brewed ONNX 1.23.2, and its installed C++ inference test passes on macOS arm64. The changed files pass clang-format 20.1.8 and git diff --check.

Signed-off-by: Rui Chen <rui@chenrui.dev>
Copilot AI balanced review requested due to automatic review settings October 11, 2026 02:04
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
There may be pipelines that require an authorized user to comment /azp run to run.

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.

🟢 Approval recommended

The focused compatibility change preserves existing unsupported-type behavior and includes appropriate compile-time and runtime coverage.

0 open findings

What changed in this PR

Restricts type checks to ONNX types currently supported by ONNX Runtime, preserving compatibility with newer installed ONNX versions.

Changes:

  • Bounds element-size and type-mapping checks through INT2.
  • Verifies newer ONNX types remain unsupported.
File Description
onnxruntime/​core/​framework/​tensorprotoutils.h Bounds the element-size table to supported types.
onnxruntime/​core/​framework/​onnxruntime_map_type_info.h Limits bijection validation to supported mappings.
onnxruntime/​test/​framework/​type_info_test.cc Tests supported and newer unsupported conversions.
onnxruntime/​test/​framework/​tensorutils_test.cc Tests zero sizes for newer unsupported types.

🧠 Review effort: Balanced


💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Mark Harfouche (hmaarrfk) added a commit to hmaarrfk/onnxruntime-feedstock that referenced this pull request Oct 11, 2026
<details><summary>Claude's draft</summary>

Replaces the backport of microsoft/onnxruntime#33134 (float6 types,
opset 28, new Cast/Mod/BitShift kernels; 75 files) with
microsoft/onnxruntime#33259 "Fix builds with newer installed ONNX
versions" at 9be45798 (open, not reviewed yet; 4 files, +27/-7).

#33259 only relaxes the two compile-time checks that size their tables
by TensorProto_DataType_DataType_ARRAYSIZE, so onnxruntime 1.31.0
compiles against libonnx 1.23.2 with the two float6 types treated as
unsupported. It adds no feature upstream 1.31.0 does not have. It
applies to 1.31.0 without changes.

Consequence: onnxruntime keeps its 1.31.0 operator coverage. libonnx
1.23.2 reports opset 28 as released, so opset-28 models are accepted,
but nodes whose schema was re-versioned in opset 28 (Cast, Mod, BitShift
and 16 others) have no kernel and fail at session creation.

Resume this Claude session:
```
cd /home/mark/git/feedstock/onnxruntime-feedstock
claude --resume c16b7120-814d-4a38-9b1f-2afd9f75d054
```
</details>

Claude-Session: https://claude.ai/code/session_01XZa8BwzZpVJtREiCoVo1k6
Mark Harfouche (hmaarrfk) added a commit to hmaarrfk/onnxruntime-feedstock that referenced this pull request Oct 11, 2026
<details><summary>Claude's draft</summary>

With only the build fix (microsoft/onnxruntime#33259), onnxruntime 1.31.0
compiles against libonnx 1.23.2 but 37 unit tests fail in a local
linux-64 build. libonnx 1.23.2 reports opset 28 as released, tests that
do not name an ai.onnx opset get 28, and 1.31.0 has no Cast kernel for
it ("Failed to find kernel for Cast(28)", 35 times).

Rather than skip them, add a test-only patch:

* op_tester.cc: give test models an explicit ai.onnx opset of 27 when
  the test does not set one (CausalConvWithStateTest.*, MoETest.QMoETest_*).
* GetCurrentOnnxOpset() in graph_transform_test.cc and
  graph_transform_test_layernorm.cc: cap at 27
  (EmbedLayerNormFusionFormat{2,3}CurrentOpset).
* Test updates taken from microsoft/onnxruntime#33134:
  layout_transformation_potentially_added_ops_test.cc (opset-28 Q/DQ
  exception), qdq_transformer_test.cc (pin to opset 25) and scan_test.cc
  (ONNX 1.23 shape-inference messages).

27 is what these tests run at upstream, where ONNX 1.22 is vendored. No
library code changes.

Resume this Claude session:
```
cd /home/mark/git/feedstock/onnxruntime-feedstock
claude --resume c16b7120-814d-4a38-9b1f-2afd9f75d054
```
</details>

Claude-Session: https://claude.ai/code/session_01XZa8BwzZpVJtREiCoVo1k6
Mark Harfouche (hmaarrfk) added a commit to hmaarrfk/onnxruntime-feedstock that referenced this pull request Oct 11, 2026
<details><summary>Claude's draft</summary>

The build-only fix (microsoft/onnxruntime#33259) left onnxruntime without
kernels for the operators ONNX re-versioned in opset 28, so every test
that builds a model at libonnx 1.23.2's default opset had to be pinned
back to opset 27. The test-only patch covered the CPU suites, but the
osx-arm64 jobs still failed in six CoreMLExecutionProviderTest cases with
"Failed to find kernel for Cast(28)", and fixing those would have meant
patching more test code than any upstream PR does.

Go back to microsoft/onnxruntime#33134 (head d9485f2a, still open), which
adds opset 28 and the Cast/Mod/BitShift 28 kernels along with the test
updates, and drop both the #33259 patch and the test-only opset pin. The
recipe is now identical to 423a84b, which built locally on linux-64 with
only the machine-specific GroupQueryAttention test failing.

Resume this Claude session:
```
cd /home/mark/git/feedstock/onnxruntime-feedstock
claude --resume c16b7120-814d-4a38-9b1f-2afd9f75d054
```
</details>

Claude-Session: https://claude.ai/code/session_01XZa8BwzZpVJtREiCoVo1k6

This branch has not been deployed

No deployments
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.

2 participants