onnx-graphsurgeon
ONNX GraphSurgeon
Decision gist · record as of 2026-08-14
Yes. The package is actively maintained, has no known vulnerabilities, installs with minimal friction, and solves a real problem for anyone working with ONNX models programmatically. The permissive Apache 2.0 license poses no restrictions. Install it if you need to create or modify ONNX graphs in code.AI-flagged interpretation of the facts on this page — verify before relying
Before you install
- Installation is straightforward with low friction; the package is a pure Python wheel with only three runtime dependencies (numpy, onnx, ml-dtypes).
- The project shows active maintenance with a recent release and steady repository activity.
License · maintenance · safety
Apache 2.0 (permissive) — Apache 2.0 is a permissive license, allowing you to use, modify, and distribute the package freely in both open-source and commercial projects, provided you include a copy of the license and state any significant changes.
last release 2026-04-08 (128 days) · last repo commit 2026-08-04 · 13,250 stars
0 known vulnerabilities (OSV.dev, 2026-08-14) · 751,950 downloads/mo, #5,155 on PyPI
Alternatives
Verify before relying
import onnx_graphsurgeon as gs
import onnx
# Load an ONNX model
graph = gs.import_onnx(onnx.load("model.onnx"))
# Modify the graph (e.g., cleanup unused nodes)
graph.cleanup()
# Export back to ONNX
onnx.save(gs.export_onnx(graph), "modified_model.onnx")- Whether the package supports all ONNX operator types and opset versions
- Performance characteristics when working with very large models
- Whether external data handling works seamlessly with all model types
What it is and what it does
ONNX GraphSurgeon is a Python library for creating and modifying ONNX neural network models. It provides an intermediate representation (IR) layer that abstracts away ONNX's low-level details, letting you work with graphs, nodes, and tensors as Python objects. You can import ONNX models, manipulate their structure by adding, removing, or rewiring nodes and tensors, and export the result back to ONNX format.
The library is organized around three main components: importers (to load ONNX models into the IR), the IR itself (where all modifications happen), and exporters (to write modified graphs back to ONNX). It handles both in-memory models and models with externally stored data. Common operations include topological sorting, cleanup of unused nodes, and direct manipulation of tensor values and node attributes.
Use it for
- Remove unused layers or nodes from ONNX models before deployment to reduce size
- Programmatically build custom ONNX models from scratch without writing raw protobuf
- Debug and visualize neural network graphs by inspecting nodes, tensors, and their connections
- Adapt models by inserting, removing, or rewiring layers for transfer learning workflows
- Automate model transformations as part of a model compilation or optimization pipeline
Worth the install?
AI-flagged interpretation of the facts on this page. Verify before relying on it.
Yes.
The package is actively maintained, has no known vulnerabilities, installs with minimal friction, and solves a real problem for anyone working with ONNX models programmatically. The permissive Apache 2.0 license poses no restrictions. Install it if you need to create or modify ONNX graphs in code.
Install
onnx-graphsurgeon on PyPI
Before you install
Installation is straightforward with low friction; the package is a pure Python wheel with only three runtime dependencies (numpy, onnx, ml-dtypes). The project shows active maintenance with a recent release and steady repository activity.
License in practice
Apache 2.0 is a permissive license, allowing you to use, modify, and distribute the package freely in both open-source and commercial projects, provided you include a copy of the license and state any significant changes.
Quickstart
import onnx_graphsurgeon as gs
import onnx
# Load an ONNX model
graph = gs.import_onnx(onnx.load("model.onnx"))
# Modify the graph (e.g., cleanup unused nodes)
graph.cleanup()
# Export back to ONNX
onnx.save(gs.export_onnx(graph), "modified_model.onnx")
Verify before relying
- Whether the package supports all ONNX operator types and opset versions
- Performance characteristics when working with very large models
- Whether external data handling works seamlessly with all model types
Package facts
| License | Apache 2.0 permissive |
| Python support | Not specified |
| Install friction | Low. Pure-Python wheel |
| Runtime dependencies | 3 packagesml-dtypesnumpyonnx |
| Maintenance | Actively maintained 128 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 751,950 / month, #5,155 on PyPI 30-day window, as of 2026-08-14 |
| Known vulnerabilities | None known OSV.dev, checked 2026-08-14 |
| Classifiers | Intended Audience :: DevelopersProgramming Language :: Python :: 3 |
Evidence: onnx_graphsurgeon-0.6.1-py2.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 › “neural network model manipulation”
- onnx-graphsurgeonONNX GraphSurgeon lets you programmatically create and modify ONNX…
- equinoxEquinox provides neural network and model building on top of JAX with…
- snc4onnxMerges multiple ONNX neural network models into a single combined…
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 onnx-ir · snd4onnx · soa4onnx · onnxsim · sor4onnx · sog4onnx · tf2onnx · onnx2torch · onnxscript · cotengra