Stack overview
The tensor4all Rust stack
Rust libraries for scientific computing that grew out of tensor networks. At the top are quantics tensor trains, tensor cross interpolation and tree tensor networks; underneath are a tensor runtime with automatic differentiation, tensor contraction, batched linear algebra and the thread model they all share. Every layer can be used on its own.
★ Flagship projects
Three projects carry the stack. Start with one of them; the rest of this page shows what they stand on.
tensor4all-rs
Tensor network algorithms in Rust, ported from the tensor4all Julia ecosystem and grown beyond it.
- Quantics TCI: learn a QTT from an expensive function, then integrate or evaluate it
- QTT operators: Fourier transform, shift, flip, affine maps
- Tree tensor networks: contraction, DMRG, TDVP, linear solve
- Adaptive patching, ITensors.jl compatible HDF5, C API, Julia and Python frontends
tenferro-rs
A Rust-native tensor runtime with opt-in automatic differentiation for scientific workloads.
- Typed and dynamic dense tensors, einsum, linear algebra, FFT
- Eager AD with PyTorch-style
backward(); traced AD with JAX-style VJP, JVP and Hessian vector products - CPU and CUDA, with an experimental XLA path
- One explicit engine carries the thread pool, plan cache and buffers: no global state
colmat-rs
Pure Rust dense and sparse linear algebra for scientific and HPC work, derived from faer by Sarah Quinones and published as the colmat crate (formerly t4a-faer).
- Validated nightly against LAPACK 3.12's own test suites
- Steady-state calls allocate nothing; results are bitwise reproducible at a fixed thread count
- The caller owns the threadteam team: no implicit global thread pool
- Faster than MKL and OpenBLAS in most cases of the Zen 5 comparison
Two guides
For tensor network users
You want to compress a function into a QTT, run TCI, apply Fourier or shift operators, or contract tree tensor networks. You may be coming from the Julia packages. This guide maps what you know onto the ★ tensor4all-rs crates and tells you which entry point to use.
Read the user guide →For backend developers
You care about what happens below the algorithms: the ★ tenferro-rs runtime, tensor contraction, batched linear algebra, thread ownership, C ABIs. First-principles, quantum chemistry and HPC codes that need fast strided contractions are a target audience.
Read the backend guide →The layer map
The map has three independent parts, and each uses only the ones below it. At the top are the tensor network libraries: tensor4all-rs depends on tenferro-rs like any other user would, and quanticsgrids-rs depends on nothing in the stack. In the middle is the Rust numerical stack, from tenferro down to colmat; every library in it is usable on its own, without tensor4all-rs. Its top row, tenferro-sci-rs, is planned: a dashed box marks it. At the bottom is threadteam, the thread substrate: it is not part of the numerical stack but runs under it, under hataori, and under any Rust HPC code that wants OpenMP-style teams. Bands are layers, named by their role; boxes are libraries, and each name links to its GitHub repository. ★ marks the flagship projects. hataori sits beside: it does not compute anything itself, it splits the machine into MPI ranks and thread domains and lends them to the layers that do.
The layers in brief
- Frontends. Rust programs use tensor4all-rs directly. Tensor4all.jl is a Julia frontend over the C API, maintained on a best effort basis for light use and teaching. Python bindings (
tensor4all-py) live in the tensor4all-rs repository. - Algorithms. ★ tensor4all-rs holds the algorithms: tensor trains, TCI, quantics grids and operators, tree tensor networks, patching, HDF5 I/O. It keeps two stacks on purpose (a TT and TCI stack and a network stack) with an explicit bridge between them. Grid and coordinate conversion lives in the standalone quanticsgrids-rs.
- Numerical algorithms (planned). tenferro-sci-rs will hold general numerical algorithms on top of tenferro, in the role SciPy plays for NumPy: Krylov solvers, optimizers, special functions, integrators and interpolation, with autodiff where possible. Algorithms that need only vector operations live in pure Rust cores that any Rust code can use without tenferro. The repository holds its rules and CI; no crate is released yet. Design: tenferro-sci.md.
- Tensor runtime. ★ tenferro-rs is the tensor runtime: typed and dynamic tensors, eager and traced automatic differentiation, CPU and CUDA backends and an experimental XLA path. tensor4all-rs reaches it through one adapter crate, as one user among others; tenferro does not depend on tensor4all-rs.
- Kernel providers. Tensor-free numerical libraries that tenferro calls: cpueinsum for N-ary einsum, tcontract for binary contraction over arbitrary strides, and tlinalg for batched factorizations. They take borrowed strided views and an explicit execution token, so they are usable on their own, including from C.
- Foundation. strided-rs defines the strided view types every layer above passes around. Dense arithmetic comes from ★ colmat-rs, tensor4all's pure Rust linear algebra library derived from faer (formerly published as
t4a-faer). - Thread substrate. threadteam-rs owns the CPU threads. It is not a numerical library and not part of the stack above it: it gives any Rust HPC code OpenMP-style teams, barriers and CPU placement. In the stack it is the only place where parallel tasks start, and strided-rs, colmat, the kernel providers and tenferro all take their threads from it; hataori's lanes run on threadteam teams too, and so can a host code such as a DFT or quantum chemistry program.
- Beside the stack. hataori-rs provides data-parallel map and pmap over serial, Rayon, MPI and hybrid execution, for the outer level of a study: parameter scans, momenta, independent patches.
Beyond tensor networks
The stack started as the backend of tensor network algorithms, and its lower layers are now general tools for dense numerical work in Rust. None of them requires tenferro or tensor4all-rs.
- Linear algebra. ★ colmat is a pure Rust dense and sparse linear algebra library. It is validated nightly against LAPACK 3.12's own test suites, its steady-state calls are tested to allocate nothing, and its results are bitwise reproducible at a fixed thread count. In the published comparison on a Zen 5 host it is faster than both MKL and OpenBLAS in most of the measured cases. Migration guides cover LAPACK, Eigen, NumPy and SciPy users.
- Tensor contraction. tcontract contracts tensors in any index order without transposing them first, and speaks TAPP, the community C interface for tensor products, so C, C++ and Fortran codes can call it.
- Batched factorizations. tlinalg runs SVD, QR, LU, Cholesky and eigensolvers over whole batches of matrices and decides how to spread them over threads.
- Threads that cooperate. threadteam gives a caller one pool to hand down, so a library call never competes with the OpenMP, MPI or Julia threads of the host program.
First-principles, quantum chemistry and HPC developers: the host code section of the backend guide shows how to call these libraries from an existing code, and the essay Why rewrite first-principles codes in Rust argues the case. Issues with your typical shapes are very welcome.
Repositories
Each repository's README says how to depend on it.
| Repository | Role | Docs |
|---|---|---|
| ★ tensor4all-rs | flagship: TT, TCI, QTT, tree tensor networks, C API | user guide |
| ★ tenferro-rs | flagship: tensor runtime, autodiff, CPU and CUDA backends | docs |
| tenferro-sci-rs (planned) | SciPy-like algorithms on tenferro: Krylov, optimize, special functions, integrate, interpolate | design |
| tenferro-examples | runnable tenferro examples: PINN, neural ODE, DeepONet, neural-network quantum states | README |
| quanticsgrids-rs | quantics grids and coordinate conversion | README |
| Tensor4all.jl | Julia frontend, best effort | README |
| cpueinsum-rs | N-ary einsum with caller-supplied order | README |
| tcontract-rs | binary strided contraction, TAPP C ABI | README |
| tlinalg-rs | batched SVD, QR, LU, Cholesky, eigensolvers | README |
| strided-rs | strided view types, permutation and elementwise kernels | README |
| threadteam-rs | the CPU thread pool and execution token every layer takes | README |
| ★ colmat-rs | flagship: dense and sparse linear algebra derived from faer by Sarah Quinones: caller-owned threadteam teams, validated against LAPACK | docs |
| hataori-rs | map and pmap over Rayon and MPI | docs |
Supporting repositories: computegraph-rs is the graph IR inside tenferro's traced AD; hdf5-rt and rsmpi-rt load HDF5 and MPI at run time so a Rust extension can share them with Julia or Python; elem-simd-math-rs provides vectorized elementwise math; tensor-ad-oracles is a database of derivative-correctness oracles for the AD rules; t4a-gemm is the matrix multiply fork under colmat, with Apple Silicon SME kernels; t4a-gpu-backend and t4a-cuda-kernels are GPU runtimes and kernels developed and validated on their own before tenferro adopts them.
Benchmarks
Performance claims are measured, not assumed. Each campaign lives in its own repository, keys its results by library commit and hardware profile, and publishes a site:
| Campaign | Compares | Results |
|---|---|---|
| ★ tenferro-benchmark | tenferro against PyTorch and JAX, CPU and GPU | site |
| ★ tensor4all-benchmark | tensor network algorithms: QTT elementwise products, MPO MPO contraction | results |
| ★ colmat-benchmark | colmat against upstream faer, MKL and OpenBLAS | site |
| tlinalg-benchmark | batched factorizations against vendor LAPACK | site |
| tcontract-benchmark | binary contraction against TBLIS | site |
| cpueinsum-benchmark | N-ary einsum over a standard corpus of einsum instances | site |
The campaigns share their tooling in campaign-toolkit; how they are run is described in Benchmarks of the tensor4all stack.
Three ideas that run through every layer
- Explicit execution. No library in the stack starts a hidden global thread pool or changes behavior through environment variables. The caller builds one thread pool (a threadteam
Pool) and passes a token for it down; tenferro bundles that pool with its scratch memory and plan cache in an engine. This is what lets an MPI program, a Julia session and a Rust test share one machine predictably. - Tensor-free providers. The numerical kernels (tcontract, tlinalg) do not know about tensor types. They take borrowed strided views. The host above them owns allocation, dtype dispatch and placement. That keeps them small, testable on plain buffers and reusable from other codes.
- One shared vocabulary. All CPU layers exchange strided-rs views and threadteam tokens. A view made by tenferro can be handed to tcontract or tlinalg without conversion, which is why the whole stack resolves to the same strided-rs and threadteam releases.
Join the community
tensor4all is open to new developers, and AI assisted contributions are welcome. The rules that hold in every Rust repository are in the contribution rules; each repository adds its local facts in AGENTS.md and its contributing guide. Good first contributions are benchmark cases from real applications, kernels for hardware we have not tuned for, and bindings for other languages.