onnxscript
Naturally author ONNX functions and models using a subset of Python
Decision gist · record as of 2026-08-14
Yes. Active maintenance, low install friction, permissive MIT license, and no known vulnerabilities make this a safe choice. Install if you author or optimize ONNX models and want to work in Python syntax rather than protobuf. The eager-mode debugger is a real productivity gain for model development, though not for production inference.AI-flagged interpretation of the facts on this page — verify before relying
Before you install
- Low friction: pure Python wheel with six runtime dependencies (numpy, onnx, packaging, and type-support libraries).
- Active maintenance with recent releases and 451 repository stars.
License · maintenance · safety
permissive license (permissive) — MIT license permits unrestricted use, modification, and distribution in both open-source and commercial projects.
last release 2026-06-29 (46 days) · last repo commit 2026-08-14 · 451 stars
0 known vulnerabilities (OSV.dev, 2026-08-14) · 3,553,221 downloads/mo, #2,579 on PyPI
Alternatives
Verify before relying
pip install onnxscript
from onnxscript import script, opset15 as op
@script()
def my_function(X):
return op.MatMul(X, X)
onnx_model = my_function.to_model_proto()- Whether the eager-mode runtime performance is suitable for your debugging workflow (docs note it is not optimized for speed).
- Exact scope of Python language subset supported beyond the examples shown.
What it is and what it does
ONNX Script is a Python-to-ONNX compiler that lets you define ONNX functions and models using Python syntax decorated with the @script decorator. The decorator parses your Python code, traverses its abstract syntax tree, and builds an equivalent ONNX graph that can be saved and validated. It supports a subset of Python—not the full language—and includes eager-mode evaluation for debugging, where functions execute using ONNX Runtime as a shim to test intermediate results.
Beyond compilation, the package provides an ONNX Optimizer (constant folding, dead code elimination) and an ONNX Rewriter (pattern-based graph transformation using user-defined rules). The rewriter allows you to match subgraph patterns and replace them with optimized alternatives. All of this is built on top of onnx and onnx_ir, with support for modern Python versions (3.9 through 3.14).
Use it for
- Author ONNX functions in readable Python instead of manually constructing protobuf graphs.
- Debug ONNX model logic by running functions in eager mode to inspect intermediate tensor values.
- Optimize ONNX models by applying constant folding and dead code elimination automatically.
- Rewrite ONNX graph patterns (e.g., replace a custom Erf-based GELU with a native Gelu operator).
- Round-trip between Python ONNX Script and ONNX graphs for model inspection and modification.
Worth the install?
AI-flagged interpretation of the facts on this page. Verify before relying on it.
Yes.
Active maintenance, low install friction, permissive MIT license, and no known vulnerabilities make this a safe choice. Install if you author or optimize ONNX models and want to work in Python syntax rather than protobuf. The eager-mode debugger is a real productivity gain for model development, though not for production inference.
Install
onnxscript on PyPI
Before you install
Low friction: pure Python wheel with six runtime dependencies (numpy, onnx, packaging, and type-support libraries). Active maintenance with recent releases and 451 repository stars.
License in practice
MIT license permits unrestricted use, modification, and distribution in both open-source and commercial projects.
Quickstart
pip install onnxscript
from onnxscript import script, opset15 as op
@script()
def my_function(X):
return op.MatMul(X, X)
onnx_model = my_function.to_model_proto()
Verify before relying
- Whether the eager-mode runtime performance is suitable for your debugging workflow (docs note it is not optimized for speed).
- Exact scope of Python language subset supported beyond the examples shown.
Package facts
| License | permissive license permissive |
| Python support | Supports the current Python release >=3.9 |
| Install friction | Low. Pure-Python wheel |
| Runtime dependencies | 6 packagesml_dtypesnumpyonnx_ironnxpackagingtyping_extensions |
| Maintenance | Actively maintained 46 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 3,553,221 / month, #2,579 on PyPI 30-day window, as of 2026-08-14 |
| Known vulnerabilities | None known OSV.dev, checked 2026-08-14 |
| Classifiers | Development Status :: 4 - BetaEnvironment :: ConsoleIntended Audience :: DevelopersLicense :: OSI Approved :: MIT LicenseOperating System :: MacOS :: MacOS XOperating System :: Microsoft :: WindowsOperating System :: POSIXProgramming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.14Programming Language :: Python :: 3.9 |
Evidence: onnxscript-0.7.1-py3-none-any.whl
Tags
Let your AI agent find packages like this
Example. Real query, live index.
You found this page by searching. An agent finds it by wishing: SkillFed indexes 14,416 PyPI packages by what they can do, searchable in plain language.
wish › “write onnx in python”
- onnxscriptWrite ONNX functions and models in Python syntax, then convert them…
- sod4onnxsod4onnx removes specified output operations from ONNX model files,…
- onnx-graphsurgeonONNX GraphSurgeon lets you programmatically create and modify ONNX…
Give your agent the search over MCP, or paste the wish link into any chat.
More Artificial Intelligence packages
LiteLLM provides a unified Python interface to call 100+ LLM providers (OpenAI, Anthropic, Gemini, Bedrock, Azure, and others) using OpenAI-compatible API format, available as both a Python SDK and a self-hosted AI Gateway proxy server.
Install it if you need to work with multiple LLM providers or want to centralize LLM routing in your organization.
Client library and CLI tool for downloading, uploading, and managing models, datasets, and repositories on the Hugging Face Hub platform.
Install it if you work with Hugging Face Hub models or datasets.
LangChain provides a framework for building agents and LLM-powered applications by composing language models, tools, and memory through a unified API that abstracts over multiple model providers.
hf-xet provides chunk-based deduplication and efficient file transfer for the Hugging Face Hub, enabling faster uploads and downloads of large files with local disk caching.
Tokenizers converts raw text into token sequences for NLP models, with support for training custom vocabularies and using pre-built tokenizers (BPE, WordPiece) optimized for speed via Rust.
Transformers provides a unified framework for loading, fine-tuning, and running state-of-the-art pretrained models across text, vision, audio, video, and multimodal tasks using PyTorch, JAX, or TensorFlow.
Install it if you need to run or train any transformer-based model for NLP, vision, audio, or multimodal tasks.
See also sam4onnx · onnxoptimizer · onnxsim · onnx-ir · sog4onnx · onnx-graphsurgeon · sna4onnx · sng4onnx · soa4onnx · onnx2torch