Skip to content

Complete native ONNX opset conversion through 28 - #3139

Open
Justin Chu (justinchuby) wants to merge 12 commits into
mainfrom
justinchuby-opset-converter-completion
Open

Justin Chu (justinchuby) wants to merge 12 commits into
mainfrom
justinchuby-opset-converter-completion

Conversation

@justinchuby

Copy link
Copy Markdown
Collaborator

Stack

This is the upper layer (2 of 2) of the ONNX support split. Prerequisite: #3138, which contains the opset-28 APIs, dtype exports, dependency/CI changes, and related documentation. This PR targets justinchuby-latest-onnx-support, not main.

Changes

Restore only the five version-converter paths from immutable source commit dcc945413b0094cebd2039c5e7eb4652205c8c98; this is a split of existing work, not a redesign.

  • Support native upward conversion within opsets 18–28, with explicit native errors and optional ONNX fallback for downgrades/out-of-range sources. Opset 29 remains excluded.
  • Update ModelProto opset imports; preserve legacy GroupNormalization per-group parameters, epsilon, and precision; adapt DFT axes/reference attributes and GridSample modes.
  • Preserve source node versions when inlining mixed-opset local functions; traverse nested GRAPH/GRAPHS attributes, including custom operators and target-version roots; repair names/metadata and track modifications.
  • Restore focused regression/semantic tests and converter documentation.

Validation

  • Combined converter/integration suite on ONNX 1.24.0: 471 passed, 1 skipped, 1 existing xfailed.
  • Required lintrunner -a: no lint issues.
  • Full-tree preservation: git diff --exit-code dcc945413b0094cebd2039c5e7eb4652205c8c98 HEAD -- passes.

Neither layer is merged; native stack registration is left to the coordinating session.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Restore the version-converter slice as the upper layer above #3138, preserving the original combined tree.

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

codecov Bot commented Oct 30, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 96.40449% with 16 lines in your changes missing coverage. Please review.
✅ Project coverage is 73.68%. Comparing base (9112df0) to head (9050918).
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
onnxscript/version_converter/_version_converter.py 90.90% 5 Missing and 5 partials ⚠️
onnxscript/version_converter/__init__.py 81.81% 3 Missing and 3 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3139      +/-   ##
==========================================
+ Coverage   73.25%   73.68%   +0.42%     
==========================================
  Files         269      270       +1     
  Lines       33441    33741     +300     
  Branches     3192     3222      +30     
==========================================
+ Hits        24498    24861     +363     
+ Misses       7874     7827      -47     
+ Partials     1069     1053      -16     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

Distinguish per-node operator schema revisions from imported source opsets. Verify schema identity at opset 18 before allowing older explicit revisions, preserving rejection of unsupported imports and changed legacy schemas. This fixes Phi export through torch.onnx without bypassing semantic validation.

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

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

The ONNX fallback inlines mixed-opset functions without adapting their bodies and loses per-node versions during serialization, potentially producing invalid models or conversion failures.

1 open issue
What changed in this PR

This upper layer of the ONNX support stack extends native version conversion through opset 28, building on the APIs and dependency updates in #3138.

Changes:

  • Adds native upgrades within opsets 18–28, explicit errors, and updated ModelProto imports.
  • Preserves operator semantics and source versions while handling local functions and nested graphs.
  • Expands regression and semantic tests and documents conversion limits and fallback behavior.
File Description
onnxscript/​version_converter/​_version_converter.py Extends conversion range, adapters, traversal, and version validation.
onnxscript/​version_converter/​_version_converter_test.py Expands upgrade, adapter, metadata, and import regression coverage.
onnxscript/​version_converter/​_version_converter_semantics_test.py Adds semantic tests for operators, functions, nested graphs, and errors.
onnxscript/​version_converter/​__init__.py Preserves function source versions before inlining and updates ModelProto imports.
docs/​api/​version_converter.md Documents supported conversions, semantic preservation, and failure behavior.

Review effort: Balanced

# The inliner requires identical imports. Preserve the actual source
# versions on nodes so adapters still run after attribute resolution.
preserve_versions(function, version)
_version_converter._set_onnx_opset_version(function, source_version)
Base automatically changed from justinchuby-latest-onnx-support to main November 4, 2026 03:37
Justin Chu (justinchuby) added a commit that referenced this pull request Nov 4, 2026
## Summary

- Generate the opset 28 API and expose standard opsets 24–28 at the
package root. Keep unreleased opset 29 excluded.
- Refresh opset 25 to include Attention's sliding-window attributes.
- Add FLOAT6E2M3/FLOAT6E3M2 annotations and export all existing low-bit
dtype annotations.
- Require onnx_ir 1.1.0, which introduced float6 support and
transitively requires ml_dtypes 0.5.0 or later; align the CI ONNX IR
pin.
- Preserve ONNX 1.17 compatibility by filtering schema type strings
against installed ONNX enums and resolving annotation names through IR.
- Document the supported APIs, dtype requirements, and API generation
command excluding opset 29.

## Stack

Registered as a native GitHub stack in this order:

1. This PR: APIs, dtypes, documentation, and dependencies; targets
`main`.
2. [#3139](#3139):
version-converter implementation, documentation, and regression
coverage; targets this PR's branch.

This PR's diff contains no version-converter changes. The combined stack
preserves the complete implementation from before the split.

## CI follow-up

- Split SwiGLU coverage from the SpaceToDepth mode-attribute check. The
pinned ONNX weekly build reports opset 28 but predates that attribute,
so its availability is now checked against the actual installed schema.
SwiGLU coverage still runs.
- Classify backend roundtrips with Optional graph inputs/outputs as
unsupported by the scripting frontend, matching its existing annotation
limitations. This does not add Optional-I/O frontend support or disable
tests based on the presence of Optional operators alone.
- The Phi export schema-revision regression is fixed in the converter
layer, #3139. Inspected failed stable/nightly job logs contain no native
ORT crash signatures; no ORT patch is justified by that evidence.

## Validation

- Exact pinned CI ONNX weekly 1.23.0.dev20260831: complete backend
roundtrip, API, and dtype suites **1104 passed, 760 skipped, no
failures**, with only the blanket Windows backend skip removed to
exercise Linux-like coverage. Existing unsupported frontend/runtime
cases remain skipped; the unavailable SpaceToDepth mode check skips
independently.
- Current ONNX 1.24 API suite: **7 passed**, including the SpaceToDepth
mode check.
- Earlier independent bottom-layer integration across
scripting/builders, IR schemas, tensors, API/dtype exports, and the
unchanged converter suite: **295 passed, 1 skipped, 7 existing xfails**.
- Every concrete IR dtype has a public annotation; numeric storage
roundtrips include float6 and other low-bit types. API/dtype
compatibility was also covered by earlier integration runs on current
ONNX and minimum ONNX 1.17.
- `lintrunner -a` and `git diff --check` pass. Local ORT 1.31.1 is newer
than the CI runtime pins; fresh hosted CI remains authoritative for
those versions.

---------

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Restore the version-converter slice as the upper layer above #3138, preserving the original combined tree.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Distinguish per-node operator schema revisions from imported source opsets. Verify schema identity at opset 18 before allowing older explicit revisions, preserving rejection of unsupported imports and changed legacy schemas. This fixes Phi export through torch.onnx without bypassing semantic validation.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@justinchuby
Justin Chu (justinchuby) force-pushed the justinchuby-opset-converter-completion branch from 6ad75b3 to 96d98ba Compare November 4, 2026 03:37
_set_onnx_opset_version(graph_or_function, self._target_version)

def _check_node_version(self, node: ir.Node, source_version: int) -> None:
if 0 < source_version < SUPPORTED_MIN_ONNX_OPSET:

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Does this also mean we need the latest onnx version always? Otherwise the op is not defined.

Avoid repeated ONNX schema lookups for identical operator/version pairs on large graphs while preserving incompatible-schema errors and per-conversion isolation.

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

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

Development

Successfully merging this pull request may close these issues.

2 participants