Repository navigation
Complete native ONNX opset conversion through 28 - #3139
Justin Chu (justinchuby) wants to merge 12 commits into
Conversation
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 Report❌ Patch coverage is 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. |
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>
There was a problem hiding this comment.
🟡 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) |
## 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>
6ad75b3 to
96d98ba
Compare
…uby-opset-converter-completion
| _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: |
There was a problem hiding this comment.
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>

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, notmain.Changes
Restore only the five version-converter paths from immutable source commit
dcc945413b0094cebd2039c5e7eb4652205c8c98; this is a split of existing work, not a redesign.Validation
lintrunner -a: no lint issues.git diff --exit-code dcc945413b0094cebd2039c5e7eb4652205c8c98 HEAD --passes.Neither layer is merged; native stack registration is left to the coordinating session.