Skip to main content
The ORT format is an optimized binary format for ONNX models designed for efficient deployment and faster loading times.

Overview

ORT format models are serialized using FlatBuffers, providing:
  • Faster loading: Zero-copy deserialization for instant model loading
  • Smaller file size: Optimized binary representation
  • Runtime optimizations: Pre-applied graph optimizations are preserved
  • Execution provider support: EP-specific optimizations can be saved

Converting to ORT Format

Using Python

Convert ONNX models to ORT format using the Python API:

Using onnxruntime.tools.convert_onnx_models_to_ort

Conversion Options

ORT Format Versions

The ORT format has evolved across ONNX Runtime versions:

Version 6 (Current)

  • Support for Float8 types (E4M3FN, E5M2)
  • Enhanced type system for quantization

Version 5

  • Removed kernel def hashes
  • Added KernelTypeStrResolver for EP support
  • Enables additional execution providers in minimal builds

Version 4

  • Updated kernel def hashing (not backwards compatible)

Version 3

  • Added graph_doc_string field support

Version 2

  • Sparse initializers support

Version 1

  • Initial FlatBuffers implementation
  • Basic model, graph, and operator support

Backwards Compatibility

ONNX Runtime 1.14+

  • Full builds: Can load older ORT format models (v1-v4), but saved optimizations are ignored
  • Minimal builds: Cannot load models older than version 5

Upgrading Old Models

To upgrade an older ORT format model:
Note: Saved runtime optimizations from older models will be ignored during upgrade.

Using ORT Format Models

Loading ORT Models

C++ Example

JavaScript/WebAssembly

Minimal Builds

ORT format is essential for minimal builds:

Graph Optimizations

Optimization Levels

  • disabled: No optimizations
  • basic: Constant folding, redundant node elimination
  • extended: Advanced optimizations like operator fusion
  • layout: Layout transformations for hardware efficiency
  • all: All available optimizations

Preserving Optimizations

File Structure

ORT format files use FlatBuffers schema with:
  • Model metadata: Version, producer, domain
  • Graph: Nodes, initializers, inputs/outputs
  • Operator kernels: Kernel type resolvers for execution providers
  • Runtime optimizations: Pre-computed graph transformations

Best Practices

When to Use ORT Format

Use ORT format when:
  • Deploying to production environments
  • Using minimal builds
  • Loading time is critical
  • You want to preserve runtime optimizations
Use ONNX format when:
  • Still in development/experimentation
  • Need cross-framework compatibility
  • Debugging models with visualization tools

Optimization Workflow

  1. Develop with ONNX format
  2. Optimize and convert to ORT format
  3. Test the ORT model thoroughly
  4. Deploy the ORT format model

Security Considerations

Performance Benefits

Load Time Comparison

Memory Usage

  • Zero-copy deserialization reduces memory overhead
  • Immediate access to model data without parsing

Troubleshooting

Version Mismatch Errors

If you encounter version errors:
Re-convert the model with your current ONNX Runtime version.

Missing Operators

For minimal builds, ensure all required operators are included:

Resources