Open Neural Network Exchange ONNX
A framework-neutral standard format for exporting trained neural network models, so the same model runs across inference engines, compilers and languages. It is the universal handoff format for taking physics-AI models from training into production.
What it is
ONNX is a model interchange format. You train a model in PyTorch, TensorFlow, JAX or a physics-AI framework and export it to an .onnx file. That file describes the computation graph itself - which operators exist, and each layer's input/output shapes and dtypes - rather than any framework's internal representation.
The point is to decouple training from deployment. Once exported, the inference side does not need the original training framework installed. ONNX Runtime, TensorRT, TVM and various serving stacks can all consume the same .onnx file.
Key points
- Operator coverage decides whether it works: a successful export does not mean it runs.
The ONNX operator set (opset) is versioned, and custom operators, dynamic shapes or parts of an autodiff graph in the original model may not map cleanly. An export error usually means the model uses something outside the standard operator set, not that the exporter is broken.
- Graph optimization is the entry point to inference speedup: runtimes optimize the graph on
load - constant folding, operator fusion, graph rewriting. Physics-AI models are typically full of small operators (pointwise MLPs, divergence and gradient operators), so fusion often pays off more than swapping hardware.
- Dynamic versus static shapes: a static batch and fixed mesh size export most reliably and
runs fastest; variable-resolution meshes (adaptive mesh refinement) need declared dynamic dimensions and give up some optimization opportunities.
- Physics operators must be registered yourself: custom physics-constrained layers (flux
operators, mesh interpolation) usually have to be written as custom operators and registered with the target engine, otherwise they get rejected or silently degraded.
Common pitfalls / boundaries
- ONNX is an interchange format, not an inference engine. It provides no speedup on its own;
performance comes from the runtime consuming it.
- ONNX does not solve accuracy problems. Numerical differences before and after export come from
operator implementation details and precision settings, and need separate verification.
- "Supports ONNX" does not mean "supports every ONNX operator". Coverage differs per engine, so
always run the model through the actual target engine before switching.
- Compilation-time graph optimizations in the training framework are redone after export; do not
expect the exported file to preserve them.