qec 0.1__tar.gz → 0.3.3__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.
- qec-0.3.3/PKG-INFO +177 -0
- qec-0.3.3/README.md +139 -0
- qec-0.3.3/pyproject.toml +44 -0
- qec-0.3.3/src/qec/__init__.py +2 -0
- qec-0.3.3/src/qec/code_constructions/__init__.py +17 -0
- qec-0.3.3/src/qec/code_constructions/css_code.py +959 -0
- qec-0.3.3/src/qec/code_constructions/hgp_code.py +344 -0
- qec-0.3.3/src/qec/code_constructions/periodic_surface_xzzx.py +100 -0
- qec-0.3.3/src/qec/code_constructions/rotated_xzzx.py +122 -0
- qec-0.3.3/src/qec/code_constructions/stabilizer_code.py +654 -0
- qec-0.3.3/src/qec/code_constructions/surface_code.py +66 -0
- qec-0.3.3/src/qec/code_constructions/toric_code.py +56 -0
- qec-0.3.3/src/qec/code_instances/__init__.py +5 -0
- qec-0.3.3/src/qec/code_instances/five_qubit_code.py +67 -0
- qec-0.3.3/src/qec/code_instances/saved_codes/1.json +30 -0
- qec-0.3.3/src/qec/code_instances/saved_codes/2.json +30 -0
- qec-0.3.3/src/qec/code_instances/saved_codes/3.json +30 -0
- qec-0.3.3/src/qec/code_instances/saved_codes/4.json +30 -0
- qec-0.3.3/src/qec/codetables_de/__init__.py +3 -0
- qec-0.3.3/src/qec/codetables_de/codetables_de.py +97 -0
- qec-0.3.3/src/qec/utils/__init__.py +6 -0
- qec-0.3.3/src/qec/utils/binary_pauli_utils.py +404 -0
- qec-0.3.3/src/qec/utils/codetables_de_utils.py +272 -0
- qec-0.3.3/src/qec/utils/load_code_util.py +142 -0
- qec-0.3.3/src/qec/utils/sparse_binary_utils.py +80 -0
- qec-0.3.3/src/qec.egg-info/PKG-INFO +177 -0
- qec-0.3.3/src/qec.egg-info/SOURCES.txt +30 -0
- qec-0.3.3/src/qec.egg-info/requires.txt +5 -0
- qec-0.1/PKG-INFO +0 -46
- qec-0.1/README.md +0 -11
- qec-0.1/pyproject.toml +0 -26
- qec-0.1/src/qec/__init__.py +0 -0
- qec-0.1/src/qec/codes.py +0 -48
- qec-0.1/src/qec/css.py +0 -132
- qec-0.1/src/qec/hgp.py +0 -123
- qec-0.1/src/qec/stab_code.py +0 -143
- qec-0.1/src/qec/util.py +0 -37
- qec-0.1/src/qec.egg-info/PKG-INFO +0 -46
- qec-0.1/src/qec.egg-info/SOURCES.txt +0 -17
- qec-0.1/src/qec.egg-info/requires.txt +0 -3
- qec-0.1/tests/test.py +0 -50
- qec-0.1/tests/test_stabiliser_code.py +0 -39
- qec-0.1/tests/test_util.py +0 -74
- {qec-0.1 → qec-0.3.3}/LICENSE +0 -0
- {qec-0.1 → qec-0.3.3}/setup.cfg +0 -0
- {qec-0.1 → qec-0.3.3}/src/qec.egg-info/dependency_links.txt +0 -0
- {qec-0.1 → qec-0.3.3}/src/qec.egg-info/top_level.txt +0 -0
qec-0.3.3/PKG-INFO
ADDED
@@ -0,0 +1,177 @@
|
|
1
|
+
Metadata-Version: 2.4
|
2
|
+
Name: qec
|
3
|
+
Version: 0.3.3
|
4
|
+
Summary: Python Tools for Quantum Error Correction
|
5
|
+
Author-email: Joschka Roffe <joschka@roffe.eu>, Tamas Noszko <T.K.Noszko@sms.ed.ac.uk>, Liam Veeder-Sweeney <L.D.Veeder-Sweeney@sms.ed.ac.uk>
|
6
|
+
License: MIT License
|
7
|
+
|
8
|
+
Copyright (c) 2023 qec.Codes
|
9
|
+
|
10
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
11
|
+
of this software and associated documentation files (the "Software"), to deal
|
12
|
+
in the Software without restriction, including without limitation the rights
|
13
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
14
|
+
copies of the Software, and to permit persons to whom the Software is
|
15
|
+
furnished to do so, subject to the following conditions:
|
16
|
+
|
17
|
+
The above copyright notice and this permission notice shall be included in all
|
18
|
+
copies or substantial portions of the Software.
|
19
|
+
|
20
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
21
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
22
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
23
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
24
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
25
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
26
|
+
SOFTWARE.
|
27
|
+
|
28
|
+
Classifier: Development Status :: 4 - Beta
|
29
|
+
Requires-Python: >=3.9
|
30
|
+
Description-Content-Type: text/markdown
|
31
|
+
License-File: LICENSE
|
32
|
+
Requires-Dist: ldpc>=2.2.7
|
33
|
+
Requires-Dist: numpy>=1.24.0
|
34
|
+
Requires-Dist: scipy>=1.9.3
|
35
|
+
Requires-Dist: requests
|
36
|
+
Requires-Dist: beautifulsoup4
|
37
|
+
Dynamic: license-file
|
38
|
+
|
39
|
+

|
40
|
+
|
41
|
+
<p align="center">
|
42
|
+
QEC: Python Tools for Quantum Error Correction
|
43
|
+
<br />
|
44
|
+
<a href="https://qec.codes/">Website</a>
|
45
|
+
·
|
46
|
+
<a href="#features">Features</a>
|
47
|
+
·
|
48
|
+
<a href="#installation">Installation</a>
|
49
|
+
·
|
50
|
+
<a href="#examples">Examples</a>
|
51
|
+
</p>
|
52
|
+
</p>
|
53
|
+
|
54
|
+
# Features
|
55
|
+
|
56
|
+
## Base functionality: code constructions and "fundamental" analysis
|
57
|
+
We currently provide the construction methods for the stabilizer generators of the QEC code families below, along with optimized methods to obtain their fundamental properties. All the classes allow you to:
|
58
|
+
|
59
|
+
- obtain the physical qubit count
|
60
|
+
- obtain the logical qubit count
|
61
|
+
- calculate the exact code distance
|
62
|
+
- estimate the minimum code distance
|
63
|
+
- obtain a logical basis
|
64
|
+
|
65
|
+
The classes (along with their extra methods) are:
|
66
|
+
|
67
|
+
- Hyperprgarph Product (HGP) codes, with methods:
|
68
|
+
- construct the x and z stabiliser matrices from the seed codes
|
69
|
+
- obtain the canonical basis (work in progress)
|
70
|
+
|
71
|
+
- Surface codes
|
72
|
+
- Unrotated Surface code
|
73
|
+
- Periodic Surface XZZX code
|
74
|
+
- Rotated Surface XZZX code
|
75
|
+
|
76
|
+
- Toric code
|
77
|
+
|
78
|
+
- Calderbank-Shor-Steane (CSS) codes
|
79
|
+
- check that the seed codes satisfy the CSS criteria
|
80
|
+
|
81
|
+
- Stabiliser codes
|
82
|
+
- check that the input stabiliser matrix is valid
|
83
|
+
|
84
|
+
## Circuit compilation
|
85
|
+
|
86
|
+
>
|
87
|
+
> _Note:_ this functionality is still work in progress. The corresponding code is not part of the `main` branch - you can find it on the `circuit_compilation` branch to play around.
|
88
|
+
>
|
89
|
+
|
90
|
+
Currently we only support circuit compilation for memory experiments of:
|
91
|
+
|
92
|
+
- HGP codes with:
|
93
|
+
- "coloration circuit" stabilizer schedule (twice the depth of the most optimal "cardinal circuit" method)
|
94
|
+
- _under development:_ "cardinal circuit" stabilizer schedule
|
95
|
+
|
96
|
+
One can either compile noisy or noisless circuits (for further compilation to one's own needs). To create a nosiy circuit one needs to construct their own noise model, or use one of the available presets:
|
97
|
+
- `uniform_depolarizing_noise`
|
98
|
+
- `non_uniform_depolarizing_noise` under development
|
99
|
+
- `phenomenological_noise`
|
100
|
+
|
101
|
+
For a more detailed example please see the `demo.ipynb` [notebook](https://github.com/qec-codes/qec/blob/circuit_compilation/demo/demo.ipynb), inside the `demo/` folder of the `circuit_compilation` branch.
|
102
|
+
|
103
|
+
# Installation
|
104
|
+
|
105
|
+
Simply do:
|
106
|
+
```bash
|
107
|
+
pip install qec
|
108
|
+
```
|
109
|
+
|
110
|
+
or obtain a local copy of the package by cloning it, then navigate into the created folder:
|
111
|
+
|
112
|
+
```bash
|
113
|
+
git clone git@github.com:qec-codes/qec.git
|
114
|
+
cd qec
|
115
|
+
```
|
116
|
+
|
117
|
+
Finally, install the package:
|
118
|
+
|
119
|
+
```bash
|
120
|
+
pip install -e .
|
121
|
+
```
|
122
|
+
|
123
|
+
# Examples
|
124
|
+
|
125
|
+
## Base functionality:
|
126
|
+
|
127
|
+
In this example we are going to create the Steane code, and obtain its fundamental code properties. We start by initialising its seed matrices (the [7, 4, 3] Hamming code):
|
128
|
+
```python
|
129
|
+
In [1]: import numpy as np
|
130
|
+
In [2]: from qec.code_constructions import CSSCode
|
131
|
+
|
132
|
+
In [3]: hamming_code = np.array([[1, 0, 0, 1, 0, 1, 1],
|
133
|
+
[0, 1, 0, 1, 1, 0, 1],
|
134
|
+
[0, 0, 1, 0, 1, 1, 1]])
|
135
|
+
```
|
136
|
+
as the Steane code is part of the CSS code family, we can use the `CSSCode` class:
|
137
|
+
|
138
|
+
```python
|
139
|
+
In [4]: steane_code = CSSCode(x_stabilizer_matrix = hamming_code,
|
140
|
+
z_stabilizer_matrix = hamming_code,
|
141
|
+
name = "Steane")
|
142
|
+
In [5]: steane_code.compute_exact_code_distance()
|
143
|
+
In [6]: print(steane_code)
|
144
|
+
|
145
|
+
Out [7]: Steane Code: [[N=7, K=1, dx<=3, dz<=3]]
|
146
|
+
```
|
147
|
+
|
148
|
+
we can see that all the fundamental properties (N - physical qubit number, K - logical qubit number, dx - X distance, dz - Z distance). We can continue our analysis by taking a look at the x and z logical basis of the code:
|
149
|
+
|
150
|
+
```python
|
151
|
+
In [7]: print(steane_code.x_logical_operator_basis.toarray())
|
152
|
+
Out [8]: [[1 1 0 1 0 0 0]]
|
153
|
+
In [9]: print(steane_code.z_logical_operator_basis.toarray())
|
154
|
+
Out [10]: [[1 1 0 1 0 0 0]]
|
155
|
+
```
|
156
|
+
|
157
|
+
## Circuit compilation:
|
158
|
+
|
159
|
+
```python
|
160
|
+
In [10]: from qec.code_constructions import HypergraphProductCode
|
161
|
+
In [11]: from qec.circuit_compilation import MemoryExperiment
|
162
|
+
|
163
|
+
In [12]: hgp_example_code = HypergraphProductCode(hamming_code, hamming_code)
|
164
|
+
|
165
|
+
In [12]: hgp_memory_example = MemoryExperiment(hgp_example_code)
|
166
|
+
|
167
|
+
In [13]: hgp_X_mem_circuit = hgp_memory_example.circuit(basis = 'X', rounds = 1, noise = False)
|
168
|
+
```
|
169
|
+
|
170
|
+
To see the output circuit and a more detailed example (including a simulation) see the `demo.ipynb` [notebook](https://github.com/qec-codes/qec/blob/circuit_compilation/demo/demo.ipynb), inside the `demo/` folder of the `circuit_compilation` branch.
|
171
|
+
|
172
|
+
|
173
|
+
|
174
|
+
|
175
|
+
|
176
|
+
|
177
|
+
|
qec-0.3.3/README.md
ADDED
@@ -0,0 +1,139 @@
|
|
1
|
+

|
2
|
+
|
3
|
+
<p align="center">
|
4
|
+
QEC: Python Tools for Quantum Error Correction
|
5
|
+
<br />
|
6
|
+
<a href="https://qec.codes/">Website</a>
|
7
|
+
·
|
8
|
+
<a href="#features">Features</a>
|
9
|
+
·
|
10
|
+
<a href="#installation">Installation</a>
|
11
|
+
·
|
12
|
+
<a href="#examples">Examples</a>
|
13
|
+
</p>
|
14
|
+
</p>
|
15
|
+
|
16
|
+
# Features
|
17
|
+
|
18
|
+
## Base functionality: code constructions and "fundamental" analysis
|
19
|
+
We currently provide the construction methods for the stabilizer generators of the QEC code families below, along with optimized methods to obtain their fundamental properties. All the classes allow you to:
|
20
|
+
|
21
|
+
- obtain the physical qubit count
|
22
|
+
- obtain the logical qubit count
|
23
|
+
- calculate the exact code distance
|
24
|
+
- estimate the minimum code distance
|
25
|
+
- obtain a logical basis
|
26
|
+
|
27
|
+
The classes (along with their extra methods) are:
|
28
|
+
|
29
|
+
- Hyperprgarph Product (HGP) codes, with methods:
|
30
|
+
- construct the x and z stabiliser matrices from the seed codes
|
31
|
+
- obtain the canonical basis (work in progress)
|
32
|
+
|
33
|
+
- Surface codes
|
34
|
+
- Unrotated Surface code
|
35
|
+
- Periodic Surface XZZX code
|
36
|
+
- Rotated Surface XZZX code
|
37
|
+
|
38
|
+
- Toric code
|
39
|
+
|
40
|
+
- Calderbank-Shor-Steane (CSS) codes
|
41
|
+
- check that the seed codes satisfy the CSS criteria
|
42
|
+
|
43
|
+
- Stabiliser codes
|
44
|
+
- check that the input stabiliser matrix is valid
|
45
|
+
|
46
|
+
## Circuit compilation
|
47
|
+
|
48
|
+
>
|
49
|
+
> _Note:_ this functionality is still work in progress. The corresponding code is not part of the `main` branch - you can find it on the `circuit_compilation` branch to play around.
|
50
|
+
>
|
51
|
+
|
52
|
+
Currently we only support circuit compilation for memory experiments of:
|
53
|
+
|
54
|
+
- HGP codes with:
|
55
|
+
- "coloration circuit" stabilizer schedule (twice the depth of the most optimal "cardinal circuit" method)
|
56
|
+
- _under development:_ "cardinal circuit" stabilizer schedule
|
57
|
+
|
58
|
+
One can either compile noisy or noisless circuits (for further compilation to one's own needs). To create a nosiy circuit one needs to construct their own noise model, or use one of the available presets:
|
59
|
+
- `uniform_depolarizing_noise`
|
60
|
+
- `non_uniform_depolarizing_noise` under development
|
61
|
+
- `phenomenological_noise`
|
62
|
+
|
63
|
+
For a more detailed example please see the `demo.ipynb` [notebook](https://github.com/qec-codes/qec/blob/circuit_compilation/demo/demo.ipynb), inside the `demo/` folder of the `circuit_compilation` branch.
|
64
|
+
|
65
|
+
# Installation
|
66
|
+
|
67
|
+
Simply do:
|
68
|
+
```bash
|
69
|
+
pip install qec
|
70
|
+
```
|
71
|
+
|
72
|
+
or obtain a local copy of the package by cloning it, then navigate into the created folder:
|
73
|
+
|
74
|
+
```bash
|
75
|
+
git clone git@github.com:qec-codes/qec.git
|
76
|
+
cd qec
|
77
|
+
```
|
78
|
+
|
79
|
+
Finally, install the package:
|
80
|
+
|
81
|
+
```bash
|
82
|
+
pip install -e .
|
83
|
+
```
|
84
|
+
|
85
|
+
# Examples
|
86
|
+
|
87
|
+
## Base functionality:
|
88
|
+
|
89
|
+
In this example we are going to create the Steane code, and obtain its fundamental code properties. We start by initialising its seed matrices (the [7, 4, 3] Hamming code):
|
90
|
+
```python
|
91
|
+
In [1]: import numpy as np
|
92
|
+
In [2]: from qec.code_constructions import CSSCode
|
93
|
+
|
94
|
+
In [3]: hamming_code = np.array([[1, 0, 0, 1, 0, 1, 1],
|
95
|
+
[0, 1, 0, 1, 1, 0, 1],
|
96
|
+
[0, 0, 1, 0, 1, 1, 1]])
|
97
|
+
```
|
98
|
+
as the Steane code is part of the CSS code family, we can use the `CSSCode` class:
|
99
|
+
|
100
|
+
```python
|
101
|
+
In [4]: steane_code = CSSCode(x_stabilizer_matrix = hamming_code,
|
102
|
+
z_stabilizer_matrix = hamming_code,
|
103
|
+
name = "Steane")
|
104
|
+
In [5]: steane_code.compute_exact_code_distance()
|
105
|
+
In [6]: print(steane_code)
|
106
|
+
|
107
|
+
Out [7]: Steane Code: [[N=7, K=1, dx<=3, dz<=3]]
|
108
|
+
```
|
109
|
+
|
110
|
+
we can see that all the fundamental properties (N - physical qubit number, K - logical qubit number, dx - X distance, dz - Z distance). We can continue our analysis by taking a look at the x and z logical basis of the code:
|
111
|
+
|
112
|
+
```python
|
113
|
+
In [7]: print(steane_code.x_logical_operator_basis.toarray())
|
114
|
+
Out [8]: [[1 1 0 1 0 0 0]]
|
115
|
+
In [9]: print(steane_code.z_logical_operator_basis.toarray())
|
116
|
+
Out [10]: [[1 1 0 1 0 0 0]]
|
117
|
+
```
|
118
|
+
|
119
|
+
## Circuit compilation:
|
120
|
+
|
121
|
+
```python
|
122
|
+
In [10]: from qec.code_constructions import HypergraphProductCode
|
123
|
+
In [11]: from qec.circuit_compilation import MemoryExperiment
|
124
|
+
|
125
|
+
In [12]: hgp_example_code = HypergraphProductCode(hamming_code, hamming_code)
|
126
|
+
|
127
|
+
In [12]: hgp_memory_example = MemoryExperiment(hgp_example_code)
|
128
|
+
|
129
|
+
In [13]: hgp_X_mem_circuit = hgp_memory_example.circuit(basis = 'X', rounds = 1, noise = False)
|
130
|
+
```
|
131
|
+
|
132
|
+
To see the output circuit and a more detailed example (including a simulation) see the `demo.ipynb` [notebook](https://github.com/qec-codes/qec/blob/circuit_compilation/demo/demo.ipynb), inside the `demo/` folder of the `circuit_compilation` branch.
|
133
|
+
|
134
|
+
|
135
|
+
|
136
|
+
|
137
|
+
|
138
|
+
|
139
|
+
|
qec-0.3.3/pyproject.toml
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
[project]
|
2
|
+
name = "qec"
|
3
|
+
version = "0.3.3"
|
4
|
+
|
5
|
+
description = "Python Tools for Quantum Error Correction"
|
6
|
+
readme = "README.md"
|
7
|
+
authors = [
|
8
|
+
{ name = "Joschka Roffe", email = "joschka@roffe.eu" },
|
9
|
+
{ name = "Tamas Noszko", email = "T.K.Noszko@sms.ed.ac.uk"},
|
10
|
+
{ name = "Liam Veeder-Sweeney", email = "L.D.Veeder-Sweeney@sms.ed.ac.uk"},
|
11
|
+
]
|
12
|
+
license = { file = "LICENSE" }
|
13
|
+
|
14
|
+
classifiers = [
|
15
|
+
"Development Status :: 4 - Beta",
|
16
|
+
]
|
17
|
+
requires-python = ">=3.9"
|
18
|
+
dependencies = [
|
19
|
+
"ldpc>=2.2.7",
|
20
|
+
"numpy>=1.24.0",
|
21
|
+
"scipy>=1.9.3",
|
22
|
+
"requests",
|
23
|
+
"beautifulsoup4"
|
24
|
+
]
|
25
|
+
|
26
|
+
|
27
|
+
[build-system]
|
28
|
+
requires = ["setuptools"]
|
29
|
+
build-backend = "setuptools.build_meta"
|
30
|
+
|
31
|
+
[tool.setuptools.packages.find]
|
32
|
+
where = ["src"]
|
33
|
+
include = ["qec", "qec.*"]
|
34
|
+
|
35
|
+
[tool.setuptools.package-data]
|
36
|
+
qec = ["code_instances/saved_codes/*json"]
|
37
|
+
|
38
|
+
[tool.pytest.ini_options]
|
39
|
+
pythonpath = [
|
40
|
+
"src"
|
41
|
+
]
|
42
|
+
testpaths = "tests"
|
43
|
+
|
44
|
+
|
@@ -0,0 +1,17 @@
|
|
1
|
+
from qec.code_constructions.stabilizer_code import StabilizerCode
|
2
|
+
from qec.code_constructions.css_code import CSSCode
|
3
|
+
from qec.code_constructions.hgp_code import HypergraphProductCode
|
4
|
+
from qec.code_constructions.surface_code import SurfaceCode
|
5
|
+
from qec.code_constructions.toric_code import ToricCode
|
6
|
+
from qec.code_constructions.periodic_surface_xzzx import PeriodicSurfaceXZZX
|
7
|
+
from qec.code_constructions.rotated_xzzx import RotatedSurfaceXZZX
|
8
|
+
|
9
|
+
__all__ = [
|
10
|
+
StabilizerCode,
|
11
|
+
CSSCode,
|
12
|
+
HypergraphProductCode,
|
13
|
+
SurfaceCode,
|
14
|
+
ToricCode,
|
15
|
+
PeriodicSurfaceXZZX,
|
16
|
+
RotatedSurfaceXZZX,
|
17
|
+
]
|