Graphix is a measurement-based quantum computing (MBQC) software package, featuring
- the measurement calculus framework with integrated graphical rewrite rules for Pauli measurement preprocessing
- circuit-to-pattern transpiler, graph-based deterministic pattern generator and manual pattern generation
- flow, gflow and pauliflow finding tools and graph visualization based on flows (see below)
- statevector, density matrix and tensornetwork pattern simulation backends
- QPU interface and fusion network extraction tool
Install graphix
with pip
:
pip install graphix
Install together with device interface:
pip install graphix[extra]
this will install graphix
and inteface for IBMQ and Perceval to run MBQC patterns on superconducting and optical QPUs and their simulators.
from graphix import Circuit
circuit = Circuit(4)
circuit.h(0)
...
pattern = circuit.transpile().pattern
pattern.draw_graph()
![graph_flow](https://private-user-images.githubusercontent.com/33350509/290978894-de17c663-f607-44e2-945b-835f4082a940.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjU0MTA4NDgsIm5iZiI6MTcyNTQxMDU0OCwicGF0aCI6Ii8zMzM1MDUwOS8yOTA5Nzg4OTQtZGUxN2M2NjMtZjYwNy00NGUyLTk0NWItODM1ZjQwODJhOTQwLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA5MDQlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwOTA0VDAwNDIyOFomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTNiNmVjNzZjNzQxZGExYzMyYTJhYzJjZTgzYjA4NDgwMTU2M2JmZDdlMmNkZjI2MzE4MmJmZDUzOWUzOTE2MDgmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.sYpGT7ggX6QJ7mfJqBHTD5GBM9vxS-W9p7Ambw2JS8Y)
note: this graph is generated from QAOA circuit, see our example code. Arrows indicate the causal flow of MBQC and dashed lines are the other edges of the graph. the vertical dashed partitions and the labels 'l:n' below indicate the execution layers or the order in the graph (measurements should happen from left to right, and nodes in the same layer can be measured simultaneously), based on the partial order associated with the (maximally-delayed) flow.
pattern.perform_pauli_measurements()
pattern.draw_graph()
![graph_gflow](https://private-user-images.githubusercontent.com/33350509/290979248-3c30a4c9-f912-4a36-925f-2ff446a07c68.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjU0MTA4NDgsIm5iZiI6MTcyNTQxMDU0OCwicGF0aCI6Ii8zMzM1MDUwOS8yOTA5NzkyNDgtM2MzMGE0YzktZjkxMi00YTM2LTkyNWYtMmZmNDQ2YTA3YzY4LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA5MDQlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwOTA0VDAwNDIyOFomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTE3NmFjZmQwZTAzNjhmMGFiNTViYmRkZjlkNDFhNDI4NzU1Y2IzZWM2M2EyOWJjMWNmMGIzMTQ5MjEwOWJlYmImWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.dt96qOTC5LA2hS6ocV6mYKHhkU9wqjHpKqw2rtn0qNI)
(here, the graph is visualized based on generalized flow.)
state_out = pattern.simulate_pattern(backend="statevector")
-
See demos showing other features of
graphix
. -
Read the tutorial for more usage guides.
-
For theoretical background, read our quick introduction into MBQC and LC-MBQC.
-
Full API docs is here.
Shinichi Sunami and Masato Fukushima, Graphix. (2023) https://doi.org/10.5281/zenodo.7861382
We use GitHub issues for tracking feature requests and bug reports.
Please visit Unitary Fund's Discord server, where you can find a channel for graphix
to ask questions.
Dr. Shinichi Sunami (University of Oxford)
Masato Fukushima (University of Tokyo, Fixstars Amplify)
We are proud to be supported by unitary fund microgrant program.
Special thanks to Fixstars Amplify: