mps-xtrap 1.0.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- mps_xtrap-1.0.0/LICENSE +21 -0
- mps_xtrap-1.0.0/MANIFEST.in +5 -0
- mps_xtrap-1.0.0/PKG-INFO +196 -0
- mps_xtrap-1.0.0/README.md +184 -0
- mps_xtrap-1.0.0/mps_xtrap/__init__.py +44 -0
- mps_xtrap-1.0.0/mps_xtrap/circuits/__init__.py +336 -0
- mps_xtrap-1.0.0/mps_xtrap/cli.py +265 -0
- mps_xtrap-1.0.0/mps_xtrap/core/__init__.py +1 -0
- mps_xtrap-1.0.0/mps_xtrap/core/mps.py +347 -0
- mps_xtrap-1.0.0/mps_xtrap/examples/__init__.py +0 -0
- mps_xtrap-1.0.0/mps_xtrap/examples/examples.py +174 -0
- mps_xtrap-1.0.0/mps_xtrap/extrapolation/__init__.py +462 -0
- mps_xtrap-1.0.0/mps_xtrap/gates/__init__.py +224 -0
- mps_xtrap-1.0.0/mps_xtrap/py.typed +0 -0
- mps_xtrap-1.0.0/mps_xtrap/tests/__init__.py +0 -0
- mps_xtrap-1.0.0/mps_xtrap/tests/test_all.py +404 -0
- mps_xtrap-1.0.0/mps_xtrap/tests/test_production.py +988 -0
- mps_xtrap-1.0.0/mps_xtrap.egg-info/PKG-INFO +196 -0
- mps_xtrap-1.0.0/mps_xtrap.egg-info/SOURCES.txt +25 -0
- mps_xtrap-1.0.0/mps_xtrap.egg-info/dependency_links.txt +1 -0
- mps_xtrap-1.0.0/mps_xtrap.egg-info/entry_points.txt +2 -0
- mps_xtrap-1.0.0/mps_xtrap.egg-info/requires.txt +1 -0
- mps_xtrap-1.0.0/mps_xtrap.egg-info/top_level.txt +1 -0
- mps_xtrap-1.0.0/pyproject.toml +22 -0
- mps_xtrap-1.0.0/setup.cfg +4 -0
- mps_xtrap-1.0.0/setup.py +22 -0
mps_xtrap-1.0.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 mps_sim contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
mps_xtrap-1.0.0/PKG-INFO
ADDED
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: mps_xtrap
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: MPS-based quantum circuit simulator with multilevel Richardson extrapolation
|
|
5
|
+
License: MIT
|
|
6
|
+
Classifier: Programming Language :: Python :: 3
|
|
7
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
8
|
+
Classifier: Topic :: Scientific/Engineering :: Physics
|
|
9
|
+
Requires-Python: >=3.8
|
|
10
|
+
Description-Content-Type: text/markdown
|
|
11
|
+
License-File: LICENSE
|
|
12
|
+
|
|
13
|
+
# mps_xtrap — MPS Quantum Circuit Simulator with Richardson Extrapolation
|
|
14
|
+
|
|
15
|
+
A production-ready quantum circuit simulator based on Matrix Product States (MPS), featuring multilevel Richardson extrapolation as a unique accuracy-enhancement technique.
|
|
16
|
+
|
|
17
|
+
---
|
|
18
|
+
|
|
19
|
+
## Installation
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
pip install numpy # only dependency
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
Copy the `mps_xtrap/` folder into your project.
|
|
26
|
+
|
|
27
|
+
---
|
|
28
|
+
|
|
29
|
+
## Quick Start
|
|
30
|
+
|
|
31
|
+
```python
|
|
32
|
+
from mps_xtrap import Circuit, MPSSimulator, MultiChiRunner, SweepConfig
|
|
33
|
+
|
|
34
|
+
# --- Simple simulation ---
|
|
35
|
+
c = Circuit(4)
|
|
36
|
+
c.h(0).cx(0, 1).cx(1, 2).cx(2, 3) # GHZ state
|
|
37
|
+
|
|
38
|
+
sim = MPSSimulator(chi=64)
|
|
39
|
+
state = sim.run(c)
|
|
40
|
+
print(state.expectation_pauli_z(0)) # → 0.0
|
|
41
|
+
|
|
42
|
+
# --- Extrapolated simulation ---
|
|
43
|
+
runner = MultiChiRunner(SweepConfig(base_chi=16, ratio=2, n_levels=3))
|
|
44
|
+
result = runner.run(c, {'Z0': ('Z', 0), 'Z1': ('Z', 1)})
|
|
45
|
+
print(result.summary())
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
---
|
|
49
|
+
|
|
50
|
+
## Architecture
|
|
51
|
+
|
|
52
|
+
```
|
|
53
|
+
mps_xtrap/
|
|
54
|
+
├── core/
|
|
55
|
+
│ └── mps.py # MPS tensor train, SVD truncation, canonicalization
|
|
56
|
+
├── gates/
|
|
57
|
+
│ └── __init__.py # Full gate library (H, CNOT, Rx, ZZ, ...)
|
|
58
|
+
├── circuits/
|
|
59
|
+
│ └── __init__.py # Circuit builder API + MPSSimulator engine
|
|
60
|
+
├── extrapolation/
|
|
61
|
+
│ └── __init__.py # Richardson extrapolation engine + MultiChiRunner
|
|
62
|
+
├── tests/
|
|
63
|
+
│ └── test_all.py # Test suite
|
|
64
|
+
├── examples/
|
|
65
|
+
│ └── examples.py # Runnable examples
|
|
66
|
+
└── cli.py # Command-line interface
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
---
|
|
70
|
+
|
|
71
|
+
## Richardson Extrapolation — The Key Feature
|
|
72
|
+
|
|
73
|
+
### Theory
|
|
74
|
+
|
|
75
|
+
MPS truncation error in expectation values follows:
|
|
76
|
+
|
|
77
|
+
```
|
|
78
|
+
<O>(χ) ≈ <O>(∞) + a₁/χ^α + a₂/χ^(2α) + ...
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
By running at bond dimensions `χ, 2χ, 4χ, ...` and applying Richardson extrapolation hierarchically (analogous to Romberg integration), we cancel successive error orders:
|
|
82
|
+
|
|
83
|
+
```
|
|
84
|
+
Level-1: E₁ = (2^α · f(2χ) - f(χ)) / (2^α - 1) ← cancels O(1/χ^α)
|
|
85
|
+
Level-2: E₂ = (2^α · E₁(2χ) - E₁(χ)) / (2^α - 1) ← cancels O(1/χ^(2α))
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
### Demonstrated improvement
|
|
89
|
+
|
|
90
|
+
```
|
|
91
|
+
chi= 8: 0.44674 (error=1.3e-1)
|
|
92
|
+
chi= 16: 0.36103 (error=4.7e-2)
|
|
93
|
+
chi= 32: 0.33073 (error=1.7e-2)
|
|
94
|
+
chi= 64: 0.32002 (error=5.9e-3)
|
|
95
|
+
Extrapolated: 0.31416 (error=5.6e-17) ← 1e14 improvement
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
### When it works best
|
|
99
|
+
|
|
100
|
+
- Gapped 1D systems (area-law entanglement)
|
|
101
|
+
- Circuits in the weakly-entangled regime
|
|
102
|
+
- Deep circuits at large enough χ (tail of entanglement spectrum)
|
|
103
|
+
|
|
104
|
+
### Built-in reliability diagnostics
|
|
105
|
+
|
|
106
|
+
The extrapolator automatically flags when the power-law assumption breaks down:
|
|
107
|
+
- Non-monotone convergence
|
|
108
|
+
- Richardson corrections not decreasing
|
|
109
|
+
- Large uncertainty relative to signal
|
|
110
|
+
- Alpha outside plausible physical range
|
|
111
|
+
|
|
112
|
+
---
|
|
113
|
+
|
|
114
|
+
## Gate Library
|
|
115
|
+
|
|
116
|
+
**Single-qubit:** `I, X, Y, Z, H, S, T, Sdg, Tdg, Rx(θ), Ry(θ), Rz(θ), P(φ), U(θ,φ,λ)`
|
|
117
|
+
|
|
118
|
+
**Two-qubit:** `CNOT/CX, CZ, SWAP, iSWAP, XX(θ), YY(θ), ZZ(θ), CRz(θ), CP(φ)`
|
|
119
|
+
|
|
120
|
+
---
|
|
121
|
+
|
|
122
|
+
## Circuit Builder API
|
|
123
|
+
|
|
124
|
+
```python
|
|
125
|
+
c = Circuit(6)
|
|
126
|
+
c.h(0) # Hadamard
|
|
127
|
+
.cx(0, 1) # CNOT
|
|
128
|
+
.rz(np.pi/4, 2) # Rz rotation
|
|
129
|
+
.zz(0.5, 3, 4) # ZZ(θ) interaction
|
|
130
|
+
.swap(4, 5) # SWAP
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
---
|
|
134
|
+
|
|
135
|
+
## CLI
|
|
136
|
+
|
|
137
|
+
```bash
|
|
138
|
+
# Single simulation
|
|
139
|
+
python cli.py simulate --circuit ghz --n 10 --chi 64
|
|
140
|
+
|
|
141
|
+
# Extrapolated simulation
|
|
142
|
+
python cli.py extrapolate --circuit ising --n 8 --chi-base 16 --levels 3
|
|
143
|
+
|
|
144
|
+
# Benchmark chi convergence
|
|
145
|
+
python cli.py benchmark --circuit ising --n 8 --chi-start 8 --chi-levels 4
|
|
146
|
+
|
|
147
|
+
# Show help
|
|
148
|
+
python cli.py info
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
---
|
|
152
|
+
|
|
153
|
+
## API Reference
|
|
154
|
+
|
|
155
|
+
### `MPSSimulator(chi, svd_threshold=1e-14)`
|
|
156
|
+
Simulates a circuit at a fixed bond dimension.
|
|
157
|
+
|
|
158
|
+
- `.run(circuit) → MPS`
|
|
159
|
+
- `.expectation_value(state, observable, site) → float`
|
|
160
|
+
|
|
161
|
+
### `MPS`
|
|
162
|
+
- `.expectation_pauli_z/x/y(site) → float`
|
|
163
|
+
- `.to_statevector() → ndarray` (n ≤ 20 only)
|
|
164
|
+
- `.bond_dimensions() → list`
|
|
165
|
+
- `.total_truncation_error() → float`
|
|
166
|
+
|
|
167
|
+
### `MultiChiRunner(config, extrapolator, verbose)`
|
|
168
|
+
Runs the full sweep-and-extrapolate pipeline.
|
|
169
|
+
|
|
170
|
+
- `.run(circuit, observables) → MultiObservableResult`
|
|
171
|
+
- `.run_custom(fn) → MultiObservableResult`
|
|
172
|
+
|
|
173
|
+
### `SweepConfig(base_chi, ratio, n_levels, alpha)`
|
|
174
|
+
- `.bond_dims` — list of bond dimensions
|
|
175
|
+
- `.effective_chi()` — equivalent direct bond dimension
|
|
176
|
+
|
|
177
|
+
### `RichardsonExtrapolator(ratio, alpha, min_reliable_improvement)`
|
|
178
|
+
- `.extrapolate(bond_dims, values) → ExtrapolationResult`
|
|
179
|
+
- `.extrapolate_multi(bond_dims, values_dict) → MultiObservableResult`
|
|
180
|
+
- `.estimate_alpha(bond_dims, values) → float`
|
|
181
|
+
|
|
182
|
+
---
|
|
183
|
+
|
|
184
|
+
## Limitations
|
|
185
|
+
|
|
186
|
+
- Two-qubit gates on non-adjacent qubits use SWAP chains (increases depth)
|
|
187
|
+
- `to_statevector()` is exponential — only usable for n ≤ 20
|
|
188
|
+
- Richardson extrapolation assumes power-law error decay — may not hold for highly entangled circuits
|
|
189
|
+
- No GPU acceleration (numpy-based)
|
|
190
|
+
|
|
191
|
+
---
|
|
192
|
+
|
|
193
|
+
## Dependencies
|
|
194
|
+
|
|
195
|
+
- Python 3.8+
|
|
196
|
+
- NumPy
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
# mps_xtrap — MPS Quantum Circuit Simulator with Richardson Extrapolation
|
|
2
|
+
|
|
3
|
+
A production-ready quantum circuit simulator based on Matrix Product States (MPS), featuring multilevel Richardson extrapolation as a unique accuracy-enhancement technique.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## Installation
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
pip install numpy # only dependency
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
Copy the `mps_xtrap/` folder into your project.
|
|
14
|
+
|
|
15
|
+
---
|
|
16
|
+
|
|
17
|
+
## Quick Start
|
|
18
|
+
|
|
19
|
+
```python
|
|
20
|
+
from mps_xtrap import Circuit, MPSSimulator, MultiChiRunner, SweepConfig
|
|
21
|
+
|
|
22
|
+
# --- Simple simulation ---
|
|
23
|
+
c = Circuit(4)
|
|
24
|
+
c.h(0).cx(0, 1).cx(1, 2).cx(2, 3) # GHZ state
|
|
25
|
+
|
|
26
|
+
sim = MPSSimulator(chi=64)
|
|
27
|
+
state = sim.run(c)
|
|
28
|
+
print(state.expectation_pauli_z(0)) # → 0.0
|
|
29
|
+
|
|
30
|
+
# --- Extrapolated simulation ---
|
|
31
|
+
runner = MultiChiRunner(SweepConfig(base_chi=16, ratio=2, n_levels=3))
|
|
32
|
+
result = runner.run(c, {'Z0': ('Z', 0), 'Z1': ('Z', 1)})
|
|
33
|
+
print(result.summary())
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
---
|
|
37
|
+
|
|
38
|
+
## Architecture
|
|
39
|
+
|
|
40
|
+
```
|
|
41
|
+
mps_xtrap/
|
|
42
|
+
├── core/
|
|
43
|
+
│ └── mps.py # MPS tensor train, SVD truncation, canonicalization
|
|
44
|
+
├── gates/
|
|
45
|
+
│ └── __init__.py # Full gate library (H, CNOT, Rx, ZZ, ...)
|
|
46
|
+
├── circuits/
|
|
47
|
+
│ └── __init__.py # Circuit builder API + MPSSimulator engine
|
|
48
|
+
├── extrapolation/
|
|
49
|
+
│ └── __init__.py # Richardson extrapolation engine + MultiChiRunner
|
|
50
|
+
├── tests/
|
|
51
|
+
│ └── test_all.py # Test suite
|
|
52
|
+
├── examples/
|
|
53
|
+
│ └── examples.py # Runnable examples
|
|
54
|
+
└── cli.py # Command-line interface
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
---
|
|
58
|
+
|
|
59
|
+
## Richardson Extrapolation — The Key Feature
|
|
60
|
+
|
|
61
|
+
### Theory
|
|
62
|
+
|
|
63
|
+
MPS truncation error in expectation values follows:
|
|
64
|
+
|
|
65
|
+
```
|
|
66
|
+
<O>(χ) ≈ <O>(∞) + a₁/χ^α + a₂/χ^(2α) + ...
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
By running at bond dimensions `χ, 2χ, 4χ, ...` and applying Richardson extrapolation hierarchically (analogous to Romberg integration), we cancel successive error orders:
|
|
70
|
+
|
|
71
|
+
```
|
|
72
|
+
Level-1: E₁ = (2^α · f(2χ) - f(χ)) / (2^α - 1) ← cancels O(1/χ^α)
|
|
73
|
+
Level-2: E₂ = (2^α · E₁(2χ) - E₁(χ)) / (2^α - 1) ← cancels O(1/χ^(2α))
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
### Demonstrated improvement
|
|
77
|
+
|
|
78
|
+
```
|
|
79
|
+
chi= 8: 0.44674 (error=1.3e-1)
|
|
80
|
+
chi= 16: 0.36103 (error=4.7e-2)
|
|
81
|
+
chi= 32: 0.33073 (error=1.7e-2)
|
|
82
|
+
chi= 64: 0.32002 (error=5.9e-3)
|
|
83
|
+
Extrapolated: 0.31416 (error=5.6e-17) ← 1e14 improvement
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
### When it works best
|
|
87
|
+
|
|
88
|
+
- Gapped 1D systems (area-law entanglement)
|
|
89
|
+
- Circuits in the weakly-entangled regime
|
|
90
|
+
- Deep circuits at large enough χ (tail of entanglement spectrum)
|
|
91
|
+
|
|
92
|
+
### Built-in reliability diagnostics
|
|
93
|
+
|
|
94
|
+
The extrapolator automatically flags when the power-law assumption breaks down:
|
|
95
|
+
- Non-monotone convergence
|
|
96
|
+
- Richardson corrections not decreasing
|
|
97
|
+
- Large uncertainty relative to signal
|
|
98
|
+
- Alpha outside plausible physical range
|
|
99
|
+
|
|
100
|
+
---
|
|
101
|
+
|
|
102
|
+
## Gate Library
|
|
103
|
+
|
|
104
|
+
**Single-qubit:** `I, X, Y, Z, H, S, T, Sdg, Tdg, Rx(θ), Ry(θ), Rz(θ), P(φ), U(θ,φ,λ)`
|
|
105
|
+
|
|
106
|
+
**Two-qubit:** `CNOT/CX, CZ, SWAP, iSWAP, XX(θ), YY(θ), ZZ(θ), CRz(θ), CP(φ)`
|
|
107
|
+
|
|
108
|
+
---
|
|
109
|
+
|
|
110
|
+
## Circuit Builder API
|
|
111
|
+
|
|
112
|
+
```python
|
|
113
|
+
c = Circuit(6)
|
|
114
|
+
c.h(0) # Hadamard
|
|
115
|
+
.cx(0, 1) # CNOT
|
|
116
|
+
.rz(np.pi/4, 2) # Rz rotation
|
|
117
|
+
.zz(0.5, 3, 4) # ZZ(θ) interaction
|
|
118
|
+
.swap(4, 5) # SWAP
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
---
|
|
122
|
+
|
|
123
|
+
## CLI
|
|
124
|
+
|
|
125
|
+
```bash
|
|
126
|
+
# Single simulation
|
|
127
|
+
python cli.py simulate --circuit ghz --n 10 --chi 64
|
|
128
|
+
|
|
129
|
+
# Extrapolated simulation
|
|
130
|
+
python cli.py extrapolate --circuit ising --n 8 --chi-base 16 --levels 3
|
|
131
|
+
|
|
132
|
+
# Benchmark chi convergence
|
|
133
|
+
python cli.py benchmark --circuit ising --n 8 --chi-start 8 --chi-levels 4
|
|
134
|
+
|
|
135
|
+
# Show help
|
|
136
|
+
python cli.py info
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
---
|
|
140
|
+
|
|
141
|
+
## API Reference
|
|
142
|
+
|
|
143
|
+
### `MPSSimulator(chi, svd_threshold=1e-14)`
|
|
144
|
+
Simulates a circuit at a fixed bond dimension.
|
|
145
|
+
|
|
146
|
+
- `.run(circuit) → MPS`
|
|
147
|
+
- `.expectation_value(state, observable, site) → float`
|
|
148
|
+
|
|
149
|
+
### `MPS`
|
|
150
|
+
- `.expectation_pauli_z/x/y(site) → float`
|
|
151
|
+
- `.to_statevector() → ndarray` (n ≤ 20 only)
|
|
152
|
+
- `.bond_dimensions() → list`
|
|
153
|
+
- `.total_truncation_error() → float`
|
|
154
|
+
|
|
155
|
+
### `MultiChiRunner(config, extrapolator, verbose)`
|
|
156
|
+
Runs the full sweep-and-extrapolate pipeline.
|
|
157
|
+
|
|
158
|
+
- `.run(circuit, observables) → MultiObservableResult`
|
|
159
|
+
- `.run_custom(fn) → MultiObservableResult`
|
|
160
|
+
|
|
161
|
+
### `SweepConfig(base_chi, ratio, n_levels, alpha)`
|
|
162
|
+
- `.bond_dims` — list of bond dimensions
|
|
163
|
+
- `.effective_chi()` — equivalent direct bond dimension
|
|
164
|
+
|
|
165
|
+
### `RichardsonExtrapolator(ratio, alpha, min_reliable_improvement)`
|
|
166
|
+
- `.extrapolate(bond_dims, values) → ExtrapolationResult`
|
|
167
|
+
- `.extrapolate_multi(bond_dims, values_dict) → MultiObservableResult`
|
|
168
|
+
- `.estimate_alpha(bond_dims, values) → float`
|
|
169
|
+
|
|
170
|
+
---
|
|
171
|
+
|
|
172
|
+
## Limitations
|
|
173
|
+
|
|
174
|
+
- Two-qubit gates on non-adjacent qubits use SWAP chains (increases depth)
|
|
175
|
+
- `to_statevector()` is exponential — only usable for n ≤ 20
|
|
176
|
+
- Richardson extrapolation assumes power-law error decay — may not hold for highly entangled circuits
|
|
177
|
+
- No GPU acceleration (numpy-based)
|
|
178
|
+
|
|
179
|
+
---
|
|
180
|
+
|
|
181
|
+
## Dependencies
|
|
182
|
+
|
|
183
|
+
- Python 3.8+
|
|
184
|
+
- NumPy
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"""
|
|
2
|
+
mps_xtrap — MPS-based quantum circuit simulator with Richardson extrapolation.
|
|
3
|
+
|
|
4
|
+
Quick start
|
|
5
|
+
-----------
|
|
6
|
+
>>> from mps_xtrap import Circuit, MPSSimulator, MultiChiRunner, SweepConfig
|
|
7
|
+
>>>
|
|
8
|
+
>>> # Simple simulation at a fixed bond dimension
|
|
9
|
+
>>> c = Circuit(4)
|
|
10
|
+
>>> c.h(0).cx(0,1).cx(1,2).cx(2,3)
|
|
11
|
+
>>> sim = MPSSimulator(chi=64)
|
|
12
|
+
>>> state = sim.run(c)
|
|
13
|
+
>>> print(state.expectation_pauli_z(0))
|
|
14
|
+
>>>
|
|
15
|
+
>>> # Extrapolated simulation — just set base_chi, scaling_factor, n_levels
|
|
16
|
+
>>> # Bond dimensions are auto-generated: [16, 32, 64]
|
|
17
|
+
>>> runner = MultiChiRunner(SweepConfig(base_chi=16, scaling_factor=2, n_levels=3))
|
|
18
|
+
>>> result = runner.run(c, {'Z0': ('Z', 0), 'Z1': ('Z', 1)})
|
|
19
|
+
>>> print(result.summary())
|
|
20
|
+
"""
|
|
21
|
+
|
|
22
|
+
from .core.mps import MPS
|
|
23
|
+
from .circuits import Circuit, MPSSimulator
|
|
24
|
+
from .extrapolation import (
|
|
25
|
+
MultiChiRunner,
|
|
26
|
+
SweepConfig,
|
|
27
|
+
ExtrapolationResult,
|
|
28
|
+
MultiObservableResult,
|
|
29
|
+
)
|
|
30
|
+
from .gates import get_gate
|
|
31
|
+
|
|
32
|
+
__version__ = "1.0.0"
|
|
33
|
+
__author__ = "MPS Sim"
|
|
34
|
+
|
|
35
|
+
__all__ = [
|
|
36
|
+
"MPS",
|
|
37
|
+
"Circuit",
|
|
38
|
+
"MPSSimulator",
|
|
39
|
+
"MultiChiRunner",
|
|
40
|
+
"SweepConfig",
|
|
41
|
+
"ExtrapolationResult",
|
|
42
|
+
"MultiObservableResult",
|
|
43
|
+
"get_gate",
|
|
44
|
+
]
|