SkillAgentSearch skills...

Cotengra

Hyper optimized contraction trees for large tensor networks and einsums

Install / Use

/learn @jcmgray/Cotengra

README

<p align="left"><img src="https://imgur.com/OM5XyaD.png" alt="cotengra" width="400px"></p>

tests codecov Docs PyPI Anaconda-Server Badge Pixi Badge

cotengra is a python library for contracting tensor networks or einsum expressions involving large numbers of tensors - the main docs can be found at cotengra.readthedocs.io. Some of the key feautures of cotengra include:

  • drop-in einsum and ncon replacement
  • an explicit contraction tree object that can be flexibly built, modified and visualized
  • a 'hyper optimizer' that samples trees while tuning the generating meta-paremeters
  • dynamic slicing for massive memory savings and parallelism
  • simulated annealing as an alternative optimizing and slicing strategy
  • support for hyper edge tensor networks and thus arbitrary einsum equations
  • paths that can be supplied to numpy.einsum, opt_einsum, quimb among others
  • performing contractions with tensors from many libraries via autoray, even if they don't provide einsum or tensordot but do have (batch) matrix multiplication
<p align="center"><img src="https://imgur.com/jMO138y.png" alt="cotengra" width="500px"></p>
View on GitHub
GitHub Stars236
CategoryDevelopment
Updated7d ago
Forks36

Languages

Python

Security Score

100/100

Audited on Mar 24, 2026

No findings