Skip to main content

A test-driven tensor network playground for finite-size DMRG and MPS/MPO algorithms

Project description

quantum-simulation-lab

Tests PyPI Python License

A test-driven tensor network library for finite-size DMRG and MPS/MPO algorithms on 1D quantum lattice models.

Installation · Quickstart · Features · Roadmap · Diary


Overview

quantum-simulation-lab is a from-scratch Python implementation of the core tensor network stack needed for finite-size DMRG on 1D quantum lattice models. The focus is on correctness and clarity — every algorithm is covered by a dense test suite and cross-validated against iTensor.

This project serves as both a learning vehicle and a research platform, built with the same engineering discipline expected in production scientific software: strict CI, typed APIs, and regression tests at every layer.


Features

🧱 Core Tensor Network Primitives

  • Tensor, Index — numpy-backed tensors with named indices and full linear algebra support
  • MPS — matrix product states with product-state, statevector, and qubit-label constructors
  • MPO — matrix product operators with identity, dense conversion, and MPS application
  • TruncationPolicy — configurable SVD truncation (cutoff, max bond dimension, strict mode)
  • Utility routines for expectation values and left/right environments

⚛️ Hamiltonian Builders

  • Transverse-field Ising model (TFIM)
  • XXZ Heisenberg model — via heisenberg_mpo and XX wrappers
  • Random field models — X and Z directions, ZZ+Z coupling

🔬 Finite-Size 2-Site DMRG

  • Mixed-canonical MPS, incremental left/right environments
  • Two-site effective Hamiltonians with correct gauge fixing per sweep direction
  • Converges on TFIM, Heisenberg, random Z/X fields, and ZZ+Z — results match iTensor

🧪 Test Suite

  • 315+ pytest tests — unit, integration, dense-reference checks, and DMRG regression tests
  • CI runs on every push and pull request via GitHub Actions

Installation

pip install quantum-simulation-lab

Or from source:

git clone https://github.com/szmbthydmnk/quantum-simulation-lab.git
cd quantum-simulation-lab
python -m venv .venv && source .venv/bin/activate
pip install -e ".[dev]"

Quickstart: Ground State of TFIM with DMRG

import numpy as np
from tensor_network_library.core.env import Environment
from tensor_network_library.core.mps import MPS
from tensor_network_library.core.policy import TruncationPolicy
from tensor_network_library.algorithms.dmrg import finite_dmrg, DMRGConfig
from tensor_network_library.hamiltonian.models import tfim_mpo

L, J, g = 10, 1.0, 1.0

env = Environment.qubit_chain(L=L, chi_max=32)
mpo = tfim_mpo(L=L, J=J, g=g)

rng = np.random.default_rng(0)
psi = rng.standard_normal(2**L) + 1j * rng.standard_normal(2**L)
mps0 = MPS.from_statevector(psi / np.linalg.norm(psi), physical_dims=2, normalize=True)

config = DMRGConfig(max_sweeps=10, energy_tol=1e-10, verbose=True)
result = finite_dmrg(env, mpo, mps0, config)

print(f"Ground-state energy: {result.energies[-1]:.12f}")

See examples/ for convergence plots and random-field model scripts.


Running Tests

pytest

The CI badge above reflects the current state of the main branch.


Roadmap

Version Focus Status
v1 Finite-size DMRG — qubit and spin-1/2 bosonic chains ✅ Done
v2 TEBD / iTEBD — fermionic and spin-1 environments 🔲 In-progress
v3 2D geometries and long-range Hamiltonians 🔲 Planned

See ROADMAP.md for detailed per-version task lists and DIARY.md for development notes.


Lines of code

Last updated automatically by CI:

6885

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

quantum_simulation_lab-1.2.2.tar.gz (301.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

quantum_simulation_lab-1.2.2-py3-none-any.whl (57.7 kB view details)

Uploaded Python 3

File details

Details for the file quantum_simulation_lab-1.2.2.tar.gz.

File metadata

  • Download URL: quantum_simulation_lab-1.2.2.tar.gz
  • Upload date:
  • Size: 301.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for quantum_simulation_lab-1.2.2.tar.gz
Algorithm Hash digest
SHA256 104179defe96743f23ecbfa6aa2e20aa5501c02e708f1717d40ae3c251991389
MD5 4c7be7ce008ad5c9cf426b909d255c85
BLAKE2b-256 436a7e6832698a7e14a4518f9bc8d7e9a2f858a1fb2908d4c3fa7e9965baf5fe

See more details on using hashes here.

Provenance

The following attestation bundles were made for quantum_simulation_lab-1.2.2.tar.gz:

Publisher: publish.yml on szmbthydmnk/quantum-simulation-lab

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file quantum_simulation_lab-1.2.2-py3-none-any.whl.

File metadata

File hashes

Hashes for quantum_simulation_lab-1.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 47148af885e59005ea3207b43409188639eb1cb9f9e2813b53c8d82f8e932fe8
MD5 814230d6bdeb08568d3af02e4601ab4c
BLAKE2b-256 fd65b0ab0d4f76169c03790723f08a320eeb7ca93e8134de86e876b72c5596ce

See more details on using hashes here.

Provenance

The following attestation bundles were made for quantum_simulation_lab-1.2.2-py3-none-any.whl:

Publisher: publish.yml on szmbthydmnk/quantum-simulation-lab

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page