pnnx
pnnx is an open standard for PyTorch model interoperability.
What it is and what it does
PNNX is a Python wrapper around an open standard for PyTorch model interoperability. It takes trained PyTorch models and exports them to PNNX format, which generates multiple output artifacts: a graph definition file, model weights, and Python inference code. The package can also convert existing TorchScript models to PNNX. The main use case is preparing PyTorch models for deployment or cross-framework use by optimizing the computation graph and making the model portable across different inference engines.
The package depends only on torch and provides two main functions: export (which traces a model and converts it to PNNX) and convert (which transforms an already-saved TorchScript model). It supports custom operators, module preservation, and multiple optimization levels. The fact sheet shows it is actively maintained, has no known vulnerabilities, and runs on modern Python versions across major platforms via pre-built wheels.
Use it for:
- Export a trained PyTorch model to PNNX format for deployment on inference engines.
- Convert a PyTorch model to alternative formats via the PNNX intermediate representation.
- Optimize a model graph for inference by applying graph-level optimizations during export.
- Generate portable Python inference code alongside model weights for reproducible model loading.
- Handle models with dynamic input shapes by specifying alternative input shapes during export.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Exports and converts PyTorch neural network models to PNNX format, an open standard for model interoperability that generates optimized graph definitions, weights, and inference code.
Yes, if you need to export PyTorch models to PNNX format for deployment or cross-framework use. The package is actively maintained, has no security issues, and provides pre-built wheels for common platforms. Install friction is moderate due to the torch dependency, but that is expected for a PyTorch model tool. Not necessary if you only work within PyTorch's native ecosystem.
Install
pnnx on PyPI
pip
pip install pnnxuv
uv add pnnxpoetry
poetry add pnnxInstalling pnnx
Before you install
Medium install friction due to torch dependency and platform-specific wheels. The package is actively maintained with recent releases and no known vulnerabilities. Supports Python 3.7 through 3.11 across macOS, Linux, and Windows.
License in practice
BSD-3 is permissive, allowing commercial and private use with minimal restrictions. You must include the license text in distributions but face no copyleft obligations.
Quickstart
pip install pnnx
import torch
import pnnx
net = torch.nn.Linear(10, 2)
x = torch.rand(1, 10)
opt_net = pnnx.export(net, "model.pt", x)
Requires torch to be installed; building from source requires C++14 compiler support and CMake >= 3.4.
Verify before relying
- Whether pnnx2onnx and torchvision integration are enabled by default or require manual environment variable setup.
- Performance characteristics and optimization level differences for typical model sizes.
- Compatibility with dynamic shapes and practical limits of input_shapes2 resolution.
Package facts
| License | BSD-3 (permissive) |
| Python support | supports the current Python release (>=3.7) |
| Install friction | medium — platform-specific wheel |
| Runtime dependencies | 1 — torch |
| Maintenance | actively maintained — 80 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 227,549/month — #9,175 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: pnnx-20260526-py3-none-macosx_10_9_universal2.macosx_10_9_x86_64.macosx_11_0_arm64.whl; pnnx-20260526-py3-none-manylinux2014_aarch64.manylinux_2_17_aarch64.whl; pnnx-20260526-py3-none-manylinux2014_x86_64.manylinux_2_17_x86_64.whl; pnnx-20260526-py3-none-win_amd64.whl
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
onnx2torchConverts ONNX models to PyTorch modules with a…
permissive · top 15,000 on PyPI
litert-torchConverts PyTorch models to .tflite format for…
permissive · top 15,000 on PyPI
onnx2tfConverts ONNX model files to LiteRT,…
permissive · top 5,000 on PyPI
ncnnncnn is a neural network inference framework…
permissive · top 15,000 on PyPI
torch-geometricPyTorch Geometric is a library for building and…
permissive · top 5,000 on PyPI
torchvisionTorchvision provides pre-built datasets, model…
permissive · top 1,000 on PyPI
netronNetron is a viewer for neural network and…
permissive · top 15,000 on PyPI
torchPyTorch provides GPU-accelerated tensor…
permissive · top 1,000 on PyPI
timmTimm provides a large collection of pretrained…
permissive · top 5,000 on PyPI