tract

Library Listed

Tiny, no-nonsense, self contained, TensorFlow and ONNX inference

Checked · Sources

Downloads
24,404
Dependents
114
Stars
3,113
Forks
297
Contributors
107
Commits
11,096
Latest release
0.23.10 ·

About

From the project README ·

tract-logo

Sonos' neural-network inference engine.

tract loads ONNX and NNEF models, optimises them, and runs them anywhere — from embedded ARM CPUs to NVIDIA / Apple GPUs, in the browser via WebAssembly, or on a Linux / macOS / Windows workstation. It is used in production at Sonos for wake-word and streaming speech-recognition workloads, and also runs LLM, text-to-image, and classical CV models with a particular focus on the translate-once / ship-tiny-runtime story enabled by its NNEF-based intermediate format (tract-OPL).

Quick start

From examples/onnx-mobilenet-v2:

use tract::prelude::*;
tract::impl_ndarray_interop!();

let model = tract::onnx()?
    .load("mobilenetv2-7.onnx")?
    .into_model()?;

// prepare() optimises and compiles the model for the chosen runtime
let runtime = tract::runtime_for_name("default")?;
let runnable = runtime.prepare(model)?;

let result = runnable.run([input.tract()?])?;

The tract crate (api/rs/src/lib.rs) is the authoritative public API. The internal crates (tract-core, tract-nnef, tract-onnx, ...) are not stable surface and shouldn't be depended on directly.

For Python, see the tract package on PyPI.

Read the full README

Examples

examples/ has runnable demos covering the workloads tract targets today:

ExampleWhat
onnx-mobilenet-v2Minimal CV starter
tflite-mobilenet-v3TFLite import path
causal_llmTransformer text generation
nemo-parakeet-asr / nemo-nemotron-streaming-asrSpeech recognition, including streaming via pulsification
stable-diffusion / stable-diffusion-3 / stable-diffusion-xlText-to-image
face_detection_yolov8onnx_example / face_similarity_arcface_onnxModern object detection / face recognition
wasm-model-benchRunning tract in the browser

Resources

Technical documentation lives under doc/ (start at doc/intro.md); the doc/cli-recipe.md page collects practical CLI recipes. The Sonos engineering blog has a long-form post on tract internals.

Python

tract is also available as the tract package on PyPI, built on top of the same Rust core:

pip install tract

The API mirrors the Rust pipeline: load a model, set input facts, optimise, then run. Documentation: sonos.github.io/tract. Source lives in api/py/.

Runtimes

RuntimeNameCrateNotes
CPU (x86, ARMv6/7/8, ARM SVE)"default"tract-linalgDefault. Hand-rolled SIMD micro-kernels.
Apple Metal"metal"tract-metalApple GPUs.
NVIDIA CUDA"cuda"tract-cudaNVIDIA GPUs.
WebAssembly"default"via standard wasm32 targetsBrowser / WASI deployment.

All runtimes share the TypedModel IR and the same loaders, so a model optimised on one platform can be moved to another.

Benchmarks

Every night, main is benchmarked on a fleet of devices — Cortex-A7 to Cortex-A55 boards, RISC-V boards, x86 and Apple desktops, NVIDIA and Apple GPUs, and WebAssembly — over wake-word, speech recognition, speech enhancement, vision and LLM models. The bench page tracks every model on every device. A few of the trends:

ModelTargetSpeedTrend
GTCRN speech enhancementCortex-A5512.1× since Aug 2026GTCRN speech enhancement on Cortex-A55
MobileNet v2, multi-threadCortex-A533.2× since Aug 2026MobileNet v2, multi-thread on Cortex-A53
Parakeet TDT 0.6B preprocessorIntel i9-11900KB14.7× since Jun 2026Parakeet TDT 0.6B preprocessor on Intel i9-11900KB
Llama 3.2 3B text generationApple M1 Max, Metal1.8× since Apr 2025Llama 3.2 3B text generation on Apple M1 Max, Metal

Speed is relative to the first week of each series, dashed line at 1×. doc/bench/sparklines.py regenerates the charts.

Streaming and pulsification

tract has first-class support for pulsified inference: a network that operates on full sequences during training is translated into one that processes a fixed-size pulse along its streaming axis at each step. This lets the same model serve both batch evaluation and low-latency real-time inference (wake-word, streaming ASR, ...).

The translate-time logic lives in tract-pulse; runtime ships only the small tract-pulse-opl crate. See doc/overview.md § Streaming and pulsification for the engineering view, and examples/nemo-nemotron-streaming-asr for a working demo.

Formats and tract-OPL

FormatLoadSave
ONNX✓—
NNEF (+ tract-OPL extensions)✓✓
TensorFlow Lite (legacy)✓✓
TensorFlow 1 frozen graph (legacy)✓—

PyTorch models can be exported directly to NNEF using torch-to-nnef (source), an open-source PyTorch-to-NNEF converter maintained alongside tract — useful when you want to skip the detour through ONNX.

tract-OPL is an NNEF-compatible intermediate representation that extends NNEF with the operators needed to express a full tract-core model. The recommended deployment workflow is:

  1. Once, at build time: convert from ONNX / TF / TFLite to NNEF using the tract CLI:
    tract model.onnx dump --nnef model.nnef.tgz
    
  2. At runtime: ship only tract-core + tract-nnef, plus tract-onnx-opl if the model uses ONNX-only operators, and tract-pulse-opl if it is pulsified.

This keeps the runtime footprint small (no protobuf, no training-framework loaders). See doc/intro.md for the full design rationale.

tract-OPL stability

NNEF parts are tied to the NNEF specification and very stable. tract-OPL extensions are a bit more in flux, but we observe the rule:

A model serialised with tract 0.x.y should work with tract 0.x.z where z >= y.

Models embed a tract_nnef_ser_version property identifying the generating tract version; tract itself does not enforce a version check, so it is up to the application to do so if needed. See CHANGELOG.md for the running list of notable serialisation-format changes.

TensorFlow 1 (legacy)

tract still loads TF1 frozen graphs and supports the operator set needed for the classical CV and wake-word models that originally drove its design (Inception v3, Snips wake words, ...). TensorFlow 2 is not directly supported — convert to ONNX first.

License

Files in tensorflow/protos are copied from the TensorFlow project and files in onnx/protos from the ONNX project; neither is covered by the licence statement below.

Apache 2.0 / MIT

All original work is licensed under either of

  • Apache License, Version 2.0 (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
  • MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)

at your option.

Contribution

Unless you explicitly state otherwise, any Contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

Runs on
CUDA, WebGPU, Metal
What shows it
  • CUDA: tract feature cuda, tract-cuda dependency cudarc, tract-libcli feature cuda (dependency cudarc)
  • WebGPU: tract feature wgpu (dependency wgpu)
  • Metal: tract feature metal, tract-ffi feature metal, tract-libcli feature metal, tract-metal dependency metal
Native code
Build tool
  • Build uses a native toolchain: cc
Python bindings
No Python binding crate found
License
Apache-2.0 OR MIT

Compare with similar projects

Order: strongest tier first, then most downloads, then name, with unmeasured values last. A library counts downloads over 30 days. An app counts binary downloads per release. An app with none counts its crate downloads over 30 days. ML Rust runs this catalogue, so its closest project always gets a row.

tract beside the projects that share a topic with it
ProjectDownloadsDependentsStarsLatest releaseRuns on (GPU)Native codeLicense
tract This page Listed

Tiny, no-nonsense, self contained, TensorFlow and ONNX inference

24,404 downloads over 30 days 114 3,113 0.23.10 CUDA, WebGPU, Metal Build uses a native toolchain: cc Apache-2.0 OR MIT
ort Featured

A safe Rust wrapper for ONNX Runtime 1.31 - Optimize and accelerate machine learning inference & training

3,902,768 downloads over 30 days 694 2,611 2.0.0-rc.15 CUDA, WebGPU, ROCm Binds native code: onnxruntime, ort-sys. Build uses a native toolchain: pkg-config (feature pkg-config) Apache-2.0 OR MIT
oxionnx Listed

Pure Rust ONNX inference engine — zero C/C++ dependencies

550 downloads over 30 days 24 20 0.1.7 CUDA, WebGPU No native code found Apache-2.0
candle-vllm App Listed

Efficent platform for inference and serving local LLMs including an OpenAI compatible API server.

138 binary downloads per release Not applicable 739 Not measured Not measured MIT
nobodywho App Listed

NobodyWho is an inference engine that lets you run LLMs locally and efficiently on any device.

34 binary downloads per release Not applicable 1,672 Not measured Not measured EUPL-1.2
blazr App Listed

Inference server for LLMs, speech and embeddings: OpenAI-compatible routes with streaming, plus speech synthesis (TTS) and transcription (ASR). Serves Llama, Mistral, Qwen, Mamba2, MLA+MoE and hybrid models from SafeTensors, AWQ, GPTQ and GGUF.

8 binary downloads per release Not applicable 7 0.7.1 CUDA, WebGPU Binds native code: ring (feature distributed) Apache-2.0
tractjs App Listed Dormant

Run ONNX and TensorFlow inference in the browser.

0 binary downloads per release Not applicable 76 Not measured Not measured Not measured
Why ListedNo archive, New or Featured rule places it, so it is Listed.

What it lacks for Featured

  • Docs are missing: the primary crate publishes no README.

What else the check found

  • The last activity is on 7 Nov 2026, 2 days ago. The rules expect an update within 900 days. Dormancy rule

Check notes

  • the latest release was packaged from a dirty working tree

Exact rules: Listed, Featured library. The check on applied thresholds version 9.

Every rule outcome, as the check records it
  • expected-interval: version 0.23.10 base 450, doubled for 63 active users: E = 900 days
  • dormancy: last activity 2026-11-07, 2 days ago, E = 900: active
  • featured: not featured: docs missing
  • listed: listed: no archive, new or featured rule applies
Crates21 crates

Measurements and sources

Each signal row shows the raw value, its source and the fetch date. The Sources list gathers every distinct source on this page. Movement needs more history.

Sources6 sources
Adoption63 active dependents, 59 new dependents in 365 days1 not measured
Adoption measurements
SignalValueSourceFetchedCounts
Active dependents63crates.io database dumpYes
New dependents (365 days)59crates.io database dumpYes
Peak active dependents62crates.io database dumpYes
Active dependents as a share of the peak1crates.io database dumpYes
Binary downloads per releaseNot measuredYes
MaintenanceLatest human commit: 2 days ago3 not measured
Maintenance measurements
SignalValueSourceFetchedCounts
Latest human commit2026-11-07GitHub repositoryYes
Latest release2026-11-05crates.io database dumpYes
First release2018-11-02crates.io database dumpYes
Latest version0.23.10crates.io database dumpYes
Days the oldest outside issue waits for a reply100GitHub repositoryYes
Maintainer replies over 365 days48GitHub repositoryYes
Repository archivedfalseGitHub repositoryYes
Repository gonefalseGitHub repositoryYes
Release commit or manifest in the repotruecrates.io packageYes
Published docsfalsecrates.io database dumpYes
Latest release fails cargo checkNot measuredYes
Build check dateNot measuredYes
Build check toolchainNot measuredYes
SecurityUnpatched vulnerabilities: none
Security measurements
SignalValueSourceFetchedCounts
Unpatched vulnerabilities past the grace windownoneRustSec advisory databaseYes
RustSec unmaintained advisorynoneRustSec advisory databaseYes
Deprecation noticenonecrates.io database dumpYes
Deprecated requirementnonecrates.io database dumpYes
Distribution157 releases, 24,404 downloads over 30 days5 not measured
Distribution measurements
SignalValueSourceFetchedCounts
Releases157crates.io database dumpYes
Downloads over 30 days24404crates.io database dumpYes
Binary downloads over the last 3 releasesNot measuredYes
Homebrew installs on request over 365 daysNot measuredYes
Repology repository familiesNot measuredYes
Docker pull growth over 90 daysNot measuredYes
Docker pulls at the growth baselineNot measuredYes
Every version a prereleasefalsecrates.io database dumpYes
Every version 0.0.xfalsecrates.io database dumpYes
Every version yankedfalsecrates.io database dumpYes
Crate deleted from crates.iofalsecrates.io database dumpYes
Repository3,113 stars, 297 forks, 107 contributors, 11,096 commits. Stars alone never qualify a project.
Repository measurements
SignalValueSourceFetchedCounts
GitHub stars3113GitHub repositoryYes — one part of the repository route
GitHub forks297GitHub repositoryYes — one part of the repository route
Contributors with a GitHub account107GitHub contributorsYes — one part of the repository route
Commits on the default branch11096GitHub repositoryNo
Repository's main crate left out of the entrynonecrates.io database dumpYes
Facts that never count
Facts that never count measurements
SignalValueSourceFetchedCounts
LicenseApache-2.0 OR MITcrates.io database dumpNo
Runs on, from listed crates and their direct dependenciesCUDA, WebGPU, Metalcrates.io database dumpNo
What shows each backendCUDA: tract feature cuda, tract-cuda dependency cudarc, tract-libcli feature cuda (dependency cudarc); WebGPU: tract feature wgpu (dependency wgpu); Metal: tract feature metal, tract-ffi feature metal, tract-libcli feature metal, tract-metal dependency metalcrates.io database dumpNo
Native code, from listed crates and their dependenciesBuild uses a native toolchain: cccrates.io database dumpNo
Python bindings, from direct dependencies of listed cratesNo Python binding crate foundcrates.io database dumpNo
Crates that depend on a listed crate directly114crates.io database dumpNo

Corrections and review history

Report a correction

No correction applies to this entry.

Judgments

A judgment enters only through an approved issue and a merged pull request.

No judgment applies to this entry.