← Quantum Store · Guides · Lessons · Glossary · Packages · About · Türkçe
Johnnie Gray (Caltech) and the quimb community
A 50-qubit tensor network simulation with quimb
Official source: jcmgray/quimb
Download ZIP (free)A tested example that simulates a 50-qubit GHZ circuit, whose full state vector would take 18 petabytes, in seconds on a laptop using tensor networks (MPS).
What is quimb?
quimb is an open-source quantum information and tensor network library developed by Johnnie Gray. It represents large quantum systems as a network of small, connected tensors, without storing the whole state vector.
Why does it matter?
Simulating n qubits exactly on a classical computer needs 2ⁿ complex numbers: 30 qubits take about 16 GB and 50 qubits about 18 petabytes. But in many circuits the entanglement between qubits is limited. An MPS (matrix product state) uses this structure to keep memory proportional to the amount of entanglement.
The example in this package
mps_50_kubit.py builds the 50-qubit GHZ state (all 0 or all 1).
- The largest bond dimension in the MPS is only 2, so memory use is a few kilobytes.
- The amplitudes of
|00…0⟩and|11…1⟩are 0.7071 (1/√2); all other states have 0. - Sampling always gives fifty zeros or fifty ones.
When running it you may see a warning that the kahypar package was not
found. It is harmless for this small example.
When is it not enough?
As entanglement grows, the bond dimension grows exponentially. In random, deep circuits tensor networks get stuck too; the debate around Google's 2019 "quantum supremacy" experiment is about exactly this limit.
Next steps
- Set
Nto 200; the time and memory hardly change. - Add random
rxrotations on every qubit and layers of neighbouring CNOTs; watch howmax_bond()grows.
Installation and running
pip install quimb
python mps_50_kubit.py
Tested with: quimb 1.15.0, Python 3.12.
Official source
- Repository: jcmgray/quimb
- Latest release: v1.15.0 — 10 August 2026
- Licence: Apache-2.0
- Stars: 669
- Default branch commit when the catalogue was built:
b3bf45a505b6(8 October 2026)
Links
Package contents
mps_50_kubit.pyREADME.en.md— this fileREADME.md— the same guide in TurkishLICENSE— the licence of the files in this packageKAYNAK.json— a machine-readable summary of the official sourceUPSTREAM-LICENSE.txt— the licence text of the official project
Licence
The example code and the guide in this package were written by the Quantum Store editors and are MIT licensed. The project it uses is subject to its own licence (Apache-2.0).
Quantum Store — https://hakanerdogan.com/en
Example code
The example shipped in the package, run and checked. Comments and printed messages are in Turkish; the code is the same in any language. Everything is in the ZIP.
mps_50_kubit.py
"""quimb ile 50 kübitlik GHZ durumu: tensör ağıyla (MPS) devasa devreyi dizüstünde simüle et.
Çalıştırma:
pip install quimb
python mps_50_kubit.py
"""
import quimb.tensor as qtn
N = 50
# Tam durum vektörü 2**50 karmaşık sayı = yaklaşık 18 petabayt olurdu.
# MPS (matris çarpım durumu) yalnızca kübitler arasındaki dolanıklık kadar bellek kullanır.
devre = qtn.CircuitMPS(N)
devre.h(0)
for i in range(N - 1):
devre.cx(i, i + 1)
tam_bellek_pb = (2**N) * 16 / 1e15
bag = devre.psi.max_bond()
print(f"Kübit sayısı: {N}")
print(f"Tam durum vektörü için gereken bellek: ~{tam_bellek_pb:,.0f} PB")
print(f"MPS'teki en büyük bağ boyutu: {bag} (dolanıklığın ölçüsü)")
sifirlar = complex(devre.amplitude("0" * N))
birler = complex(devre.amplitude("1" * N))
karisik = complex(devre.amplitude("01" * (N // 2)))
print(f"|00…0⟩ genliği: {sifirlar.real:.4f}")
print(f"|11…1⟩ genliği: {birler.real:.4f}")
print(f"|0101…⟩ genliği: {abs(karisik):.4f}")
ornekler = list(devre.sample(6, seed=5))
for o in ornekler:
print("ölçüm:", o)
assert bag == 2, bag
assert abs(sifirlar - 2**-0.5) < 1e-9 and abs(birler - 2**-0.5) < 1e-9
assert abs(karisik) < 1e-9
assert all(o in ("0" * N, "1" * N) for o in ornekler), ornekler
print("Tamam: 50 kübit ya hep 0 ya hep 1; bunu birkaç kilobaytla hesapladık.")