# GraphQOMB

[](https://badge.fury.io/py/graphqomb)
[](https://pypi.org/project/graphqomb/)
[](https://graphqomb.readthedocs.io/en/latest/?badge=latest)
[](https://github.com/TeamGraphix/graphqomb/actions/workflows/pytest.yml)
[](https://github.com/TeamGraphix/graphqomb/actions/workflows/typecheck.yml)
[](https://github.com/astral-sh/ruff)
**GraphQOMB** (Qompiler for Measurement-Based Quantum Computing) is a comprehensive reimplementation of the [graphix](https://github.com/TeamGraphix/graphix). Our package compiles ZX-diagrams with optional feedforward strategy into measurement patterns with Pauli frame tracking.
## Features
### Computation Design
- **ZX-Calculus Integration**: Use ZX-diagrams as an abstract expression of measurement pattern
- **Feedforward Strategy Design**: Our library accepts general feedforward strategy and optimization, eliminating the necessity of measurement calculus
- **Scheduler**: Scheduling the node preparation and measurement time
### Compilation
- **MBQC Pattern Generation**: Measurement pattern is treated as a quantum assembly
- **Pauli Frame Tracking**: Manage all the classical feedforward with Pauli Frame, enabling fault-tolerant computing as well
### Simulation
- **Pattern Simulation**: Simulate measurement patterns with statevector backend
- **Simulation in Stim circuit**: Generate a stim circuit implementing a fault-tolerant MBQC
### Others
- **Transpilation into Graphix Pattern**: Transpile generated pattern into `graphix.pattern.Pattern` object for variety of execution backend (WIP)
- **Visualization**: Visualize graph states
## Installation
### From PyPI (Recommended)
```bash
pip install graphqomb
```
### From Source (Development)
```bash
git clone https://github.com/TeamGraphix/graphqomb.git
cd graphqomb/
pip install -e .
```
Install with development dependencies:
```bash
pip install -e .[dev]
```
Install with documentation dependencies:
```bash
pip install -e .[doc]
```
## Quick Start
### Prepare Resource State and Feedforward
```python
from graphqomb.circuit import Circuit, circuit2graph
from graphqomb.gates import H, CNOT
from graphqomb.qompiler import qompile
from graphqomb.simulator import PatternSimulator, SimulatorBackend
# Create a quantum circuit
circuit = Circuit(2)
circuit.apply_macro_gate(H(0))
circuit.apply_macro_gate(CNOT((0, 1)))
graph, feedforward = circuit2graph(circuit)
# Compile into pattern
pattern = qompile(graph, feedforward)
# Simulate the pattern
simulator = PatternSimulator(pattern, SimulatorBackend.StateVector)
simulator.simulate()
print(simulator.state)
```
### Creating and Visualizing Graph States
```python
from graphqomb.graphstate import GraphState
from graphqomb.visualizer import visualize
# Create a graph state
graph = GraphState()
node1 = graph.add_physical_node()
node2 = graph.add_physical_node()
node3 = graph.add_physical_node()
# Register input/output nodes
q_index = 0
graph.register_input(node1, q_index)
graph.register_output(node3, q_index)
# Add edges
graph.add_physical_edge(node1, node2)
graph.add_physical_edge(node2, node3)
# Visualize the graph
visualize(graph)
```
## Documentation
- **Tutorial**: [WIP] for detailed usage guides
- **Examples**: See [examples](https://graphqomb.readthedocs.io/en/latest/gallery/index.html) for code demonstrations
- **API Reference**: Full API documentation is available [here](https://graphqomb.readthedocs.io/en/latest/references.html)
## Development
### Running Tests
```bash
pytest # Run all tests
pytest tests/test_specific.py # Run specific test file
```
### Code Quality
```bash
ruff check # Lint code
ruff format # Format code
mypy # Type checking
pyright # Type checking
```
### Building Documentation
```bash
cd docs/
make html # Build HTML documentation
# Output will be in docs/build/html/
```
## Project Structure
```
graphqomb/
├── graphqomb/ # Main source code
│ ├── circuit.py # Quantum circuit implementation
│ ├── graphstate.py # Graph state manipulation
| ├── scheduler.py # Scheduling computaional order
│ ├── qompiler.py # Generate MBQC pattern
│ ├── simulator.py # Pattern simulation
│ ├── visualizer.py # Visualization tools
│ └── ...
├── tests/ # Test suite
├── examples/ # Example scripts
├── docs/ # Sphinx documentation
│ └── source/
│ ├── gallery/ # Example gallery
│ └── ...
└── pyproject.toml # Project configuration
```
## Contributing
We welcome contributions! Please:
1. Fork the repository
2. Create a feature branch
3. Make your changes with tests
4. Ensure all tests pass and code is properly formatted
5. Submit a pull request
## Related Projects
- [graphix](https://github.com/TeamGraphix/graphix): The original MBQC library
- [PyZX](https://github.com/Quantomatic/pyzx): ZX-calculus library for Python
- [swiflow](https://github.com/TeamGraphix/swiflow): Rust-based fast flow finding algorithms
## License
[MIT License](LICENSE)
## Citation
If you use GraphQOMB in your research, please cite:
```bibtex
@software{graphqomb,
title = {GraphQOMB: A Modular Graph State Qompiler for Measurement-Based Quantum Computation},
author = {Masato Fukushima, Sora Shiratani, Yuki Watanabe, and Daichi Sasaki},
year = {2025},
url = {https://github.com/TeamGraphix/graphqomb}
}
```
## Acknowledgements
We acknowledge the [NICT Quantum Camp](https://nqc.nict.go.jp/) for supporting our development.
Special thanks to Fixstars Amplify:
<p><a href="https://amplify.fixstars.com/en/">
<img src="https://github.com/TeamGraphix/graphix/raw/master/docs/imgs/fam_logo.png" alt="amplify" width="200"/>
</a></p>
Raw data
{
"_id": null,
"home_page": null,
"name": "graphqomb",
"maintainer": null,
"docs_url": null,
"requires_python": "<3.14,>=3.9",
"maintainer_email": "Masato Fukushima <masa1063fuk@gmail.com>",
"keywords": "quantum computing, MBQC, measurement-based quantum computing, quantum compilation, fault-tolerant quantum computing, graph state",
"author": "Sora Shiratani, Yuki Watanabe, Daichi Sasaki",
"author_email": "Masato Fukushima <masa1063fuk@gmail.com>",
"download_url": "https://files.pythonhosted.org/packages/ed/46/82f663d82d71156b65df34a6ae052fccdd7c74b237fd2a9aa8ce1eb92555/graphqomb-0.1.1.tar.gz",
"platform": null,
"description": "# GraphQOMB\n\n\n[](https://badge.fury.io/py/graphqomb)\n[](https://pypi.org/project/graphqomb/)\n[](https://graphqomb.readthedocs.io/en/latest/?badge=latest)\n[](https://github.com/TeamGraphix/graphqomb/actions/workflows/pytest.yml)\n[](https://github.com/TeamGraphix/graphqomb/actions/workflows/typecheck.yml)\n[](https://github.com/astral-sh/ruff)\n\n**GraphQOMB** (Qompiler for Measurement-Based Quantum Computing) is a comprehensive reimplementation of the [graphix](https://github.com/TeamGraphix/graphix). Our package compiles ZX-diagrams with optional feedforward strategy into measurement patterns with Pauli frame tracking.\n\n## Features\n\n### Computation Design\n\n- **ZX-Calculus Integration**: Use ZX-diagrams as an abstract expression of measurement pattern\n- **Feedforward Strategy Design**: Our library accepts general feedforward strategy and optimization, eliminating the necessity of measurement calculus\n- **Scheduler**: Scheduling the node preparation and measurement time\n\n### Compilation\n\n- **MBQC Pattern Generation**: Measurement pattern is treated as a quantum assembly\n- **Pauli Frame Tracking**: Manage all the classical feedforward with Pauli Frame, enabling fault-tolerant computing as well\n\n### Simulation\n\n- **Pattern Simulation**: Simulate measurement patterns with statevector backend\n- **Simulation in Stim circuit**: Generate a stim circuit implementing a fault-tolerant MBQC\n\n### Others\n\n- **Transpilation into Graphix Pattern**: Transpile generated pattern into `graphix.pattern.Pattern` object for variety of execution backend (WIP)\n- **Visualization**: Visualize graph states\n\n## Installation\n\n### From PyPI (Recommended)\n\n```bash\npip install graphqomb\n```\n\n### From Source (Development)\n\n```bash\ngit clone https://github.com/TeamGraphix/graphqomb.git\ncd graphqomb/\npip install -e .\n```\n\nInstall with development dependencies:\n\n```bash\npip install -e .[dev]\n```\n\nInstall with documentation dependencies:\n\n```bash\npip install -e .[doc]\n```\n\n## Quick Start\n\n### Prepare Resource State and Feedforward\n\n```python\nfrom graphqomb.circuit import Circuit, circuit2graph\nfrom graphqomb.gates import H, CNOT\nfrom graphqomb.qompiler import qompile\nfrom graphqomb.simulator import PatternSimulator, SimulatorBackend\n\n# Create a quantum circuit\ncircuit = Circuit(2)\ncircuit.apply_macro_gate(H(0))\ncircuit.apply_macro_gate(CNOT((0, 1)))\n\ngraph, feedforward = circuit2graph(circuit)\n\n# Compile into pattern\npattern = qompile(graph, feedforward)\n\n# Simulate the pattern\nsimulator = PatternSimulator(pattern, SimulatorBackend.StateVector)\nsimulator.simulate()\nprint(simulator.state)\n```\n\n### Creating and Visualizing Graph States\n\n```python\nfrom graphqomb.graphstate import GraphState\nfrom graphqomb.visualizer import visualize\n\n# Create a graph state\ngraph = GraphState()\nnode1 = graph.add_physical_node()\nnode2 = graph.add_physical_node()\nnode3 = graph.add_physical_node()\n\n# Register input/output nodes\nq_index = 0\ngraph.register_input(node1, q_index)\ngraph.register_output(node3, q_index)\n\n# Add edges\ngraph.add_physical_edge(node1, node2)\ngraph.add_physical_edge(node2, node3)\n\n# Visualize the graph\nvisualize(graph)\n```\n\n## Documentation\n\n- **Tutorial**: [WIP] for detailed usage guides\n- **Examples**: See [examples](https://graphqomb.readthedocs.io/en/latest/gallery/index.html) for code demonstrations\n- **API Reference**: Full API documentation is available [here](https://graphqomb.readthedocs.io/en/latest/references.html)\n\n## Development\n\n### Running Tests\n\n```bash\npytest # Run all tests\npytest tests/test_specific.py # Run specific test file\n```\n\n### Code Quality\n\n```bash\nruff check # Lint code\nruff format # Format code\nmypy # Type checking\npyright # Type checking\n```\n\n### Building Documentation\n\n```bash\ncd docs/\nmake html # Build HTML documentation\n# Output will be in docs/build/html/\n```\n\n## Project Structure\n\n```\ngraphqomb/\n\u251c\u2500\u2500 graphqomb/ # Main source code\n\u2502 \u251c\u2500\u2500 circuit.py # Quantum circuit implementation\n\u2502 \u251c\u2500\u2500 graphstate.py # Graph state manipulation\n| \u251c\u2500\u2500 scheduler.py # Scheduling computaional order\n\u2502 \u251c\u2500\u2500 qompiler.py # Generate MBQC pattern\n\u2502 \u251c\u2500\u2500 simulator.py # Pattern simulation\n\u2502 \u251c\u2500\u2500 visualizer.py # Visualization tools\n\u2502 \u2514\u2500\u2500 ...\n\u251c\u2500\u2500 tests/ # Test suite\n\u251c\u2500\u2500 examples/ # Example scripts\n\u251c\u2500\u2500 docs/ # Sphinx documentation\n\u2502 \u2514\u2500\u2500 source/\n\u2502 \u251c\u2500\u2500 gallery/ # Example gallery\n\u2502 \u2514\u2500\u2500 ...\n\u2514\u2500\u2500 pyproject.toml # Project configuration\n```\n\n## Contributing\n\nWe welcome contributions! Please:\n\n1. Fork the repository\n2. Create a feature branch\n3. Make your changes with tests\n4. Ensure all tests pass and code is properly formatted\n5. Submit a pull request\n\n## Related Projects\n\n- [graphix](https://github.com/TeamGraphix/graphix): The original MBQC library\n- [PyZX](https://github.com/Quantomatic/pyzx): ZX-calculus library for Python\n- [swiflow](https://github.com/TeamGraphix/swiflow): Rust-based fast flow finding algorithms\n\n## License\n\n[MIT License](LICENSE)\n\n## Citation\n\nIf you use GraphQOMB in your research, please cite:\n\n```bibtex\n@software{graphqomb,\n title = {GraphQOMB: A Modular Graph State Qompiler for Measurement-Based Quantum Computation},\n author = {Masato Fukushima, Sora Shiratani, Yuki Watanabe, and Daichi Sasaki},\n year = {2025},\n url = {https://github.com/TeamGraphix/graphqomb}\n}\n```\n\n## Acknowledgements\n\nWe acknowledge the [NICT Quantum Camp](https://nqc.nict.go.jp/) for supporting our development.\n\nSpecial thanks to Fixstars Amplify:\n\n<p><a href=\"https://amplify.fixstars.com/en/\">\n<img src=\"https://github.com/TeamGraphix/graphix/raw/master/docs/imgs/fam_logo.png\" alt=\"amplify\" width=\"200\"/>\n</a></p>\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "A modular Graph State qompiler for measurement-based quantum computing.",
"version": "0.1.1",
"project_urls": {
"Bug Tracker": "https://github.com/TeamGraphix/graphqomb/issues",
"Changelog": "https://github.com/TeamGraphix/graphqomb/blob/master/CHANGELOG.md",
"Documentation": "https://graphqomb.readthedocs.io/",
"Homepage": "https://github.com/TeamGraphix/graphqomb",
"Repository": "https://github.com/TeamGraphix/graphqomb"
},
"split_keywords": [
"quantum computing",
" mbqc",
" measurement-based quantum computing",
" quantum compilation",
" fault-tolerant quantum computing",
" graph state"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "54c209c8a54d8f6306ead95b3796832363130edb6a1bdfd44b6b43e4ae8d7d8e",
"md5": "76f3da7a4047dc9770abef04a9532089",
"sha256": "82c22026643ae1f64cb4d4fdc153cbf82df0bbf4cda19d910e5bc9ae85dc6dc8"
},
"downloads": -1,
"filename": "graphqomb-0.1.1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "76f3da7a4047dc9770abef04a9532089",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": "<3.14,>=3.9",
"size": 49969,
"upload_time": "2025-10-25T06:25:57",
"upload_time_iso_8601": "2025-10-25T06:25:57.930256Z",
"url": "https://files.pythonhosted.org/packages/54/c2/09c8a54d8f6306ead95b3796832363130edb6a1bdfd44b6b43e4ae8d7d8e/graphqomb-0.1.1-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "ed4682f663d82d71156b65df34a6ae052fccdd7c74b237fd2a9aa8ce1eb92555",
"md5": "33bb69d1739268d48c5c9fc3bf3b94b1",
"sha256": "964345b03b3bfc1159146e1da32f5f527832b45061d7c94e770b07a90586c749"
},
"downloads": -1,
"filename": "graphqomb-0.1.1.tar.gz",
"has_sig": false,
"md5_digest": "33bb69d1739268d48c5c9fc3bf3b94b1",
"packagetype": "sdist",
"python_version": "source",
"requires_python": "<3.14,>=3.9",
"size": 61290,
"upload_time": "2025-10-25T06:25:59",
"upload_time_iso_8601": "2025-10-25T06:25:59.138038Z",
"url": "https://files.pythonhosted.org/packages/ed/46/82f663d82d71156b65df34a6ae052fccdd7c74b237fd2a9aa8ce1eb92555/graphqomb-0.1.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-10-25 06:25:59",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "TeamGraphix",
"github_project": "graphqomb",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"requirements": [
{
"name": "numpy",
"specs": [
[
">=",
"1.22"
],
[
"<",
"3"
]
]
},
{
"name": "matplotlib",
"specs": []
},
{
"name": "networkx",
"specs": []
},
{
"name": "ortools",
"specs": [
[
"<",
"10"
],
[
">=",
"9"
]
]
},
{
"name": "typing_extensions",
"specs": []
}
],
"lcname": "graphqomb"
}