Skip to main content

uairt (Python)

A ctypes binding for the Unified AI Runtime C API. Pure Python plus NumPy; no compiler is needed to install it, but it needs the shared library libuairt.

From a wheel (once published; see docs/releasing.md), which carries the native library and the ONNX Runtime plugin, so nothing else is built:

pip install "uairt[onnxruntime]"

From source, for development:

cmake -S ../.. -B ../../build-shared -DBUILD_SHARED_LIBS=ON && cmake --build ../../build-shared
export UAIRT_LIBRARY=$PWD/../../build-shared/libuairt.dylib      # .so on Linux
pip install -e .
import numpy as np
import uairt

uairt.load_backend_library("libuairt_backend_onnxruntime.so")   # a plugin per backend
with uairt.Engine("onnxruntime", intra_op_threads=1) as engine:
    with engine.load_model("model.onnx") as model:
        print(model.inputs, model.outputs)          # TensorInfo(name, dtype, shape, quant_scale, ...)
        x = np.zeros(model.inputs[0].shape, model.inputs[0].dtype)
        (y,) = model.run(x)

AutoModel and plugin discovery

AutoModel picks the backend from the model file and the device, so you do not need to know which plugin or which options a runtime takes. It is a thin layer over Engine and Model, which stay available.

import uairt

with uairt.AutoModel.from_file("yolov8n.onnx", device="gpu") as model:
    print(model.backend, model.options)        # onnxruntime {'execution_provider': 'cuda'}
    (y,) = model.run(x)

uairt.AutoModel.from_file("face_det.dlc", device="npu")                  # qnn
uairt.AutoModel.from_file("yolov8n_ncnn_model", device="gpu", input_shapes="3x640x640")   # ncnn on Vulkan
uairt.AutoModel.resolve("m.onnx", device="gpu")                           # the plan only, nothing loaded
  • Backend by file: .dlc and .bin go to qnn, .onnx to onnxruntime (then openvino), .xml to openvino, .param to ncnn, .engine and .plan to tensorrt, .tflite to tflite, .mlmodelc, .mlpackage and .mlmodel to coreml. A directory is judged by what it holds (an ultralytics _openvino_model or _ncnn_model export). Pass backend= to choose.
  • Device: cpu, gpu, npu, cuda, tensorrt or vulkan, with an optional index (gpu:1), or None for the backend's default. It is mapped to that backend's own options (device=npu for QNN, execution_provider=cuda for ONNX Runtime, device=GPU for OpenVINO, device=vulkan for NCNN, and so on). QNN's default is npu.
  • Strict: the first candidate that is available (registered, or with a plugin that can be found) and supports the device is used. If it fails to load, that error is raised: there is no fallback to another runtime or to the CPU. A device a backend cannot serve raises Unsupported; no usable plugin raises NotFound. Both say why each candidate was passed over. model.plan.skipped lists the candidates passed over.
  • Options: keyword arguments and options={...} go to the backend and override the device mapping.

Backend plugins are found, and loaded when an engine asks for them, in this order: UAIRT_PLUGIN_PATH (directories separated like PATH), the package's own plugins/ directory, the directory of the loaded libuairt, and its uairt/ subdirectory. A plugin is a file named libuairt_backend_<name>.so, .dylib or .dll. uairt.load_backend_library(path) still loads one by path, and uairt.available_backends() and uairt.discover_plugins() show what is registered and what was found. A plugin still needs its vendor runtime installed; loading it reports that.

examples/auto_model.py loads any model this way and prints what was chosen.

  • Inputs must match the model's dtype and shape exactly; the binding never converts silently.
  • Errors are uairt.UairtError subclasses (NotFound, Unsupported, IncompatibleModel, IoFailure, ...) carrying .status and .message.
  • Engine.alloc_buffer(n, "host" | "dmabuf" | "pinned") and Model.run_buffers give zero-copy buffers; Buffer.array(dtype, shape) is a NumPy view.
  • Models and buffers keep their engine alive. Close models before buffers they used.
  • Threading follows the C API: do not run one model from several threads at once.

Tests: UAIRT_LIBRARY=... pytest bindings/python/tests. Set UAIRT_TEST_ORT_PLUGIN to the ONNX Runtime plugin to also run the two-input/two-output test.

Windows ARM64: use an ARM64 Python (an x64 Python cannot load the ARM64 uairt.dll), build libuairt as a DLL and set UAIRT_LIBRARY to build-shared\Debug\uairt.dll. examples/run_qnn.py <plugin> <QAIRT root> <model.dlc> [npu|cpu|gpu] runs a model through the QNN plugin (0.8 ms on the Snapdragon X Elite NPU for face_det_lite). Set ADSP_LIBRARY_PATH to <QAIRT root>\lib\hexagon-v73\unsigned before starting Python for npu; see the Rust README for the caveat.

Metadata

Release files for uairt 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for uairt 0.1.0
File Size Uploaded
uairt-0.1.0.tar.gz 113.4 kB Details

Built distributions (wheels)

Table of built distributions (wheels) for uairt 0.1.0
File
uairt-0.1.0-py3-none-win_amd64.whl Python 3 none Windows x86-64 Details
uairt-0.1.0-py3-none-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl Python 3 none Linux glibc 2.17+ ARM64, Linux glibc 2.28+ ARM64 Details
uairt-0.1.0-py3-none-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl Python 3 none Linux glibc 2.5+ x86-64, Linux glibc 2.28+ x86-64 Details
uairt-0.1.0-py3-none-macosx_11_0_arm64.whl Python 3 none macOS 11.0+ ARM64 Details

Total release size: 255.2 kB

Release files / uairt-0.1.0.tar.gz

Download URL uairt-0.1.0.tar.gz
Size 113.4 kB
Tags Source
SHA-256 checksum
How to use checksums
7ec67dfbf2b1f5d3d2e82c51d0675975a0ce7f980f427583db4951f955e3cd95
BLAKE2b-256 checksum
How to use checksums
6ef6c700d99042a23ea6233c0fb25e8a3f86278cc2423506b089344c6986cf23
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 5, 2026.

Transparency log

Release files / uairt-0.1.0-py3-none-win_amd64.whl

Download URL uairt-0.1.0-py3-none-win_amd64.whl
Size 39.2 kB
Tags Python 3 Windows x86-64
SHA-256 checksum
How to use checksums
3a67153ab4a516d4ace35c0d547dab3a7fad9f742da825464be877251b39a7bd
BLAKE2b-256 checksum
How to use checksums
2a1a5457751ea78af67f6854579a751d91278bedd8d5f96be2335202b809eb25
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 5, 2026.

Transparency log

Release files / uairt-0.1.0-py3-none-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl

Download URL uairt-0.1.0-py3-none-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl
Size 35.8 kB
Tags Linux glibc 2.17+ ARM64 Linux glibc 2.28+ ARM64 Python 3
SHA-256 checksum
How to use checksums
245266f39aed6be4def52784307c39462fd1a1403fece35551ed757d832493fa
BLAKE2b-256 checksum
How to use checksums
0f997cf8088ca5940934936e918d1867faf4e1f33f8c166f0b5856efcebb45fe
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 5, 2026.

Transparency log

Release files / uairt-0.1.0-py3-none-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl

Download URL uairt-0.1.0-py3-none-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
Size 34.9 kB
Tags Linux glibc 2.28+ x86-64 Linux glibc 2.5+ x86-64 Python 3
SHA-256 checksum
How to use checksums
4b3e38ebbfb3142ae0bb7f7f5a9eb083909cd9dc2eb4f5f8be55e2d4c51f37a3
BLAKE2b-256 checksum
How to use checksums
b997eee3855daa13ca056b8c6e362ea82d8499500b93675857387e0a93fd1277
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 5, 2026.

Transparency log

Release files / uairt-0.1.0-py3-none-macosx_11_0_arm64.whl

Download URL uairt-0.1.0-py3-none-macosx_11_0_arm64.whl
Size 31.9 kB
Tags Python 3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
710c3cf37c0781278964f080ce68d6060b759ef1136f8ef3c9ec1f8378ff1ac6
BLAKE2b-256 checksum
How to use checksums
df4fb51f6a872a91174f11ac59a252bef24175c75a3c3b734061608d61b5d724
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 5, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.1.0 This release

5 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page