optimum-onnx
Optimum ONNX is an interface between the Hugging Face libraries and ONNX / ONNX Runtime
What it is and what it does
optimum-onnx bridges Hugging Face transformer models and the ONNX ecosystem, enabling you to export PyTorch checkpoints to ONNX format and run them via ONNX Runtime. It provides command-line tooling for export with optional graph optimization and quantization, plus Python classes that wrap ONNX Runtime to maintain a familiar Hugging Face API surface for inference.
The package targets developers who want faster or more portable inference than standard PyTorch, particularly for deployment scenarios where ONNX Runtime's performance characteristics or cross-platform support matter. It depends on transformers, optimum, and onnx, and supports Python 3.9 through 3.13. The project is actively maintained but marked Pre-Alpha, reflecting its early maturity.
Use it for:
- Export a transformer to ONNX and quantize it for faster CPU or GPU inference
- Deploy a model to environments where ONNX Runtime is preferred over PyTorch for size or performance
- Run inference on exported ONNX models using the ORTModelForXXX classes with minimal code changes
- Optimize and benchmark models in ONNX format for production serving
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Exports Hugging Face transformer models to ONNX format and runs them via ONNX Runtime for optimized inference.
Yes, if you need to export Hugging Face models to ONNX for deployment or performance optimization. The low install friction, active maintenance, permissive license, and zero known vulnerabilities make it safe to try. Pre-Alpha status means the API may shift, but the project is backed by Hugging Face and already handles real models.
Install
optimum-onnx on PyPI
pip
pip install optimum-onnxuv
uv add optimum-onnxpoetry
poetry add optimum-onnxInstalling optimum-onnx
Before you install
Low friction install with a pure Python wheel. Active maintenance with recent commits and no known vulnerabilities. Early stage (Pre-Alpha) but backed by Hugging Face infrastructure.
License in practice
Apache-2.0 permissive license allows commercial and private use with minimal restrictions.
Quickstart
pip install "optimum-onnx[onnxruntime]"
from optimum.onnxruntime import ORTModelForCausalLM
from transformers import AutoTokenizer
model = ORTModelForCausalLM.from_pretrained("onnx-community/Llama-3.2-1B", subfolder="onnx")
tokenizer = AutoTokenizer.from_pretrained("meta-llama/Llama-3.2-1B")
Requires Python 3.9 or later. GPU inference requires CUDA and cuDNN; avoid installing both onnxruntime and onnxruntime-gpu simultaneously.
Verify before relying
- Performance gains (latency, throughput, memory) compared to PyTorch inference on typical models
- Supported model architectures beyond the examples shown
- Quantization options available and their impact on model accuracy
- Compatibility with Diffusers, Timm, and Sentence Transformers models as mentioned
Package facts
| License | Apache-2.0 (permissive) |
| Python support | supports the current Python release (>=3.9.0) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 3 — optimum, transformers, onnx |
| Maintenance | actively maintained — 234 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 679,411/month — #5,369 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: optimum_onnx-0.1.0-py3-none-any.whl
Keywords: transformers, quantization, inference, onnx, onnxruntime
Tags
More Artificial Intelligence packages
LiteLLM provides a unified Python interface to…
permissive · top 100 on PyPI
huggingface-hubClient library and CLI tool for downloading,…
permissive · top 100 on PyPI
langchainLangChain provides a framework for building…
permissive · top 1,000 on PyPI
hf-xethf-xet provides chunk-based deduplication and…
permissive · top 1,000 on PyPI
tokenizersTokenizers converts raw text into token…
permissive · top 1,000 on PyPI
transformersTransformers provides a unified framework for…
permissive · top 1,000 on PyPI
optimumOptimum provides optimization tools to export…
permissive · top 5,000 on PyPI
optimum-intelOptimum Intel bridges Hugging Face Transformers…
permissive · top 15,000 on PyPI
onnxslimOnnxSlim reduces the size and operator count of…
permissive · top 5,000 on PyPI
nvidia-modeloptApplies state-of-the-art model optimization…
permissive · top 15,000 on PyPI
onnxruntime-genaiRuns small and large language models and…
permissive · top 15,000 on PyPI
skl2onnxConverts trained scikit-learn models to ONNX…
permissive · top 5,000 on PyPI
onnx-toolParse, analyze, optimize, and profile ONNX…
permissive · top 15,000 on PyPI
onnxruntime_extensionsExtends ONNX Runtime with custom operators for…
permissive · top 15,000 on PyPI
optimum-quantoA PyTorch quantization backend that reduces…
permissive · top 15,000 on PyPI
onnxruntimeonnxruntime loads and executes Open Neural…
permissive · top 1,000 on PyPI