graphqomb 0.2.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.
- graphqomb-0.2.0/LICENSE +21 -0
- graphqomb-0.2.0/PKG-INFO +255 -0
- graphqomb-0.2.0/README.md +206 -0
- graphqomb-0.2.0/docs/requirements.txt +5 -0
- graphqomb-0.2.0/graphqomb/__init__.py +1 -0
- graphqomb-0.2.0/graphqomb/circuit.py +271 -0
- graphqomb-0.2.0/graphqomb/command.py +123 -0
- graphqomb-0.2.0/graphqomb/common.py +399 -0
- graphqomb-0.2.0/graphqomb/euler.py +318 -0
- graphqomb-0.2.0/graphqomb/feedforward.py +337 -0
- graphqomb-0.2.0/graphqomb/focus_flow.py +201 -0
- graphqomb-0.2.0/graphqomb/gates.py +1272 -0
- graphqomb-0.2.0/graphqomb/graphstate.py +979 -0
- graphqomb-0.2.0/graphqomb/matrix.py +52 -0
- graphqomb-0.2.0/graphqomb/pattern.py +351 -0
- graphqomb-0.2.0/graphqomb/pauli_frame.py +250 -0
- graphqomb-0.2.0/graphqomb/qompiler.py +133 -0
- graphqomb-0.2.0/graphqomb/random_objects.py +82 -0
- graphqomb-0.2.0/graphqomb/rng.py +40 -0
- graphqomb-0.2.0/graphqomb/schedule_solver.py +230 -0
- graphqomb-0.2.0/graphqomb/scheduler.py +545 -0
- graphqomb-0.2.0/graphqomb/simulator.py +235 -0
- graphqomb-0.2.0/graphqomb/simulator_backend.py +275 -0
- graphqomb-0.2.0/graphqomb/statevec.py +296 -0
- graphqomb-0.2.0/graphqomb/stim_compiler.py +253 -0
- graphqomb-0.2.0/graphqomb/visualizer.py +567 -0
- graphqomb-0.2.0/graphqomb.egg-info/PKG-INFO +255 -0
- graphqomb-0.2.0/graphqomb.egg-info/SOURCES.txt +48 -0
- graphqomb-0.2.0/graphqomb.egg-info/dependency_links.txt +1 -0
- graphqomb-0.2.0/graphqomb.egg-info/requires.txt +19 -0
- graphqomb-0.2.0/graphqomb.egg-info/top_level.txt +1 -0
- graphqomb-0.2.0/pyproject.toml +161 -0
- graphqomb-0.2.0/requirements-dev.txt +6 -0
- graphqomb-0.2.0/requirements.txt +5 -0
- graphqomb-0.2.0/setup.cfg +4 -0
- graphqomb-0.2.0/tests/test_circuit.py +377 -0
- graphqomb-0.2.0/tests/test_common.py +52 -0
- graphqomb-0.2.0/tests/test_euler.py +175 -0
- graphqomb-0.2.0/tests/test_feedforward.py +553 -0
- graphqomb-0.2.0/tests/test_focus_flow.py +51 -0
- graphqomb-0.2.0/tests/test_gate.py +128 -0
- graphqomb-0.2.0/tests/test_graph_compose.py +180 -0
- graphqomb-0.2.0/tests/test_graphstate.py +287 -0
- graphqomb-0.2.0/tests/test_graphstate_bulk_init.py +304 -0
- graphqomb-0.2.0/tests/test_pattern.py +333 -0
- graphqomb-0.2.0/tests/test_pauli_frame.py +427 -0
- graphqomb-0.2.0/tests/test_scheduler_integration.py +645 -0
- graphqomb-0.2.0/tests/test_simulator_backend.py +194 -0
- graphqomb-0.2.0/tests/test_statevec.py +533 -0
- graphqomb-0.2.0/tests/test_stim_compiler.py +461 -0
graphqomb-0.2.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Masato Fukushima and 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.
|
graphqomb-0.2.0/PKG-INFO
ADDED
|
@@ -0,0 +1,255 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: graphqomb
|
|
3
|
+
Version: 0.2.0
|
|
4
|
+
Summary: A modular Graph State qompiler for measurement-based quantum computing.
|
|
5
|
+
Author: Sora Shiratani, Yuki Watanabe, Daichi Sasaki
|
|
6
|
+
Author-email: Masato Fukushima <masa1063fuk@gmail.com>
|
|
7
|
+
Maintainer-email: Masato Fukushima <masa1063fuk@gmail.com>
|
|
8
|
+
License: MIT
|
|
9
|
+
Project-URL: Homepage, https://github.com/TeamGraphix/graphqomb
|
|
10
|
+
Project-URL: Documentation, https://graphqomb.readthedocs.io/
|
|
11
|
+
Project-URL: Repository, https://github.com/TeamGraphix/graphqomb
|
|
12
|
+
Project-URL: Changelog, https://github.com/TeamGraphix/graphqomb/blob/master/CHANGELOG.md
|
|
13
|
+
Project-URL: Bug Tracker, https://github.com/TeamGraphix/graphqomb/issues
|
|
14
|
+
Keywords: quantum computing,MBQC,measurement-based quantum computing,quantum compilation,fault-tolerant quantum computing,graph state
|
|
15
|
+
Classifier: Development Status :: 4 - Beta
|
|
16
|
+
Classifier: Intended Audience :: Science/Research
|
|
17
|
+
Classifier: Intended Audience :: Developers
|
|
18
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
19
|
+
Classifier: Programming Language :: Python :: 3
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
22
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
23
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
24
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
25
|
+
Classifier: Topic :: Scientific/Engineering :: Physics
|
|
26
|
+
Classifier: Topic :: Scientific/Engineering :: Quantum Computing
|
|
27
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
28
|
+
Requires-Python: <3.14,>=3.9
|
|
29
|
+
Description-Content-Type: text/markdown
|
|
30
|
+
License-File: LICENSE
|
|
31
|
+
Requires-Dist: numpy<3,>=1.22
|
|
32
|
+
Requires-Dist: matplotlib
|
|
33
|
+
Requires-Dist: networkx
|
|
34
|
+
Requires-Dist: ortools<10,>=9
|
|
35
|
+
Requires-Dist: typing_extensions
|
|
36
|
+
Provides-Extra: dev
|
|
37
|
+
Requires-Dist: ruff==0.14.10; extra == "dev"
|
|
38
|
+
Requires-Dist: mypy==1.19.1; extra == "dev"
|
|
39
|
+
Requires-Dist: pyright==1.1.407; extra == "dev"
|
|
40
|
+
Requires-Dist: pytest==8.4.2; extra == "dev"
|
|
41
|
+
Requires-Dist: pytest-cov; extra == "dev"
|
|
42
|
+
Requires-Dist: types-networkx; extra == "dev"
|
|
43
|
+
Provides-Extra: doc
|
|
44
|
+
Requires-Dist: sphinx>=7.4.0; extra == "doc"
|
|
45
|
+
Requires-Dist: sphinx_gallery>=0.17.0; extra == "doc"
|
|
46
|
+
Requires-Dist: furo>=2024.01.29; extra == "doc"
|
|
47
|
+
Requires-Dist: matplotlib>=3.7.0; extra == "doc"
|
|
48
|
+
Dynamic: license-file
|
|
49
|
+
|
|
50
|
+
# GraphQOMB
|
|
51
|
+
|
|
52
|
+

|
|
53
|
+
[](https://badge.fury.io/py/graphqomb)
|
|
54
|
+
[](https://pypi.org/project/graphqomb/)
|
|
55
|
+
[](https://graphqomb.readthedocs.io/en/latest/?badge=latest)
|
|
56
|
+
[](https://codecov.io/gh/TeamGraphix/graphqomb)
|
|
57
|
+
[](https://github.com/TeamGraphix/graphqomb/actions/workflows/pytest.yml)
|
|
58
|
+
[](https://github.com/TeamGraphix/graphqomb/actions/workflows/typecheck.yml)
|
|
59
|
+
[](https://github.com/astral-sh/ruff)
|
|
60
|
+
|
|
61
|
+
**GraphQOMB** (Qompiler for Measurement-Based Quantum Computing, pronounce as _graphcomb_) is a modular graph-based compiler for measurement-based quantum computing (MBQC), providing a high-level interface to the [graphix](https://github.com/TeamGraphix/graphix) package for applications such as fault-tolerant MBQC.
|
|
62
|
+
|
|
63
|
+
GraphQOMB's philosophy is to use graph-like ZX diagrams as MBQC representation, with feedforward strategy treated independently.
|
|
64
|
+
This allows, for example, to integrate Pauli frame tracking needed for fault-tolerant MBQC, into basic feedforward strategy of MBQC, allowing streamlined compilation.
|
|
65
|
+
|
|
66
|
+
## Features
|
|
67
|
+
|
|
68
|
+
### Computation Design
|
|
69
|
+
|
|
70
|
+
- **ZX-Calculus Integration**: Use ZX-diagrams as an abstract expression of measurement pattern
|
|
71
|
+
- **Feedforward Strategy Design**: Our library accepts general feedforward strategy and optimization, eliminating the necessity of measurement calculus
|
|
72
|
+
- **Scheduler**: Scheduling the node preparation and measurement time
|
|
73
|
+
|
|
74
|
+
### Compilation
|
|
75
|
+
|
|
76
|
+
- **MBQC Pattern Generation**: Measurement pattern is treated as a quantum assembly
|
|
77
|
+
- **Pauli Frame Tracking**: Manage all the classical feedforward with Pauli Frame, enabling fault-tolerant computing as well
|
|
78
|
+
|
|
79
|
+
### Simulation
|
|
80
|
+
|
|
81
|
+
- **Pattern Simulation**: Simulate measurement patterns with statevector backend
|
|
82
|
+
- **Simulation in Stim circuit**: Generate a stim circuit implementing a fault-tolerant MBQC
|
|
83
|
+
|
|
84
|
+
### Others
|
|
85
|
+
|
|
86
|
+
- **Transpilation into Graphix Pattern**: Transpile generated pattern into `graphix.pattern.Pattern` object for variety of execution backend (WIP)
|
|
87
|
+
- **Visualization**: Visualize graph states
|
|
88
|
+
|
|
89
|
+
## Installation
|
|
90
|
+
|
|
91
|
+
### From PyPI (Recommended)
|
|
92
|
+
|
|
93
|
+
```bash
|
|
94
|
+
pip install graphqomb
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
### From Source (Development)
|
|
98
|
+
|
|
99
|
+
```bash
|
|
100
|
+
git clone https://github.com/TeamGraphix/graphqomb.git
|
|
101
|
+
cd graphqomb/
|
|
102
|
+
pip install -e .
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
Install with development dependencies:
|
|
106
|
+
|
|
107
|
+
```bash
|
|
108
|
+
pip install -e .[dev]
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
Install with documentation dependencies:
|
|
112
|
+
|
|
113
|
+
```bash
|
|
114
|
+
pip install -e .[doc]
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
## Quick Start
|
|
118
|
+
|
|
119
|
+
### Prepare Resource State and Feedforward
|
|
120
|
+
|
|
121
|
+
```python
|
|
122
|
+
from graphqomb.circuit import Circuit, circuit2graph
|
|
123
|
+
from graphqomb.gates import H, CNOT
|
|
124
|
+
from graphqomb.qompiler import qompile
|
|
125
|
+
from graphqomb.simulator import PatternSimulator, SimulatorBackend
|
|
126
|
+
|
|
127
|
+
# Create a quantum circuit
|
|
128
|
+
circuit = Circuit(2)
|
|
129
|
+
circuit.apply_macro_gate(H(0))
|
|
130
|
+
circuit.apply_macro_gate(CNOT((0, 1)))
|
|
131
|
+
|
|
132
|
+
graph, feedforward = circuit2graph(circuit)
|
|
133
|
+
|
|
134
|
+
# Compile into pattern
|
|
135
|
+
pattern = qompile(graph, feedforward)
|
|
136
|
+
|
|
137
|
+
# Simulate the pattern
|
|
138
|
+
simulator = PatternSimulator(pattern, SimulatorBackend.StateVector)
|
|
139
|
+
simulator.simulate()
|
|
140
|
+
print(simulator.state)
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
### Creating and Visualizing Graph States
|
|
144
|
+
|
|
145
|
+
```python
|
|
146
|
+
from graphqomb.graphstate import GraphState
|
|
147
|
+
from graphqomb.visualizer import visualize
|
|
148
|
+
|
|
149
|
+
# Create a graph state using from_graph
|
|
150
|
+
graph, node_map = GraphState.from_graph(
|
|
151
|
+
nodes=["input", "middle", "output"],
|
|
152
|
+
edges=[("input", "middle"), ("middle", "output")],
|
|
153
|
+
inputs=["input"],
|
|
154
|
+
outputs=["output"]
|
|
155
|
+
)
|
|
156
|
+
|
|
157
|
+
# Visualize the graph
|
|
158
|
+
visualize(graph)
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
## Documentation
|
|
162
|
+
|
|
163
|
+
- **Tutorial**: [WIP] for detailed usage guides
|
|
164
|
+
- **Examples**: See [examples](https://graphqomb.readthedocs.io/en/latest/gallery/index.html) for code demonstrations
|
|
165
|
+
- **API Reference**: Full API documentation is available [here](https://graphqomb.readthedocs.io/en/latest/references.html)
|
|
166
|
+
|
|
167
|
+
## Development
|
|
168
|
+
|
|
169
|
+
### Running Tests
|
|
170
|
+
|
|
171
|
+
```bash
|
|
172
|
+
pytest # Run all tests
|
|
173
|
+
pytest tests/test_specific.py # Run specific test file
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
### Code Quality
|
|
177
|
+
|
|
178
|
+
```bash
|
|
179
|
+
ruff check # Lint code
|
|
180
|
+
ruff format # Format code
|
|
181
|
+
mypy # Type checking
|
|
182
|
+
pyright # Type checking
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
### Building Documentation
|
|
186
|
+
|
|
187
|
+
```bash
|
|
188
|
+
cd docs/
|
|
189
|
+
make html # Build HTML documentation
|
|
190
|
+
# Output will be in docs/build/html/
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
## Project Structure
|
|
194
|
+
|
|
195
|
+
```
|
|
196
|
+
graphqomb/
|
|
197
|
+
├── graphqomb/ # Main source code
|
|
198
|
+
│ ├── circuit.py # Quantum circuit implementation
|
|
199
|
+
│ ├── graphstate.py # Graph state manipulation
|
|
200
|
+
| ├── scheduler.py # Scheduling computaional order
|
|
201
|
+
│ ├── qompiler.py # Generate MBQC pattern
|
|
202
|
+
│ ├── simulator.py # Pattern simulation
|
|
203
|
+
│ ├── visualizer.py # Visualization tools
|
|
204
|
+
│ └── ...
|
|
205
|
+
├── tests/ # Test suite
|
|
206
|
+
├── examples/ # Example scripts
|
|
207
|
+
├── docs/ # Sphinx documentation
|
|
208
|
+
│ └── source/
|
|
209
|
+
│ ├── gallery/ # Example gallery
|
|
210
|
+
│ └── ...
|
|
211
|
+
└── pyproject.toml # Project configuration
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
## Contributing
|
|
215
|
+
|
|
216
|
+
We welcome contributions! Please:
|
|
217
|
+
|
|
218
|
+
1. Fork the repository
|
|
219
|
+
2. Create a feature branch
|
|
220
|
+
3. Make your changes with tests
|
|
221
|
+
4. Ensure all tests pass and code is properly formatted
|
|
222
|
+
5. Submit a pull request
|
|
223
|
+
|
|
224
|
+
## Related Projects
|
|
225
|
+
|
|
226
|
+
- [graphix](https://github.com/TeamGraphix/graphix): The original MBQC library
|
|
227
|
+
- [PyZX](https://github.com/Quantomatic/pyzx): ZX-calculus library for Python
|
|
228
|
+
- [swiflow](https://github.com/TeamGraphix/swiflow): Rust-based fast flow finding algorithms
|
|
229
|
+
|
|
230
|
+
## License
|
|
231
|
+
|
|
232
|
+
[MIT License](LICENSE)
|
|
233
|
+
|
|
234
|
+
## Citation
|
|
235
|
+
|
|
236
|
+
If you use GraphQOMB in your research, please cite:
|
|
237
|
+
|
|
238
|
+
```bibtex
|
|
239
|
+
@software{graphqomb,
|
|
240
|
+
title = {GraphQOMB: A Modular Graph State Qompiler for Measurement-Based Quantum Computation},
|
|
241
|
+
author = {Masato Fukushima, Sora Shiratani, Yuki Watanabe, and Daichi Sasaki},
|
|
242
|
+
year = {2025},
|
|
243
|
+
url = {https://github.com/TeamGraphix/graphqomb}
|
|
244
|
+
}
|
|
245
|
+
```
|
|
246
|
+
|
|
247
|
+
## Acknowledgements
|
|
248
|
+
|
|
249
|
+
We acknowledge the [NICT Quantum Camp](https://nqc.nict.go.jp/) for supporting our development.
|
|
250
|
+
|
|
251
|
+
Special thanks to Fixstars Amplify:
|
|
252
|
+
|
|
253
|
+
<p><a href="https://amplify.fixstars.com/en/">
|
|
254
|
+
<img src="https://github.com/TeamGraphix/graphix/raw/master/docs/imgs/fam_logo.png" alt="amplify" width="200"/>
|
|
255
|
+
</a></p>
|
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
# GraphQOMB
|
|
2
|
+
|
|
3
|
+

|
|
4
|
+
[](https://badge.fury.io/py/graphqomb)
|
|
5
|
+
[](https://pypi.org/project/graphqomb/)
|
|
6
|
+
[](https://graphqomb.readthedocs.io/en/latest/?badge=latest)
|
|
7
|
+
[](https://codecov.io/gh/TeamGraphix/graphqomb)
|
|
8
|
+
[](https://github.com/TeamGraphix/graphqomb/actions/workflows/pytest.yml)
|
|
9
|
+
[](https://github.com/TeamGraphix/graphqomb/actions/workflows/typecheck.yml)
|
|
10
|
+
[](https://github.com/astral-sh/ruff)
|
|
11
|
+
|
|
12
|
+
**GraphQOMB** (Qompiler for Measurement-Based Quantum Computing, pronounce as _graphcomb_) is a modular graph-based compiler for measurement-based quantum computing (MBQC), providing a high-level interface to the [graphix](https://github.com/TeamGraphix/graphix) package for applications such as fault-tolerant MBQC.
|
|
13
|
+
|
|
14
|
+
GraphQOMB's philosophy is to use graph-like ZX diagrams as MBQC representation, with feedforward strategy treated independently.
|
|
15
|
+
This allows, for example, to integrate Pauli frame tracking needed for fault-tolerant MBQC, into basic feedforward strategy of MBQC, allowing streamlined compilation.
|
|
16
|
+
|
|
17
|
+
## Features
|
|
18
|
+
|
|
19
|
+
### Computation Design
|
|
20
|
+
|
|
21
|
+
- **ZX-Calculus Integration**: Use ZX-diagrams as an abstract expression of measurement pattern
|
|
22
|
+
- **Feedforward Strategy Design**: Our library accepts general feedforward strategy and optimization, eliminating the necessity of measurement calculus
|
|
23
|
+
- **Scheduler**: Scheduling the node preparation and measurement time
|
|
24
|
+
|
|
25
|
+
### Compilation
|
|
26
|
+
|
|
27
|
+
- **MBQC Pattern Generation**: Measurement pattern is treated as a quantum assembly
|
|
28
|
+
- **Pauli Frame Tracking**: Manage all the classical feedforward with Pauli Frame, enabling fault-tolerant computing as well
|
|
29
|
+
|
|
30
|
+
### Simulation
|
|
31
|
+
|
|
32
|
+
- **Pattern Simulation**: Simulate measurement patterns with statevector backend
|
|
33
|
+
- **Simulation in Stim circuit**: Generate a stim circuit implementing a fault-tolerant MBQC
|
|
34
|
+
|
|
35
|
+
### Others
|
|
36
|
+
|
|
37
|
+
- **Transpilation into Graphix Pattern**: Transpile generated pattern into `graphix.pattern.Pattern` object for variety of execution backend (WIP)
|
|
38
|
+
- **Visualization**: Visualize graph states
|
|
39
|
+
|
|
40
|
+
## Installation
|
|
41
|
+
|
|
42
|
+
### From PyPI (Recommended)
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
pip install graphqomb
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
### From Source (Development)
|
|
49
|
+
|
|
50
|
+
```bash
|
|
51
|
+
git clone https://github.com/TeamGraphix/graphqomb.git
|
|
52
|
+
cd graphqomb/
|
|
53
|
+
pip install -e .
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
Install with development dependencies:
|
|
57
|
+
|
|
58
|
+
```bash
|
|
59
|
+
pip install -e .[dev]
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
Install with documentation dependencies:
|
|
63
|
+
|
|
64
|
+
```bash
|
|
65
|
+
pip install -e .[doc]
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
## Quick Start
|
|
69
|
+
|
|
70
|
+
### Prepare Resource State and Feedforward
|
|
71
|
+
|
|
72
|
+
```python
|
|
73
|
+
from graphqomb.circuit import Circuit, circuit2graph
|
|
74
|
+
from graphqomb.gates import H, CNOT
|
|
75
|
+
from graphqomb.qompiler import qompile
|
|
76
|
+
from graphqomb.simulator import PatternSimulator, SimulatorBackend
|
|
77
|
+
|
|
78
|
+
# Create a quantum circuit
|
|
79
|
+
circuit = Circuit(2)
|
|
80
|
+
circuit.apply_macro_gate(H(0))
|
|
81
|
+
circuit.apply_macro_gate(CNOT((0, 1)))
|
|
82
|
+
|
|
83
|
+
graph, feedforward = circuit2graph(circuit)
|
|
84
|
+
|
|
85
|
+
# Compile into pattern
|
|
86
|
+
pattern = qompile(graph, feedforward)
|
|
87
|
+
|
|
88
|
+
# Simulate the pattern
|
|
89
|
+
simulator = PatternSimulator(pattern, SimulatorBackend.StateVector)
|
|
90
|
+
simulator.simulate()
|
|
91
|
+
print(simulator.state)
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
### Creating and Visualizing Graph States
|
|
95
|
+
|
|
96
|
+
```python
|
|
97
|
+
from graphqomb.graphstate import GraphState
|
|
98
|
+
from graphqomb.visualizer import visualize
|
|
99
|
+
|
|
100
|
+
# Create a graph state using from_graph
|
|
101
|
+
graph, node_map = GraphState.from_graph(
|
|
102
|
+
nodes=["input", "middle", "output"],
|
|
103
|
+
edges=[("input", "middle"), ("middle", "output")],
|
|
104
|
+
inputs=["input"],
|
|
105
|
+
outputs=["output"]
|
|
106
|
+
)
|
|
107
|
+
|
|
108
|
+
# Visualize the graph
|
|
109
|
+
visualize(graph)
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
## Documentation
|
|
113
|
+
|
|
114
|
+
- **Tutorial**: [WIP] for detailed usage guides
|
|
115
|
+
- **Examples**: See [examples](https://graphqomb.readthedocs.io/en/latest/gallery/index.html) for code demonstrations
|
|
116
|
+
- **API Reference**: Full API documentation is available [here](https://graphqomb.readthedocs.io/en/latest/references.html)
|
|
117
|
+
|
|
118
|
+
## Development
|
|
119
|
+
|
|
120
|
+
### Running Tests
|
|
121
|
+
|
|
122
|
+
```bash
|
|
123
|
+
pytest # Run all tests
|
|
124
|
+
pytest tests/test_specific.py # Run specific test file
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
### Code Quality
|
|
128
|
+
|
|
129
|
+
```bash
|
|
130
|
+
ruff check # Lint code
|
|
131
|
+
ruff format # Format code
|
|
132
|
+
mypy # Type checking
|
|
133
|
+
pyright # Type checking
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
### Building Documentation
|
|
137
|
+
|
|
138
|
+
```bash
|
|
139
|
+
cd docs/
|
|
140
|
+
make html # Build HTML documentation
|
|
141
|
+
# Output will be in docs/build/html/
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
## Project Structure
|
|
145
|
+
|
|
146
|
+
```
|
|
147
|
+
graphqomb/
|
|
148
|
+
├── graphqomb/ # Main source code
|
|
149
|
+
│ ├── circuit.py # Quantum circuit implementation
|
|
150
|
+
│ ├── graphstate.py # Graph state manipulation
|
|
151
|
+
| ├── scheduler.py # Scheduling computaional order
|
|
152
|
+
│ ├── qompiler.py # Generate MBQC pattern
|
|
153
|
+
│ ├── simulator.py # Pattern simulation
|
|
154
|
+
│ ├── visualizer.py # Visualization tools
|
|
155
|
+
│ └── ...
|
|
156
|
+
├── tests/ # Test suite
|
|
157
|
+
├── examples/ # Example scripts
|
|
158
|
+
├── docs/ # Sphinx documentation
|
|
159
|
+
│ └── source/
|
|
160
|
+
│ ├── gallery/ # Example gallery
|
|
161
|
+
│ └── ...
|
|
162
|
+
└── pyproject.toml # Project configuration
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
## Contributing
|
|
166
|
+
|
|
167
|
+
We welcome contributions! Please:
|
|
168
|
+
|
|
169
|
+
1. Fork the repository
|
|
170
|
+
2. Create a feature branch
|
|
171
|
+
3. Make your changes with tests
|
|
172
|
+
4. Ensure all tests pass and code is properly formatted
|
|
173
|
+
5. Submit a pull request
|
|
174
|
+
|
|
175
|
+
## Related Projects
|
|
176
|
+
|
|
177
|
+
- [graphix](https://github.com/TeamGraphix/graphix): The original MBQC library
|
|
178
|
+
- [PyZX](https://github.com/Quantomatic/pyzx): ZX-calculus library for Python
|
|
179
|
+
- [swiflow](https://github.com/TeamGraphix/swiflow): Rust-based fast flow finding algorithms
|
|
180
|
+
|
|
181
|
+
## License
|
|
182
|
+
|
|
183
|
+
[MIT License](LICENSE)
|
|
184
|
+
|
|
185
|
+
## Citation
|
|
186
|
+
|
|
187
|
+
If you use GraphQOMB in your research, please cite:
|
|
188
|
+
|
|
189
|
+
```bibtex
|
|
190
|
+
@software{graphqomb,
|
|
191
|
+
title = {GraphQOMB: A Modular Graph State Qompiler for Measurement-Based Quantum Computation},
|
|
192
|
+
author = {Masato Fukushima, Sora Shiratani, Yuki Watanabe, and Daichi Sasaki},
|
|
193
|
+
year = {2025},
|
|
194
|
+
url = {https://github.com/TeamGraphix/graphqomb}
|
|
195
|
+
}
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
## Acknowledgements
|
|
199
|
+
|
|
200
|
+
We acknowledge the [NICT Quantum Camp](https://nqc.nict.go.jp/) for supporting our development.
|
|
201
|
+
|
|
202
|
+
Special thanks to Fixstars Amplify:
|
|
203
|
+
|
|
204
|
+
<p><a href="https://amplify.fixstars.com/en/">
|
|
205
|
+
<img src="https://github.com/TeamGraphix/graphix/raw/master/docs/imgs/fam_logo.png" alt="amplify" width="200"/>
|
|
206
|
+
</a></p>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"""GraphQOMB library."""
|