tensor4all

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.

★ Flagship · algorithms

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
★ Flagship · tensor runtime

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
★ Flagship · linear algebra

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

Guide A

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 →
Guide B

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.

Blue: tensor network libraries. Orange: the numerical stack, each library usable on its own. Grey: the thread substrate under any Rust HPC code. On a narrow screen, scroll the map sideways.

The layers in brief

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.

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.

RepositoryRoleDocs
★ tensor4all-rsflagship: TT, TCI, QTT, tree tensor networks, C APIuser guide
★ tenferro-rsflagship: tensor runtime, autodiff, CPU and CUDA backendsdocs
tenferro-sci-rs (planned)SciPy-like algorithms on tenferro: Krylov, optimize, special functions, integrate, interpolatedesign
tenferro-examplesrunnable tenferro examples: PINN, neural ODE, DeepONet, neural-network quantum statesREADME
quanticsgrids-rsquantics grids and coordinate conversionREADME
Tensor4all.jlJulia frontend, best effortREADME
cpueinsum-rsN-ary einsum with caller-supplied orderREADME
tcontract-rsbinary strided contraction, TAPP C ABIREADME
tlinalg-rsbatched SVD, QR, LU, Cholesky, eigensolversREADME
strided-rsstrided view types, permutation and elementwise kernelsREADME
threadteam-rsthe CPU thread pool and execution token every layer takesREADME
★ colmat-rsflagship: dense and sparse linear algebra derived from faer by Sarah Quinones: caller-owned threadteam teams, validated against LAPACKdocs
hataori-rsmap and pmap over Rayon and MPIdocs

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:

CampaignComparesResults
★ tenferro-benchmarktenferro against PyTorch and JAX, CPU and GPUsite
★ tensor4all-benchmarktensor network algorithms: QTT elementwise products, MPO MPO contractionresults
★ colmat-benchmarkcolmat against upstream faer, MKL and OpenBLASsite
tlinalg-benchmarkbatched factorizations against vendor LAPACKsite
tcontract-benchmarkbinary contraction against TBLISsite
cpueinsum-benchmarkN-ary einsum over a standard corpus of einsum instancessite

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

  1. 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.
  2. 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.
  3. 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.