Update ML.NET's ONNX exporter to target the latest released ONNX specification:
- ONNX version: 1.22
- Core
ai.onnx opset: 27
ai.onnx.ml opset: 5
- ONNX Runtime: 1.29
ML.NET currently targets core opset 12 and ai.onnx.ml opset 2. Maintaining these old targets limits future exporter development and leaves several emitted graphs using obsolete operator schemas.
Motivation
The latest released opsets should be ML.NET's primary export target. Compatibility with older runtimes should not prevent the exporter from tracking the maintained ONNX specification.
Moving to the current opsets will:
- Allow new exporters to use modern ONNX operators and data types.
- Enable standard bitwise and string operators where suitable.
- Enable the newer
TreeEnsemble representation.
- Allow tree thresholds and weights to retain double precision through tensor attributes.
- Align exported models with a currently maintained ONNX Runtime release.
- Remove accumulated schema and domain-import debt.
This intentionally raises the runtime requirement for newly exported models. Existing ONNX files and ML.NET's ability to consume older models are unaffected.
Required changes
Update versions and dependencies
- Change the default core opset from 12 to 27.
- Change the
ai.onnx.ml opset from 2 to 5.
- Upgrade
Microsoft.ML.OnnxRuntime to 1.29.
- Refresh the generated ONNX protobuf bindings from ONNX 1.22.
- Update the emitted IR version as required by the features used.
- Update public documentation and validation of supported target versions.
Emit current core operator schemas
Update operators whose signatures changed after opset 12:
- Emit
axes as an int64 tensor input for Squeeze, Unsqueeze, and ReduceSum.
- Emit
axes as an input for the remaining Reduce* operators changed in opset 18.
- Emit
Clip bounds as inputs rather than attributes.
- Review every emitted core operator against its opset-27 schema.
- Preserve ML.NET inference behaviour and output shapes.
There are currently more than twenty axes attributes across the exporter which require review.
Migrate tree exports
TreeEnsembleRegressor and TreeEnsembleClassifier are deprecated in ai.onnx.ml opset 5 and are rejected by the official ONNX checker.
- Replace the existing tree representation with
TreeEnsemble.
- Reconstruct classification labels and scores where necessary.
- Use tensor-valued splits and weights to avoid unnecessary float conversion.
- Preserve missing-value routing and post-transform behaviour.
- Cover FastTree, FastForest, LightGBM, ranking, regression, and classification exports.
Correct operator-domain imports
ML.NET emits operators from the com.microsoft domain for tokenisation, hashing, and some trainer graphs, but currently writes only the core and ai.onnx.ml imports.
- Track every operator domain used by a graph.
- Emit a corresponding
opset_import entry for each domain.
- Add
com.microsoft version 1 when required.
- Avoid importing unused domains where practical.
Compatibility
Newly exported models will require a runtime supporting core opset 27 and ai.onnx.ml opset 5. ONNX Runtime 1.29 is the corresponding current release.
Support for producing older opsets may remain available where it is correct and maintainable, but it must not constrain or delay the current default exporter.
Acceptance criteria
Non-goals
- Targeting unreleased core opset 28.
- Automatically rewriting ONNX files previously exported by ML.NET.
- Implementing every operator introduced between opsets 12 and 27.
References
Update ML.NET's ONNX exporter to target the latest released ONNX specification:
ai.onnxopset: 27ai.onnx.mlopset: 5ML.NET currently targets core opset 12 and
ai.onnx.mlopset 2. Maintaining these old targets limits future exporter development and leaves several emitted graphs using obsolete operator schemas.Motivation
The latest released opsets should be ML.NET's primary export target. Compatibility with older runtimes should not prevent the exporter from tracking the maintained ONNX specification.
Moving to the current opsets will:
TreeEnsemblerepresentation.This intentionally raises the runtime requirement for newly exported models. Existing ONNX files and ML.NET's ability to consume older models are unaffected.
Required changes
Update versions and dependencies
ai.onnx.mlopset from 2 to 5.Microsoft.ML.OnnxRuntimeto 1.29.Emit current core operator schemas
Update operators whose signatures changed after opset 12:
axesas anint64tensor input forSqueeze,Unsqueeze, andReduceSum.axesas an input for the remainingReduce*operators changed in opset 18.Clipbounds as inputs rather than attributes.There are currently more than twenty
axesattributes across the exporter which require review.Migrate tree exports
TreeEnsembleRegressorandTreeEnsembleClassifierare deprecated inai.onnx.mlopset 5 and are rejected by the official ONNX checker.TreeEnsemble.Correct operator-domain imports
ML.NET emits operators from the
com.microsoftdomain for tokenisation, hashing, and some trainer graphs, but currently writes only the core andai.onnx.mlimports.opset_importentry for each domain.com.microsoftversion 1 when required.Compatibility
Newly exported models will require a runtime supporting core opset 27 and
ai.onnx.mlopset 5. ONNX Runtime 1.29 is the corresponding current release.Support for producing older opsets may remain available where it is correct and maintainable, but it must not constrain or delay the current default exporter.
Acceptance criteria
ai.onnx.mlopset 5.TreeEnsembleoperator.opset_importentry.Non-goals
References
ai.onnx.mloperator changelog