Stack overview
The tensor4all Rust stack
A family of Rust libraries for tensor networks (quantics tensor trains, tensor cross interpolation, tree tensor networks) and the dense tensor backend they run on. This page shows how the pieces fit together and where to start reading.
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 Rust crates and tells you which entry point to use.
Read the user guide →For backend developers
You care about what happens below the algorithms: tensor contraction, batched linear algebra, execution contexts, C ABIs. Quantum chemistry codes that need fast strided contractions are a target audience. This guide goes down to tcontract and tlinalg.
Read the backend guide →The layer map
Each layer depends only on layers below it. Bands are layers, named by their role; boxes are libraries, and each name links to its GitHub repository. hataori sits beside the stack: it does not compute anything itself, it owns processes and threads 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.
- Tensor runtime. tenferro-rs is the tensor runtime: typed and dynamic tensors, eager and traced automatic differentiation, and CPU, GPU and XLA backends. tensor4all-rs reaches it through one adapter crate. computegraph-rs supplies the graph IR that traced AD builds on.
- 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 context, so they are usable on their own, including from C.
- Foundation. strided-rs defines the strided view types every layer above passes around; faer and, optionally, a vendor BLAS and LAPACK do the dense arithmetic. tensor4all develops its own fork of faer, published as
t4a-faer, which carries strided and batched entry points, caller-owned workspaces, an explicit thread policy and fixes that upstream does not have. - Beside the stack. hataori-rs provides data-parallel map and pmap over serial, Rayon, MPI and hybrid execution. Since no layer in the stack owns a global thread pool, hataori is where pools and MPI ranks come from.
Repositories
Each repository's README says how to depend on it.
| Repository | Role | Docs |
|---|---|---|
| tensor4all-rs | TT, TCI, QTT, tree tensor networks, C API | user guide |
| quanticsgrids-rs | quantics grids and coordinate conversion | README |
| Tensor4all.jl | Julia frontend, best effort | README |
| tenferro-rs | tensor runtime, autodiff, backends | docs |
| computegraph-rs | graph IR used by traced AD | rustdoc |
| 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, kernels | README |
| t4a-faer | tensor4all fork of faer by Sarah Quinones, tuned for the stack | PATCHSET.md |
| hataori-rs | map and pmap over Rayon and MPI | docs |
Benchmarks are kept in separate repositories so results can be keyed by commit and hardware: tenferro-benchmark, tcontract-benchmark, tlinalg-benchmark and tensor4all-benchmark.
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 creates a context (a Rayon pool, a backend, scratch memory) and passes it down. 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. A view made by tenferro can be handed to tcontract or tlinalg without conversion, which is why the whole stack pins the same strided-rs release.