TNC: Distributed Tensor Network Contractions in Rust
TNC: Distributed Tensor Network Contractions in Rust - Published in JOSS (2026)
Science Score: 90.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
○CITATION.cff file
-
○codemeta.json file
-
○.zenodo.json file
-
✓DOI references
Found 1 DOI reference(s) in JOSS metadata -
✓Academic publication links
Links to: arxiv.org -
○Academic email domains
-
✓Institutional organization owner
Organization qc-tum has institutional domain (www5.in.tum.de) -
✓JOSS paper metadata
Published in Journal of Open Source Software
Repository
Distributed-memory tensor network contraction in Rust using partitioning.
Basic Info
Statistics
- Stars: 3
- Watchers: 1
- Forks: 0
- Open Issues: 1
- Releases: 1
Metadata Files
README.md
Tensornetwork Contraction Library
This library is designed to perform tensor network contractions, using partitioning of the network as parallelization strategy. To this end, it ships multiple methods to partition a tensor network for lowest contraction cost, for example, based on simulated annealing. The partitions can then be contracted in parallel on a distributed-memory system, as common in high-performance computing. Local contractions on a single system are also possible.
Some key features: - Contraction of arbitrary tensor networks - Efficient "transpose-free" contraction using TBLIS - Contraction path finding using state-of-the-art methods - Partitioning of tensor networks with iterative refinement - Parallel contraction on multiple compute nodes using MPI - Import of quantum circuits from QASM2 code - Creation of tensor networks for quantum circuits to compute amplitudes or expectation values
Example
```rust use tnc::{ contractionpath::paths::{ cotengrust::{Cotengrust, OptMethod}, FindPath, }, io::qasm::importqasm, tensornetwork::contraction::contracttensor_network, };
fn main() { // The QASM code prepares a GHZ state let code = "\ OPENQASM 2.0; include \"qelib1.inc\";
qreg q[3]; h q[0]; cx q[0], q[1]; cx q[1], q[2]; ";
// Create a Circuit instance out of the code
let circuit = import_qasm(code);
// Create a tensor network that computes the full state vector.
// This also returns a permutator which we need to apply to the final tensor to
// make sure the entries are in the expected order.
let (tensor_network, permutator) = circuit.into_statevector_network();
// Find a contraction path to contract the tensor network.
// We use a greedy path finder here.
let mut opt = Cotengrust::new(&tensor_network, OptMethod::Greedy);
opt.find_path();
let path = opt.get_best_replace_path();
// Contract the tensor network locally
let final_tensor = contract_tensor_network(tensor_network, &path);
// Apply the permutator to make sure the data is in the expected order
let statevector = permutator.apply(final_tensor);
// Get the actual data.
let data = statevector.into_tensor_data().into_data();
// Print the data
println!("Resulting statevector is: {:?}", data);
} ```
Installation
Requirements
The library requires a few dependencies to be installed on the system.
Those can be installed with
shell
sudo apt install libhdf5-dev openmpi-bin libopenmpi-dev libboost-program-options-dev
Furthermore, for building the library, cmake and a C++ compiler must be installed on the system.
Additionally, to run the HyperOptimizer of cotengra, Python is required.
The following Python packages have to be installed (in a virtual environment if preferred):
shell
pip install cotengra kahypar optuna
Usage
The library can be added to an existing Rust project with e.g.
shell
cargo add --git https://github.com/qc-tum/TNC.git --features cotengra tnc
or you can run the examples of this library by e.g.
shell
cargo run --example local_contraction
Features
cotengra: Enables Rust bindings to the tree annealing, tree reconfiguration and tree tempering methods of cotengramkl: Uses the MKL library for performing the tensor contractions.
Getting started
To familiarize yourself with the code, it is recommended to look at the Examples and the Documentation. Some aspects of the library are also covered in more detail in the [Tutorial]. If you want to contribute, please take a loot at the Contribution guide.
Publications
- Optimizing Tensor Network Partitioning using Simulated Annealing, Geiger et al. (2025): https://arxiv.org/abs/2507.20667
Owner
- Name: qc-tum
- Login: qc-tum
- Kind: organization
- Location: Germany
- Website: https://www5.in.tum.de/~quanTUMcomputing/
- Repositories: 3
- Profile: https://github.com/qc-tum
JOSS Publication
TNC: Distributed Tensor Network Contractions in Rust
Authors
School for Computation, Information and Technology, Technical University of Munich, Germany
Tags
tensor networks quantum computing high-performance computingGitHub Events
Total
- Release event: 1
- Delete event: 30
- Pull request event: 86
- Issues event: 3
- Watch event: 1
- Issue comment event: 8
- Push event: 102
- Create event: 34
Last Year
- Release event: 1
- Delete event: 30
- Pull request event: 86
- Issues event: 3
- Watch event: 1
- Issue comment event: 8
- Push event: 102
- Create event: 34
Issues and Pull Requests
Last synced: 2 days ago
All Time
- Total issues: 2
- Total pull requests: 20
- Average time to close issues: N/A
- Average time to close pull requests: 1 day
- Total issue authors: 2
- Total pull request authors: 2
- Average comments per issue: 0.0
- Average comments per pull request: 0.15
- Merged pull requests: 14
- Bot issues: 0
- Bot pull requests: 6
Past Year
- Issues: 2
- Pull requests: 20
- Average time to close issues: N/A
- Average time to close pull requests: 1 day
- Issue authors: 2
- Pull request authors: 2
- Average comments per issue: 0.0
- Average comments per pull request: 0.15
- Merged pull requests: 14
- Bot issues: 0
- Bot pull requests: 6
Top Authors
Issue Authors
- Luthaf (1)
- Ectras (1)
Pull Request Authors
- Ectras (14)
- dependabot[bot] (6)
Top Labels
Issue Labels
Pull Request Labels
Dependencies
- 357 dependencies
- clap 4.5.28 development
- criterion 0.5.1 development
- flate2 1.1.1 development
- flexi_logger 0.29.6 development
- static_init 1.0.3 development
- antlr-rust 0.3.0-beta
- bincode 2.0.1
- chrono 0.4.38
- float-cmp 0.10.0
- itertools 0.13.0
- jemallocator 0.5.4
- lazy_static 1.5.0
- log 0.4.22
- mpi 0.8.0
- ndarray 0.15.6
- num-complex 0.4.6
- ordered-float 5.0.0
- permutation 0.4.1
- rand 0.8.5
- rayon 1.10.0
- regex 1.11.1
- rustc-hash 2.1.1
- serde 1.0.215
- serde-pickle 1.2.0
- serde_json 1.0.133
- actions-rust-lang/setup-rust-toolchain ac90e63697ac2784f4ecfe2964e1a285c304003a composite
- actions/checkout 08c6903cd8c0fde910a37f88322edcfb5dd907a8 composite
- dtolnay/install 982daea0f5d846abc3c83e01a6a1d73c040047c1 composite
- taiki-e/install-action c0dee14250395ae6b1754a99f67c1d693138b102 composite
- actions-rust-lang/setup-rust-toolchain ac90e63697ac2784f4ecfe2964e1a285c304003a composite
- actions/checkout 08c6903cd8c0fde910a37f88322edcfb5dd907a8 composite
- actions/setup-python a26af69be951a213d495a4c3e4e4022e16d87065 composite
- taiki-e/install-action c0dee14250395ae6b1754a99f67c1d693138b102 composite
- tluijken/code-coverage-threshold 905bb53afdaea38a54d1a7a19c75c1ff513a3b07 composite