stimflow 0.1.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.
- stimflow-0.1.0/PKG-INFO +161 -0
- stimflow-0.1.0/README.md +139 -0
- stimflow-0.1.0/requirements.txt +2 -0
- stimflow-0.1.0/setup.cfg +4 -0
- stimflow-0.1.0/setup.py +40 -0
- stimflow-0.1.0/src/stimflow/__init__.py +52 -0
- stimflow-0.1.0/src/stimflow/_chunk/__init__.py +18 -0
- stimflow-0.1.0/src/stimflow/_chunk/_chunk.py +923 -0
- stimflow-0.1.0/src/stimflow/_chunk/_chunk_builder.py +963 -0
- stimflow-0.1.0/src/stimflow/_chunk/_chunk_builder_test.py +313 -0
- stimflow-0.1.0/src/stimflow/_chunk/_chunk_compiler.py +618 -0
- stimflow-0.1.0/src/stimflow/_chunk/_chunk_compiler_test.py +714 -0
- stimflow-0.1.0/src/stimflow/_chunk/_chunk_interface.py +168 -0
- stimflow-0.1.0/src/stimflow/_chunk/_chunk_loop.py +175 -0
- stimflow-0.1.0/src/stimflow/_chunk/_chunk_reflow.py +312 -0
- stimflow-0.1.0/src/stimflow/_chunk/_chunk_reflow_test.py +71 -0
- stimflow-0.1.0/src/stimflow/_chunk/_chunk_test.py +582 -0
- stimflow-0.1.0/src/stimflow/_chunk/_code_util.py +199 -0
- stimflow-0.1.0/src/stimflow/_chunk/_code_util_test.py +176 -0
- stimflow-0.1.0/src/stimflow/_chunk/_flow_metadata.py +29 -0
- stimflow-0.1.0/src/stimflow/_chunk/_flow_util.py +273 -0
- stimflow-0.1.0/src/stimflow/_chunk/_flow_util_test.py +162 -0
- stimflow-0.1.0/src/stimflow/_chunk/_patch.py +182 -0
- stimflow-0.1.0/src/stimflow/_chunk/_patch_test.py +49 -0
- stimflow-0.1.0/src/stimflow/_chunk/_stabilizer_code.py +754 -0
- stimflow-0.1.0/src/stimflow/_chunk/_stabilizer_code_test.py +314 -0
- stimflow-0.1.0/src/stimflow/_chunk/_test_util.py +28 -0
- stimflow-0.1.0/src/stimflow/_chunk/_weave.py +370 -0
- stimflow-0.1.0/src/stimflow/_chunk/_weave_test.py +361 -0
- stimflow-0.1.0/src/stimflow/_core/__init__.py +21 -0
- stimflow-0.1.0/src/stimflow/_core/_circuit_util.py +415 -0
- stimflow-0.1.0/src/stimflow/_core/_circuit_util_test.py +299 -0
- stimflow-0.1.0/src/stimflow/_core/_complex_util.py +119 -0
- stimflow-0.1.0/src/stimflow/_core/_complex_util_test.py +32 -0
- stimflow-0.1.0/src/stimflow/_core/_flow.py +288 -0
- stimflow-0.1.0/src/stimflow/_core/_flow_test.py +7 -0
- stimflow-0.1.0/src/stimflow/_core/_noise.py +676 -0
- stimflow-0.1.0/src/stimflow/_core/_noise_test.py +368 -0
- stimflow-0.1.0/src/stimflow/_core/_pauli_map.py +306 -0
- stimflow-0.1.0/src/stimflow/_core/_pauli_map_test.py +19 -0
- stimflow-0.1.0/src/stimflow/_core/_str_html.py +41 -0
- stimflow-0.1.0/src/stimflow/_core/_str_svg.py +41 -0
- stimflow-0.1.0/src/stimflow/_core/_tile.py +183 -0
- stimflow-0.1.0/src/stimflow/_core/_tile_test.py +18 -0
- stimflow-0.1.0/src/stimflow/_layers/__init__.py +8 -0
- stimflow-0.1.0/src/stimflow/_layers/_data.py +91 -0
- stimflow-0.1.0/src/stimflow/_layers/_data_test.py +24 -0
- stimflow-0.1.0/src/stimflow/_layers/_layer.py +54 -0
- stimflow-0.1.0/src/stimflow/_layers/_layer_circuit.py +808 -0
- stimflow-0.1.0/src/stimflow/_layers/_layer_circuit_test.py +794 -0
- stimflow-0.1.0/src/stimflow/_layers/_layer_det_obs_annotation.py +42 -0
- stimflow-0.1.0/src/stimflow/_layers/_layer_empty.py +25 -0
- stimflow-0.1.0/src/stimflow/_layers/_layer_feedback.py +58 -0
- stimflow-0.1.0/src/stimflow/_layers/_layer_feedback_test.py +7 -0
- stimflow-0.1.0/src/stimflow/_layers/_layer_interact.py +92 -0
- stimflow-0.1.0/src/stimflow/_layers/_layer_interact_swap.py +75 -0
- stimflow-0.1.0/src/stimflow/_layers/_layer_interact_swap_test.py +59 -0
- stimflow-0.1.0/src/stimflow/_layers/_layer_iswap.py +34 -0
- stimflow-0.1.0/src/stimflow/_layers/_layer_loop.py +40 -0
- stimflow-0.1.0/src/stimflow/_layers/_layer_measure.py +54 -0
- stimflow-0.1.0/src/stimflow/_layers/_layer_mpp.py +30 -0
- stimflow-0.1.0/src/stimflow/_layers/_layer_noise.py +33 -0
- stimflow-0.1.0/src/stimflow/_layers/_layer_qubit_coord_annotation.py +36 -0
- stimflow-0.1.0/src/stimflow/_layers/_layer_reset.py +51 -0
- stimflow-0.1.0/src/stimflow/_layers/_layer_rotation.py +89 -0
- stimflow-0.1.0/src/stimflow/_layers/_layer_rotation_test.py +33 -0
- stimflow-0.1.0/src/stimflow/_layers/_layer_shift_coord_annotation.py +45 -0
- stimflow-0.1.0/src/stimflow/_layers/_layer_sqrt_pp.py +57 -0
- stimflow-0.1.0/src/stimflow/_layers/_layer_swap.py +81 -0
- stimflow-0.1.0/src/stimflow/_layers/_layer_tag.py +37 -0
- stimflow-0.1.0/src/stimflow/_layers/_layer_tag_test.py +58 -0
- stimflow-0.1.0/src/stimflow/_layers/_transpile.py +32 -0
- stimflow-0.1.0/src/stimflow/_layers/_transpile_test.py +635 -0
- stimflow-0.1.0/src/stimflow/_viz/_3d_model.py +563 -0
- stimflow-0.1.0/src/stimflow/_viz/_3d_model_test.py +121 -0
- stimflow-0.1.0/src/stimflow/_viz/_3d_model_text_texture.py +2185 -0
- stimflow-0.1.0/src/stimflow/_viz/_3d_model_viewer.py +211 -0
- stimflow-0.1.0/src/stimflow/_viz/__init__.py +12 -0
- stimflow-0.1.0/src/stimflow/_viz/_viz_circuit_html.py +1094 -0
- stimflow-0.1.0/src/stimflow/_viz/_viz_circuit_html_test.py +29 -0
- stimflow-0.1.0/src/stimflow/_viz/_viz_circuit_layer_svg.py +199 -0
- stimflow-0.1.0/src/stimflow/_viz/_viz_patch_svg.py +597 -0
- stimflow-0.1.0/src/stimflow/_viz/_viz_patch_svg_test.py +34 -0
- stimflow-0.1.0/src/stimflow/_viz/_viz_svg.py +175 -0
- stimflow-0.1.0/src/stimflow.egg-info/PKG-INFO +161 -0
- stimflow-0.1.0/src/stimflow.egg-info/SOURCES.txt +87 -0
- stimflow-0.1.0/src/stimflow.egg-info/dependency_links.txt +1 -0
- stimflow-0.1.0/src/stimflow.egg-info/requires.txt +2 -0
- stimflow-0.1.0/src/stimflow.egg-info/top_level.txt +1 -0
stimflow-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: stimflow
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: A library for creating quantum error correction circuits.
|
|
5
|
+
Home-page: https://github.com/quantumlib/stim
|
|
6
|
+
Author: Craig Gidney
|
|
7
|
+
Author-email: craig.gidney@gmail.com
|
|
8
|
+
License: Apache 2
|
|
9
|
+
Requires-Python: >=3.6.0
|
|
10
|
+
Description-Content-Type: text/markdown
|
|
11
|
+
Requires-Dist: pygltflib
|
|
12
|
+
Requires-Dist: stim
|
|
13
|
+
Dynamic: author
|
|
14
|
+
Dynamic: author-email
|
|
15
|
+
Dynamic: description
|
|
16
|
+
Dynamic: description-content-type
|
|
17
|
+
Dynamic: home-page
|
|
18
|
+
Dynamic: license
|
|
19
|
+
Dynamic: requires-dist
|
|
20
|
+
Dynamic: requires-python
|
|
21
|
+
Dynamic: summary
|
|
22
|
+
|
|
23
|
+
stimflow: annealed utilities for creating QEC circuits
|
|
24
|
+
=================================================
|
|
25
|
+
|
|
26
|
+
stimflow is a library for creating quantum error correction circuits.
|
|
27
|
+
|
|
28
|
+
stimflow's design philosophy is to be a tool box, not a black box.
|
|
29
|
+
For example, stimflow does *not* include a `make_surface_code` method.
|
|
30
|
+
Instead it provides tools that can be used to more easily create a surface code circuit from scratch.
|
|
31
|
+
The hope is that these tools then make it easier to create as-yet-unknown constructions in the future.
|
|
32
|
+
|
|
33
|
+
stimflow decomposes the circuit creation problem into making and combining *chunks*.
|
|
34
|
+
A *Chunk* is a circuit combined with stabilizer flow assertions that the circuit is supposed to satisfy.
|
|
35
|
+
stimflow provides tools for making chunks (`stimflow.ChunkBuilder`), verifying chunks (`stimflow.Chunk.verify`), debugging chunks (`stimflow.Chunk.to_html_viewer`), and compiling sequences of chunks into a complete final circuit (`stimflow.ChunkCompiler`).
|
|
36
|
+
|
|
37
|
+
stimflow also includes functionality for:
|
|
38
|
+
|
|
39
|
+
- Transpiling (`stimflow.transpile_to_z_basis_interaction_circuit(...)`)
|
|
40
|
+
- Adding Noise (`stimflow.NoiseModel.uniform_depolarizing(p).noisy_circuit(...)`)
|
|
41
|
+
- Visualizing (`stimflow.make_3d_model`, `stimflow.stim_circuit_html_viewer`)
|
|
42
|
+
|
|
43
|
+
# Documentation
|
|
44
|
+
|
|
45
|
+
See stimflow's [getting started notebook](doc/getting_started.ipynb).
|
|
46
|
+
|
|
47
|
+
See stimflow's [API reference](doc/api.md).
|
|
48
|
+
|
|
49
|
+
# Backwards Compatibility Warning
|
|
50
|
+
|
|
51
|
+
Stimflow does not currently guarantee backwards compatibility.
|
|
52
|
+
There are parts of the library that do not yet feel like they have converged on the "right" way to do it,
|
|
53
|
+
and I want to maintain the freedom to fix them later.
|
|
54
|
+
|
|
55
|
+
# Example Usage: Surface Code Circuit
|
|
56
|
+
|
|
57
|
+
stimflow is not yet provided as a pypi package, so you cannot install it with pip.
|
|
58
|
+
The installation can be done manually by copying the contents of this directory somewhere into your python path.
|
|
59
|
+
|
|
60
|
+
The following is python code that emits a surface code circuit.
|
|
61
|
+
|
|
62
|
+
```python
|
|
63
|
+
import stimflow as sf
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
def make_surface_code(d: int) -> sf.StabilizerCode:
|
|
67
|
+
"""Defines the stabilizers and observables of a surface code."""
|
|
68
|
+
tiles = []
|
|
69
|
+
ds = [0, 1, 1j, 1 + 1j]
|
|
70
|
+
for x in range(-1, d):
|
|
71
|
+
for y in range(-1, d):
|
|
72
|
+
m = x + 1j * y
|
|
73
|
+
qs = [m + d for d in ds]
|
|
74
|
+
qs = [q for q in qs
|
|
75
|
+
if 0 <= q.real < d and 0 <= q.imag < d]
|
|
76
|
+
b = 'XZ'[(x + y) % 2]
|
|
77
|
+
if b == 'X' and x in [-1, d - 1]:
|
|
78
|
+
continue
|
|
79
|
+
if b == 'Z' and y in [-1, d - 1]:
|
|
80
|
+
continue
|
|
81
|
+
tiles.append(sf.Tile(
|
|
82
|
+
data_qubits=qs,
|
|
83
|
+
bases=b,
|
|
84
|
+
measure_qubit=m + 0.5 + 0.5j,
|
|
85
|
+
))
|
|
86
|
+
|
|
87
|
+
patch = sf.Patch(tiles)
|
|
88
|
+
obs_x = sf.PauliMap.from_xs([q for q in patch.data_set if q.real == 0]).with_obs_name('X')
|
|
89
|
+
obs_z = sf.PauliMap.from_zs([q for q in patch.data_set if q.imag == 0]).with_obs_name('Z')
|
|
90
|
+
return sf.StabilizerCode(patch, logicals=[(obs_x, obs_z)])
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
def make_idle_round(d: int) -> sf.Chunk:
|
|
94
|
+
"""Creates a circuit that performs one round of surface code stabilizer measurement."""
|
|
95
|
+
code = make_surface_code(d=d)
|
|
96
|
+
builder = sf.ChunkBuilder(allowed_qubits=code.used_set)
|
|
97
|
+
mxs = [tile.measure_qubit for tile in code.tiles if tile.basis == 'X']
|
|
98
|
+
mzs = [tile.measure_qubit for tile in code.tiles if tile.basis == 'Z']
|
|
99
|
+
|
|
100
|
+
# Prepare measure qubits.
|
|
101
|
+
builder.append("RX", mxs)
|
|
102
|
+
builder.append("RZ", mzs)
|
|
103
|
+
builder.append("TICK")
|
|
104
|
+
|
|
105
|
+
# Perform entangling gates.
|
|
106
|
+
dxs = [-0.5 - 0.5j, 0.5 - 0.5j, -0.5 + 0.5j, 0.5 + 0.5j]
|
|
107
|
+
dzs = [dxs[0], dxs[2], dxs[1], dxs[3]]
|
|
108
|
+
for k in range(4):
|
|
109
|
+
builder.append(
|
|
110
|
+
'CX',
|
|
111
|
+
[(m, m + dxs[k]) for m in mxs] + [(m + dzs[k], m) for m in mzs],
|
|
112
|
+
unknown_qubit_append_mode='skip',
|
|
113
|
+
)
|
|
114
|
+
builder.append("TICK")
|
|
115
|
+
|
|
116
|
+
# Measure the measure qubits.
|
|
117
|
+
builder.append("MX", mxs)
|
|
118
|
+
builder.append("MZ", mzs)
|
|
119
|
+
|
|
120
|
+
# Assert the circuit should be preparing and measuring the stabilizers.
|
|
121
|
+
for tile in code.tiles:
|
|
122
|
+
builder.add_flow(start=tile, measurements=[tile.measure_qubit])
|
|
123
|
+
builder.add_flow(end=tile, measurements=[tile.measure_qubit])
|
|
124
|
+
# Assert the circuit should be preserving the logical operators.
|
|
125
|
+
for obs in code.flat_logicals:
|
|
126
|
+
builder.add_flow(start=obs, end=obs)
|
|
127
|
+
|
|
128
|
+
return builder.finish_chunk()
|
|
129
|
+
|
|
130
|
+
|
|
131
|
+
def main():
|
|
132
|
+
# Create the code, verify its commutation relationships, and save a picture of it.
|
|
133
|
+
code = make_surface_code(d=7)
|
|
134
|
+
code.verify()
|
|
135
|
+
code.to_svg().write_to('tmp.svg')
|
|
136
|
+
|
|
137
|
+
# Create the circuit cycle, verify its operation, and create an interactive viewer.
|
|
138
|
+
chunk = make_idle_round(d=7)
|
|
139
|
+
chunk.to_html_viewer(background=code).write_to('tmp.html')
|
|
140
|
+
chunk.verify()
|
|
141
|
+
|
|
142
|
+
# Compile a physical memory experiment with alternating cycle orderings.
|
|
143
|
+
compiler = sf.ChunkCompiler()
|
|
144
|
+
compiler.append(code.transversal_init_chunk(basis='X'))
|
|
145
|
+
compiler.append(sf.ChunkLoop(
|
|
146
|
+
[chunk, chunk.time_reversed()],
|
|
147
|
+
repetitions=5,
|
|
148
|
+
))
|
|
149
|
+
compiler.append(code.transversal_measure_chunk(basis='X'))
|
|
150
|
+
circuit = compiler.finish_circuit()
|
|
151
|
+
|
|
152
|
+
# Add noise to the circuit, check its distance, and make another viewer.
|
|
153
|
+
noisy_circuit = sf.NoiseModel.uniform_depolarizing(1e-3).noisy_circuit(circuit)
|
|
154
|
+
distance = len(noisy_circuit.shortest_graphlike_error())
|
|
155
|
+
assert distance == 7
|
|
156
|
+
sf.stim_circuit_html_viewer(noisy_circuit, background=code).write_to('tmp2.html')
|
|
157
|
+
|
|
158
|
+
|
|
159
|
+
if __name__ == "__main__":
|
|
160
|
+
main()
|
|
161
|
+
```
|
stimflow-0.1.0/README.md
ADDED
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
stimflow: annealed utilities for creating QEC circuits
|
|
2
|
+
=================================================
|
|
3
|
+
|
|
4
|
+
stimflow is a library for creating quantum error correction circuits.
|
|
5
|
+
|
|
6
|
+
stimflow's design philosophy is to be a tool box, not a black box.
|
|
7
|
+
For example, stimflow does *not* include a `make_surface_code` method.
|
|
8
|
+
Instead it provides tools that can be used to more easily create a surface code circuit from scratch.
|
|
9
|
+
The hope is that these tools then make it easier to create as-yet-unknown constructions in the future.
|
|
10
|
+
|
|
11
|
+
stimflow decomposes the circuit creation problem into making and combining *chunks*.
|
|
12
|
+
A *Chunk* is a circuit combined with stabilizer flow assertions that the circuit is supposed to satisfy.
|
|
13
|
+
stimflow provides tools for making chunks (`stimflow.ChunkBuilder`), verifying chunks (`stimflow.Chunk.verify`), debugging chunks (`stimflow.Chunk.to_html_viewer`), and compiling sequences of chunks into a complete final circuit (`stimflow.ChunkCompiler`).
|
|
14
|
+
|
|
15
|
+
stimflow also includes functionality for:
|
|
16
|
+
|
|
17
|
+
- Transpiling (`stimflow.transpile_to_z_basis_interaction_circuit(...)`)
|
|
18
|
+
- Adding Noise (`stimflow.NoiseModel.uniform_depolarizing(p).noisy_circuit(...)`)
|
|
19
|
+
- Visualizing (`stimflow.make_3d_model`, `stimflow.stim_circuit_html_viewer`)
|
|
20
|
+
|
|
21
|
+
# Documentation
|
|
22
|
+
|
|
23
|
+
See stimflow's [getting started notebook](doc/getting_started.ipynb).
|
|
24
|
+
|
|
25
|
+
See stimflow's [API reference](doc/api.md).
|
|
26
|
+
|
|
27
|
+
# Backwards Compatibility Warning
|
|
28
|
+
|
|
29
|
+
Stimflow does not currently guarantee backwards compatibility.
|
|
30
|
+
There are parts of the library that do not yet feel like they have converged on the "right" way to do it,
|
|
31
|
+
and I want to maintain the freedom to fix them later.
|
|
32
|
+
|
|
33
|
+
# Example Usage: Surface Code Circuit
|
|
34
|
+
|
|
35
|
+
stimflow is not yet provided as a pypi package, so you cannot install it with pip.
|
|
36
|
+
The installation can be done manually by copying the contents of this directory somewhere into your python path.
|
|
37
|
+
|
|
38
|
+
The following is python code that emits a surface code circuit.
|
|
39
|
+
|
|
40
|
+
```python
|
|
41
|
+
import stimflow as sf
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
def make_surface_code(d: int) -> sf.StabilizerCode:
|
|
45
|
+
"""Defines the stabilizers and observables of a surface code."""
|
|
46
|
+
tiles = []
|
|
47
|
+
ds = [0, 1, 1j, 1 + 1j]
|
|
48
|
+
for x in range(-1, d):
|
|
49
|
+
for y in range(-1, d):
|
|
50
|
+
m = x + 1j * y
|
|
51
|
+
qs = [m + d for d in ds]
|
|
52
|
+
qs = [q for q in qs
|
|
53
|
+
if 0 <= q.real < d and 0 <= q.imag < d]
|
|
54
|
+
b = 'XZ'[(x + y) % 2]
|
|
55
|
+
if b == 'X' and x in [-1, d - 1]:
|
|
56
|
+
continue
|
|
57
|
+
if b == 'Z' and y in [-1, d - 1]:
|
|
58
|
+
continue
|
|
59
|
+
tiles.append(sf.Tile(
|
|
60
|
+
data_qubits=qs,
|
|
61
|
+
bases=b,
|
|
62
|
+
measure_qubit=m + 0.5 + 0.5j,
|
|
63
|
+
))
|
|
64
|
+
|
|
65
|
+
patch = sf.Patch(tiles)
|
|
66
|
+
obs_x = sf.PauliMap.from_xs([q for q in patch.data_set if q.real == 0]).with_obs_name('X')
|
|
67
|
+
obs_z = sf.PauliMap.from_zs([q for q in patch.data_set if q.imag == 0]).with_obs_name('Z')
|
|
68
|
+
return sf.StabilizerCode(patch, logicals=[(obs_x, obs_z)])
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
def make_idle_round(d: int) -> sf.Chunk:
|
|
72
|
+
"""Creates a circuit that performs one round of surface code stabilizer measurement."""
|
|
73
|
+
code = make_surface_code(d=d)
|
|
74
|
+
builder = sf.ChunkBuilder(allowed_qubits=code.used_set)
|
|
75
|
+
mxs = [tile.measure_qubit for tile in code.tiles if tile.basis == 'X']
|
|
76
|
+
mzs = [tile.measure_qubit for tile in code.tiles if tile.basis == 'Z']
|
|
77
|
+
|
|
78
|
+
# Prepare measure qubits.
|
|
79
|
+
builder.append("RX", mxs)
|
|
80
|
+
builder.append("RZ", mzs)
|
|
81
|
+
builder.append("TICK")
|
|
82
|
+
|
|
83
|
+
# Perform entangling gates.
|
|
84
|
+
dxs = [-0.5 - 0.5j, 0.5 - 0.5j, -0.5 + 0.5j, 0.5 + 0.5j]
|
|
85
|
+
dzs = [dxs[0], dxs[2], dxs[1], dxs[3]]
|
|
86
|
+
for k in range(4):
|
|
87
|
+
builder.append(
|
|
88
|
+
'CX',
|
|
89
|
+
[(m, m + dxs[k]) for m in mxs] + [(m + dzs[k], m) for m in mzs],
|
|
90
|
+
unknown_qubit_append_mode='skip',
|
|
91
|
+
)
|
|
92
|
+
builder.append("TICK")
|
|
93
|
+
|
|
94
|
+
# Measure the measure qubits.
|
|
95
|
+
builder.append("MX", mxs)
|
|
96
|
+
builder.append("MZ", mzs)
|
|
97
|
+
|
|
98
|
+
# Assert the circuit should be preparing and measuring the stabilizers.
|
|
99
|
+
for tile in code.tiles:
|
|
100
|
+
builder.add_flow(start=tile, measurements=[tile.measure_qubit])
|
|
101
|
+
builder.add_flow(end=tile, measurements=[tile.measure_qubit])
|
|
102
|
+
# Assert the circuit should be preserving the logical operators.
|
|
103
|
+
for obs in code.flat_logicals:
|
|
104
|
+
builder.add_flow(start=obs, end=obs)
|
|
105
|
+
|
|
106
|
+
return builder.finish_chunk()
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
def main():
|
|
110
|
+
# Create the code, verify its commutation relationships, and save a picture of it.
|
|
111
|
+
code = make_surface_code(d=7)
|
|
112
|
+
code.verify()
|
|
113
|
+
code.to_svg().write_to('tmp.svg')
|
|
114
|
+
|
|
115
|
+
# Create the circuit cycle, verify its operation, and create an interactive viewer.
|
|
116
|
+
chunk = make_idle_round(d=7)
|
|
117
|
+
chunk.to_html_viewer(background=code).write_to('tmp.html')
|
|
118
|
+
chunk.verify()
|
|
119
|
+
|
|
120
|
+
# Compile a physical memory experiment with alternating cycle orderings.
|
|
121
|
+
compiler = sf.ChunkCompiler()
|
|
122
|
+
compiler.append(code.transversal_init_chunk(basis='X'))
|
|
123
|
+
compiler.append(sf.ChunkLoop(
|
|
124
|
+
[chunk, chunk.time_reversed()],
|
|
125
|
+
repetitions=5,
|
|
126
|
+
))
|
|
127
|
+
compiler.append(code.transversal_measure_chunk(basis='X'))
|
|
128
|
+
circuit = compiler.finish_circuit()
|
|
129
|
+
|
|
130
|
+
# Add noise to the circuit, check its distance, and make another viewer.
|
|
131
|
+
noisy_circuit = sf.NoiseModel.uniform_depolarizing(1e-3).noisy_circuit(circuit)
|
|
132
|
+
distance = len(noisy_circuit.shortest_graphlike_error())
|
|
133
|
+
assert distance == 7
|
|
134
|
+
sf.stim_circuit_html_viewer(noisy_circuit, background=code).write_to('tmp2.html')
|
|
135
|
+
|
|
136
|
+
|
|
137
|
+
if __name__ == "__main__":
|
|
138
|
+
main()
|
|
139
|
+
```
|
stimflow-0.1.0/setup.cfg
ADDED
stimflow-0.1.0/setup.py
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
# Copyright 2021 Google LLC
|
|
2
|
+
#
|
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
# you may not use this file except in compliance with the License.
|
|
5
|
+
# You may obtain a copy of the License at
|
|
6
|
+
#
|
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
#
|
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
# See the License for the specific language governing permissions and
|
|
13
|
+
# limitations under the License.
|
|
14
|
+
|
|
15
|
+
from setuptools import setup
|
|
16
|
+
|
|
17
|
+
with open('README.md', encoding='UTF-8') as f:
|
|
18
|
+
long_description = f.read()
|
|
19
|
+
with open('requirements.txt', encoding='UTF-8') as f:
|
|
20
|
+
requirements = f.read().splitlines()
|
|
21
|
+
|
|
22
|
+
__version__ = '0.1.0'
|
|
23
|
+
|
|
24
|
+
setup(
|
|
25
|
+
name='stimflow',
|
|
26
|
+
version=__version__,
|
|
27
|
+
author='Craig Gidney',
|
|
28
|
+
author_email='craig.gidney@gmail.com',
|
|
29
|
+
url='https://github.com/quantumlib/stim',
|
|
30
|
+
license='Apache 2',
|
|
31
|
+
packages=['stimflow', 'stimflow._chunk', 'stimflow._core', 'stimflow._layers', 'stimflow._viz'],
|
|
32
|
+
package_dir={'': 'src'},
|
|
33
|
+
description='A library for creating quantum error correction circuits.',
|
|
34
|
+
long_description=long_description,
|
|
35
|
+
long_description_content_type='text/markdown',
|
|
36
|
+
python_requires='>=3.6.0',
|
|
37
|
+
data_files=['README.md', 'requirements.txt'],
|
|
38
|
+
install_requires=requirements,
|
|
39
|
+
tests_require=['pytest', 'python3-distutils'],
|
|
40
|
+
)
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
__version__ = "0.1.0"
|
|
2
|
+
|
|
3
|
+
from stimflow._chunk import (
|
|
4
|
+
Chunk,
|
|
5
|
+
ChunkBuilder,
|
|
6
|
+
ChunkCompiler,
|
|
7
|
+
ChunkInterface,
|
|
8
|
+
ChunkLoop,
|
|
9
|
+
ChunkReflow,
|
|
10
|
+
find_d1_error,
|
|
11
|
+
find_d2_error,
|
|
12
|
+
FlowMetadata,
|
|
13
|
+
Patch,
|
|
14
|
+
StabilizerCode,
|
|
15
|
+
StimCircuitLoom,
|
|
16
|
+
transversal_code_transition_chunks,
|
|
17
|
+
verify_distance_is_at_least,
|
|
18
|
+
)
|
|
19
|
+
from stimflow._core import (
|
|
20
|
+
append_reindexed_content_to_circuit,
|
|
21
|
+
circuit_to_dem_target_measurement_records_map,
|
|
22
|
+
circuit_with_xz_flipped,
|
|
23
|
+
count_measurement_layers,
|
|
24
|
+
Flow,
|
|
25
|
+
gate_counts_for_circuit,
|
|
26
|
+
gates_used_by_circuit,
|
|
27
|
+
min_max_complex,
|
|
28
|
+
NoiseModel,
|
|
29
|
+
NoiseRule,
|
|
30
|
+
PauliMap,
|
|
31
|
+
sorted_complex,
|
|
32
|
+
stim_circuit_with_transformed_coords,
|
|
33
|
+
stim_circuit_with_transformed_moments,
|
|
34
|
+
str_html,
|
|
35
|
+
str_svg,
|
|
36
|
+
Tile,
|
|
37
|
+
xor_sorted,
|
|
38
|
+
)
|
|
39
|
+
from stimflow._layers import (
|
|
40
|
+
LayerCircuit,
|
|
41
|
+
transpile_to_z_basis_interaction_circuit,
|
|
42
|
+
)
|
|
43
|
+
from stimflow._viz import (
|
|
44
|
+
LineDataFor3DModel,
|
|
45
|
+
TriangleDataFor3DModel,
|
|
46
|
+
Viewable3dModelGLTF,
|
|
47
|
+
html_viewer_for_gltf_model,
|
|
48
|
+
make_3d_model,
|
|
49
|
+
stim_circuit_html_viewer,
|
|
50
|
+
svg,
|
|
51
|
+
TextDataFor3DModel,
|
|
52
|
+
)
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"""Utilities for building/combining pieces of quantum error correction circuits."""
|
|
2
|
+
|
|
3
|
+
from stimflow._chunk._chunk import Chunk
|
|
4
|
+
from stimflow._chunk._chunk_builder import ChunkBuilder
|
|
5
|
+
from stimflow._chunk._chunk_compiler import ChunkCompiler
|
|
6
|
+
from stimflow._chunk._chunk_interface import ChunkInterface
|
|
7
|
+
from stimflow._chunk._chunk_loop import ChunkLoop
|
|
8
|
+
from stimflow._chunk._chunk_reflow import ChunkReflow
|
|
9
|
+
from stimflow._chunk._code_util import (
|
|
10
|
+
find_d1_error,
|
|
11
|
+
find_d2_error,
|
|
12
|
+
transversal_code_transition_chunks,
|
|
13
|
+
verify_distance_is_at_least,
|
|
14
|
+
)
|
|
15
|
+
from stimflow._chunk._flow_metadata import FlowMetadata
|
|
16
|
+
from stimflow._chunk._patch import Patch
|
|
17
|
+
from stimflow._chunk._stabilizer_code import StabilizerCode
|
|
18
|
+
from stimflow._chunk._weave import StimCircuitLoom
|