inisis/OnnxSlim
A Toolkit to Help Optimize Onnx Model
OnnxSlim – Fast, lightweight ONNX model slimming
What it does – OnnxSlim is a Python package that takes an existing ONNX model, removes unnecessary operators and simplifies the graph, and writes out a smaller model that runs faster while keeping the same accuracy. It is aimed at the inference side of AI/ML pipelines, especially large language models and computer‑vision models that are exported to ONNX for deployment.
Why it matters – Inference speed and memory footprint are often bottlenecks when deploying models to edge devices, GPUs, or cloud services. By reducing the number of operators and the overall graph size, OnnxSlim can cut load time and improve runtime performance without any retraining.
Installation
# From PyPI (recommended)
pip install onnxslim
# Or directly from the repo
pip install git+https://github.com/inisis/OnnxSlim@main
Basic usage Command‑line:
onnxslim input_model.onnx output_model.onnx
Python API:
import onnx, onnxslim
model = onnx.load("model.onnx")
slimmed = onnxslim.slim(model)
if slimmed:
onnx.save(slimmed, "slimmed_model.onnx")
Run onnxslim -h for all options; more examples live in the examples folder.
Key points from the README
- Claims to keep the original accuracy while reducing operator count.
- Shows a GIF of the CLI in action.
- Lists a large number of downstream projects that already integrate OnnxSlim (e.g., NVIDIA TensorRT‑Model‑Optimizer, HuggingFace optimum, Ultralytics, MNN‑LLM, transformers.js, etc.).
- Highlights community adoption: 10 M downloads as of June 2026, top‑1 % ranking on PyPI, and several competition wins.
- Provides contact channels (Discord, QQ group) for support.
Ecosystem & dependencies – OnnxSlim builds on the standard onnx library and references tools such as NVIDIA’s onnx‑graphsurgeon, Polygraphy, onnx‑simplifier, tabulate, and onnxruntime. It is therefore compatible with the broader ONNX tooling stack used for model export, optimization, and runtime.
Who might use it –
- ML engineers preparing models for deployment on GPUs, CPUs, or specialized accelerators.
- Researchers who want a quick way to benchmark inference speed improvements.
- Open‑source projects that ship ONNX models and need an extra optimization step.
Bottom line – OnnxSlim is a genuine, actively maintained utility for slimming ONNX models, positioned as a lightweight complement to larger optimization frameworks like TensorRT‑Model‑Optimizer and HuggingFace optimum.
Related
- Project
- Project