Skip to main content

symtenet

tests coverage codecov docs license python

A Python library for symmetric tensor networks: NumPy-ish API on the surface, category theory under the hood.

tenet gives you block-sparse tensors that carry a symmetry exactly — SU(N), SU(2), U(1), Z2, fermion parity and their products — through exact recoupling coefficients. A tensor carries legs, contracts with tenet.einsum and factorizes with tenet.linalg, the way an ndarray does. Blocks live in NumPy, JAX or PyTorch arrays through autoray, so the same tensor runs under jax.jit and jax.grad with its symmetry structure intact. On top of the tensor layer, tenet.network ships finite DMRG and CTMRG.

Install

uv add symtenet         # or: pip install symtenet

The core install pulls numpy, autoray, opt-einsum and racah-py, and every symmetry works on it. Two optional extras:

uv add "symtenet[jax]"      # jax>=0.10 — pytrees, jit, grad
uv add "symtenet[torch]"    # torch>=2.0 — eager blocks

Quickstart

A 20-site spin-1/2 Heisenberg chain, U(1)-graded by 2 S^z, to its ground state:

from tenet.models import spin_half
from tenet.network import MPO, MPS, dmrg_
from tenet.symmetry import U1Sector

site, n = spin_half(), 20
terms = []
for i in range(n - 1):
    terms.append((1.0, [(site.ops["Sz"], i), (site.ops["Sz"], i + 1)]))
    terms.append((0.5, [(site.ops["S+"], i), (site.ops["S-"], i + 1)]))
    terms.append((0.5, [(site.ops["S-"], i), (site.ops["S+"], i + 1)]))

h = MPO.from_terms(n, terms)
psi = MPS.product(site.phys, [U1Sector(1 if i % 2 else -1) for i in range(n)])
out = dmrg_(psi, h, chi=64)

print(out.sweeps, out.energy)          # 6 -8.682473334398...
print(out.psi.entanglement_entropy())  # {bond: S}, in nats

The Néel product state's own charges put the run in the S^z_tot = 0 sector, and the site tensors' invariance keeps it there — no projector, no penalty term. Getting started reads this example line by line.

With the jax extra, the same tensors are JAX pytrees: jit, grad and vmap reach through to the blocks while the symmetry structure stays static.

import jax
import tenet

tenet.enable_jax()

t = out.psi[0].to_backend("jax")
g = jax.jit(jax.grad(lambda x: tenet.norm(x) ** 2))(t)
assert g.legs == t.legs

What it supports

  • Symmetries. SU(N), SU(2), U(1), Z2, fermion parity (fZ2) and Deligne products of any of them. Non-Abelian sectors are multiplets with exact Clebsch-Gordan, F- and R-symbols; fermionic wires carry their Koszul signs.
  • Tensors. SymmetricTensor over a flat tuple of Legs, one reduced block per allowed fusion channel. einsum, tensordot, compose, transpose, fuse, repartition, trace, and tenet.linalg's svd, qr, lq, eigh, eig, polar, expm, left_null, plus the truncating svd_truncated / eigh_truncated.
  • Algorithms. Finite two-site DMRG (dmrg_, schedules, noise, excited states) with MPS/MPO containers, environment caches and measurement; CTMRG on the directional EnvCTM and its C4v specialization EnvCTMc4v, with a differentiable fixed-bond move.
  • Backends. NumPy, JAX and PyTorch blocks through autoray. tenet.enable_jax() registers SymmetricTensor as a JAX pytree, so jit, grad and vmap reach the blocks while the structure stays static metadata.

Docs

Citation

If you use symtenet in your research, please cite it:

@software{symtenet,
  author  = {Watanabe, Ryo},
  title   = {{symtenet}: a {Python} library for symmetric tensor networks
             --- a {NumPy}-style {API} on the surface, category theory under
             the hood},
  url     = {https://github.com/Ryo-wtnb11/symtenet},
  license = {Apache-2.0},
  year    = {2026}
}

The same metadata lives in CITATION.cff — GitHub's "Cite this repository" button renders it as BibTeX or APA.

License

Apache License 2.0 — see LICENSE.

Metadata

Release files for symtenet 0.1.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for symtenet 0.1.3
File Size Uploaded Provenance Actions
symtenet-0.1.3.tar.gz 2.8 MB With provenance Details for symtenet-0.1.3.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for symtenet 0.1.3
File Interpreter ABI Platform Actions
symtenet-0.1.3-py3-none-any.whl Python 3 none any Details for symtenet-0.1.3-py3-none-any.whl

Total release size: 3.2 MB

Release files / symtenet-0.1.3.tar.gz

Download URL symtenet-0.1.3.tar.gz
Size 2.8 MB
Tags Source
SHA-256 checksum
How to use checksums
749f2cfc29af9ce519eb140ed0bbd5612f0aab095196bd2a924ef51327d4df04
BLAKE2b-256 checksum
How to use checksums
87679ac48e66b865a0af03a67f4190aa8c048202b56419f263608cf9694b5dc0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 5, 2026.

Transparency log

Release files / symtenet-0.1.3-py3-none-any.whl

Download URL symtenet-0.1.3-py3-none-any.whl
Size 395.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4577d981f18340f9385298bfdf59dd112bdd352f417f9d9fc3403305ab54d150
BLAKE2b-256 checksum
How to use checksums
cd02ca4a22a2d1a78407ecd99292110dc3342ea002b3c364c33d17fe3bd715e3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 5, 2026.

Transparency log

Security for symtenet 0.1.3

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for symtenet-0.1.3.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 5, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page