torch-abi-audit¶
A small tool to audit compiled Python extension modules for compliance with
the PyTorch Stable ABI (PyTorch 2.9+)
— the aoti_torch_* C shim plus torch::stable::* / torch::headeronly::*
C++ wrappers that let custom PyTorch extensions survive PyTorch upgrades.
As a side benefit, the same symbol-table walk also reports compliance with the CPython Stable ABI (PEP 384) — the "limited API" that lets a single wheel work across CPython versions.
Status of the PyTorch ecosystem¶
A snapshot of where things stand as of May 2026. These are illustrative examples — not an exhaustive list — and more projects are being ported all the time, so this may be out of date by the time you read it.
Migration completed:
In progress:
Gaps in the stable surface still get filled in as downstream projects hit them, so the list of "completed" packages will keep growing.
Resources¶
- PyTorch docs — LibTorch Stable ABI (canonical reference, three-layer breakdown).
- PyTorch Conference Europe 2026 — How to write C++ extensions in 2026, Jane Xu & Mikayla Gawarecki (Meta): schedule entry · slides (PDF)
- Plans — LibTorch ABI Stable Plans 2026 on dev-discuss.
Why¶
CPython's stable-ABI ecosystem has abi3audit
for compliance checking. The PyTorch side is brand new and there's no
equivalent yet — this fills that gap, and handles both checks in one pass.
Install¶
Linux and macOS only. Windows support requires a dumpbin-based backend that
isn't implemented yet.
Quick tour¶
# Inspect a single installed package by import name
torch-abi-audit torchaudio
# Or by path to its install directory or a single .so
torch-abi-audit /path/to/site-packages/torchaudio
# Whole-environment scan (active interpreter)
torch-abi-audit --env
# Specific site-packages directory + JSON
torch-abi-audit --site-packages /opt/venv/lib/python3.12/site-packages --json
The verdict types come straight from the symbol table: a torch-using library
is reported as STABLE only if it links exclusively against the documented
stable surface, and as UNSTABLE if any c10::*, at::*, or non-stable
torch::* symbol is referenced.
How it works¶
- Walk the target directory and collect every
.so/.pyd/.dylib. Bucket each by whether it defines aPyInit_*symbol — Python extension modules go underextensions, internal bundled libraries (e.g.torch/lib/libtorch_python.so, or torchaudio's stable plugins loaded viaSTABLE_TORCH_LIBRARY) go underbundled_libs. Both buckets count toward the PyTorch verdict; onlyextensionscount toward the CPython ABI verdict. - Run
nm -uD(Linux) ornm -u(macOS) to extract undefined symbols. - Demangle C++ names via pycxxfilt.
- Classify each symbol against two rule sets — the CPython stable-ABI symbol set from abi3info and the PyTorch stable namespace regexes.
- Roll up per-library verdicts to a per-package and per-environment view.