Skip to content

Commit

Permalink
Fix docs build
Browse files Browse the repository at this point in the history
  • Loading branch information
shinich1 committed Jun 29, 2023
1 parent 20af782 commit 527600e
Show file tree
Hide file tree
Showing 6 changed files with 89 additions and 9 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

- Interface to run patterns on the IBMQ devices. (see PR) (#44)


## [0.2.3] - 2023-06-25
### Changed

- Quantum classifier demo (#57) by @Gopal-Dahale
Expand Down
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
<img src="https://github.com/TeamGraphix/graphix/raw/master/docs/logo/black_with_name.png" alt="logo" width="550">

[![Documentation Status](https://readthedocs.org/projects/graphix/badge/?version=latest)](https://graphix.readthedocs.io/en/latest/?badge=latest)
![GitHub](https://img.shields.io/github/license/TeamGraphix/graphix)
![PyPI - Python Version](https://img.shields.io/pypi/pyversions/graphix)
![PyPI](https://img.shields.io/pypi/v/graphix)
[![Unitary Fund](https://img.shields.io/badge/Supported%20By-UNITARY%20FUND-brightgreen.svg)](https://unitary.fund/)
[![DOI](https://zenodo.org/badge/573466585.svg)](https://zenodo.org/badge/latestdoi/573466585)
[![Documentation Status](https://readthedocs.org/projects/graphix/badge/?version=latest)](https://graphix.readthedocs.io/en/latest/?badge=latest)
![GitHub](https://img.shields.io/github/license/TeamGraphix/graphix)
[![Downloads](https://static.pepy.tech/badge/graphix)](https://pepy.tech/project/graphix)

**Graphix** is a measurement-based quantum computing (MBQC) compiler, which makes it easier to generate, optimize and simulate MBQC *measurement patterns*.

Expand Down
2 changes: 1 addition & 1 deletion docs/source/device_interface.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Device Interface
:mod:`graphix.device_interface` module
+++++++++++++++++++++++++++++++++++

.. currentmodule:: graphix.interface
.. currentmodule:: graphix.device_interface

.. autoclass:: PatternRunner

Expand Down
2 changes: 1 addition & 1 deletion docs/source/modifier.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Pattern Optimization

.. automethod:: simulate_pattern

.. automethod:: execute_pattern
.. automethod:: run_pattern

.. automethod:: perform_pauli_measurements

Expand Down
85 changes: 81 additions & 4 deletions docs/source/tutorial.rst
Original file line number Diff line number Diff line change
Expand Up @@ -289,13 +289,90 @@ With this, we only need the memory space for three qubits.

This procedure is more effective when the resource state size is large compared to the logical input qubit count;
for example, the three-qubit `quantum Fourier transform (QFT)
<https://en.wikipedia.org/wiki/Quantum_Fourier_transform>`_ circuit requires 12 qubits in the resource state after :meth:`~graphix.pattern.Pattern.perform_pauli_measurements()` (we show the code in :ref:`algorithms:QFT`); with the proper reordering of the commands, the max_space reduces to 4.
<https://en.wikipedia.org/wiki/Quantum_Fourier_transform>`_ circuit requires 12 qubits in the resource state after :meth:`~graphix.pattern.Pattern.perform_pauli_measurements()` (we show the code in :ref:`gallery:qft`); with the proper reordering of the commands, the max_space reduces to 4.
In fact, for patterns transpiled from gate network, the minimum `space` we can realize is typically :math:`n_w+1` where :math:`n_w` is the width of the circuit.


..
Parallelizing a pattern
+++++++++++++++++++++++
Running pattern on quantum devices
++++++++++++++++++++++++++++++++++

We are currently adding cloud-based quantum devices to run MBQC pattern. Our first such interface is for IBMQ devices, and is available as `graphix-ibmq <https://github.com/TeamGraphix/graphix-ibmq>`_ module.

First, install ``graphix-ibmq`` by

>>> pip install graphix-ibmq

With graphix-ibmq installed, we can turn a measurement pattern into a qiskit dynamic circuit.

.. code-block:: python
from graphix_ibmq.runner import IBMQBackend
# minimize space and convert to qiskit circuit
pattern.minimize_space()
backend = IBMQBackend(pattern)
backend.to_qiskit()
print(type(backend.circ))
#set the rondom input state
psi = []
for i in range(n):
psi.append(qi.random_statevector(2, seed=100+i))
backend.set_input(psi)
.. rst-class:: sphx-glr-script-out

.. code-block:: none
<class 'qiskit.circuit.quantumcircuit.QuantumCircuit'>
This can be run on Aer simulator or IBMQ devices. See `documentation page for graphix-ibmq interface <https://graphix-ibmq.readthedocs.io/en/latest/tutorial.html>`_ for more details, as well as `a detailed example showing how to run pattern on IBMQ devices <https://graphix-ibmq.readthedocs.io/en/latest/gallery/aer_sim.html#sphx-glr-gallery-aer-sim-py>`_.


Generating QASM file
++++++++++++++++++++

For other systems, we can generate QASM3 instruction set corresponding to the pattern, following

.. code-block:: python
qasm_inst = pattern.to_qasm3('pattern')
Now check the generated qasm file:

.. code-block:: bash
$ cat pattern.qasm
.. rst-class:: sphx-glr-script-out

.. code-block:: none
// generated by graphix
OPENQASM 3;
include "stdgates.inc";
// prepare qubit q1
qubit q1;
h q1;
// prepare qubit q4
qubit q4;
h q4;
// entangle qubit q1 and q4
cz q1, q4;
// measure qubit q1
bit c1;
float theta1 = 0;
p(-theta1) q1;
h q1;
c1 = measure q1;
h q1;
p(theta1) q1;
...
References
Expand Down
2 changes: 1 addition & 1 deletion graphix/pattern.py
Original file line number Diff line number Diff line change
Expand Up @@ -1168,7 +1168,7 @@ def simulate_pattern(self, backend="statevector", **kwargs):
return state

def run_pattern(self, backend, **kwargs):
"""run the pattern on a actual device.
"""run the pattern on cloud-based quantum devices and their simulators.
Available backend: ['ibmq']
Parameters
Expand Down

0 comments on commit 527600e

Please sign in to comment.