Skip to content

Commit

Permalink
Merge branch 'master' into ZNE_get_noisy_circuit
Browse files Browse the repository at this point in the history
  • Loading branch information
mho291 committed Jul 23, 2024
2 parents 8df401e + c598c67 commit ee4b1b1
Show file tree
Hide file tree
Showing 11 changed files with 1,952 additions and 589 deletions.
97 changes: 95 additions & 2 deletions doc/source/api-reference/qibo.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1952,11 +1952,22 @@ For more details, see G. Chiribella *et al.*, *Theoretical framework for quantum
`Physical Review A 80.2 (2009): 022339
<https://journals.aps.org/pra/abstract/10.1103/PhysRevA.80.022339>`_.


.. autoclass:: qibo.quantum_info.quantum_networks.QuantumNetwork
:members:
:member-order: bysource


.. autoclass:: qibo.quantum_info.quantum_networks.QuantumComb
:members:
:member-order: bysource


.. autoclass:: qibo.quantum_info.quantum_networks.QuantumChannel
:members:
:member-order: bysource


Random Ensembles
^^^^^^^^^^^^^^^^

Expand Down Expand Up @@ -2377,6 +2388,90 @@ Parameterized quantum circuit integral
.. autofunction:: qibo.quantum_info.pqc_integral


.. _GST:



Tomography
----------

Functions used to classically simulate tomography protocols.


Gate Set Tomography
^^^^^^^^^^^^^^^^^^^

Gate Set Tomography (GST) is a powerful technique employed in quantum information processing
to characterize the behavior of quantum gates on quantum hardware [1, 2, 3].
The primary objective of GST is to provide a robust framework for obtaining a representation
of quantum gates within a predefined gate set when subjected to noise inherent to the
quantum hardware.

By characterizing the impact of noise on quantum gates, GST enables the identification and
quantification of errors, laying the groundwork for subsequent error mitigation strategies.
The insights gained from GST are instrumental, for instance, in setting up the necessary
parameters for Probabilistic Error Cancellation (PEC).

In practice, given a set of operators (or gates), :math:`\mathcal{O}=\{O_0, O_1, \dots, O_n\}`,
a set of initial states :math:`\{\rho_k\}`, and a set of measurement bases :math:`\{M_j\}`,
one performs GST on the :math:`l`-th operator by choosing an initial state :math:`\rho_k`,
applying the gate :math:`O_l \in \mathcal{O}`, measuring in the :math:`M_j` basis in order to
obtain the following matrix:

.. math::
\{\tilde{O}_l\}_{jk} = \text{tr}(M_j\,O_l\,\rho_k) \, ,
which provides an estimated representation of the operator :math:`O_l` in the specific system.

This implementation makes use, in particular, of
:math:`\rho_k \in \{ \ketbra{0}{0}, \ketbra{1}{1}, \ketbra{+}{+}, \ketbra{y+}{y+} \}^{\otimes n}` and
:math:`M_j \in \{ I, X, Y, Z\}^{\otimes n}` [4], with :math:`n\in\{1,2\}`
being the number of qubits. However, :math:`\{\tilde{O}_l\}_{jk}` is not yet given in
the Pauli-Liouville representation (also known as *Pauli Transfer Matrix*).
To obtain the Pauli-Liouville representation, one needs the two matrices, described below.
The matrix :math:`\tilde{g}` has its elements :math:`\tilde{g}_{jk}` defined as

.. math::
\tilde{g}_{jk} = \text{tr}(M_j\,\rho_k) \, ,
which is obtained by measuring the initial states :math:`\{\rho_k\}` in each basis element :math:`\{M_j\}`
without any gates' application.
The *gauge matrix* :math:`T` is given by

.. math::
T = \begin{pmatrix}
1 & 1 & 1 & 1 \\
0 & 0 & 1 & 0 \\
0 & 0 & 0 & 1 \\
1 & -1 & 0 & 0 \\
\end{pmatrix} \, .
This is the matrix, in a common gauge, implementing a change of basis.
Therefore, the Pauli-Liouville representation can be recovered as

.. math::
O_l^{PL} = T\,g^{-1}\,\tilde{O_l}\,T^{-1} \, .
References:
1. R. Blume-Kohout *et al*.
*Robust, self-consistent, closed-form tomography of quantum logic gates on a trapped ion qubit*
(2013), `arXiv:1310.4492 <https://arxiv.org/abs/1310.4492>`_.

2. D. Greenbaum, *Introduction to quantum gate set tomography* (2015),
`arXiv:1509.02921 <https://arxiv.org/abs/1509.02921>`_.

3. E. Nielsen *et al.*, *Gate set tomography* (2021),
`Quantum 5, 557 <https://doi.org/10.22331/q-2021-10-05-557>`_.

4. S. Endo, S. C. Benjamin, and Y. Li,
*Practical quantum error mitigation for near-future applications* (2018),
`Physical Review X 8.3: 031027 <https://doi.org/10.1103/PhysRevX.8.031027>`_.


.. autofunction:: qibo.tomography.gate_set_tomography.GST



.. _Parallel:

Parallelism
Expand Down Expand Up @@ -2518,12 +2613,10 @@ Alternatively, a Clifford circuit can also be executed starting from the :class:
circuit = random_clifford(nqubits)
result = Clifford.from_circuit(circuit)
.. autoclass:: qibo.backends.clifford.CliffordBackend
:members:
:member-order: bysource


Cloud Backends
^^^^^^^^^^^^^^

Expand Down
61 changes: 61 additions & 0 deletions doc/source/code-examples/advancedexamples.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2112,3 +2112,64 @@ In this case circuits will first be transpiled to respect the 5-qubit star conne
Then all gates will be converted to native. The :class:`qibo.transpiler.unroller.Unroller` transpiler used in this example assumes Z, RZ, GPI2 or U3 as
the single-qubit native gates, and supports CZ and iSWAP as two-qubit natives. In this case we restricted the two-qubit gate set to CZ only.
The final_layout contains the final logical-physical qubit mapping.

.. _gst_example:

How to perform Gate Set Tomography?
-----------------------------------

In order to obtain an estimated representation of a set of quantum gates in a particular noisy environment, qibo provides a GST routine in its tomography module.

Let's first define the set of gates we want to estimate:

.. testcode::

from qibo import gates

gate_set = {gates.X, gates.H, gates.CZ}

For simulation purposes we can define a noise model. Naturally this is not needed when running on real quantum hardware, which is intrinsically noisy. For example, we can suppose that the three gates we want to estimate are going to be noisy:

.. testcode::

from qibo.noise import NoiseModel, DepolarizingError

noise_model = NoiseModel()
noise_model.add(DepolarizingError(1e-3), gates.X)
noise_model.add(DepolarizingError(1e-2), gates.H)
noise_model.add(DepolarizingError(3e-2), gates.CZ)

Then the estimated representation of the gates in this noisy environment can be extracted by running the GST:

.. testcode::

from qibo.tomography import GST

estimated_gates = GST(
gate_set = gate_set,
nshots = 10000,
noise_model = noise_model
)

In some cases the empty circuit matrix :math:`E` can also be useful, and can be returned by setting the ``include_empty`` argument to ``True``:

.. testcode::

empty_1q, empty_2q, *estimated_gates = GST(
gate_set = gate_set,
nshots = 10000,
noise_model = noise_model,
include_empty = True,
)
where ``empty_1q`` and ``empty_2q`` correspond to the single and two qubits empty matrices respectively.
Similarly, the Pauli-Liouville representation of the gates can be directly returned as well:

.. testcode::

estimated_gates = GST(
gate_set = gate_set,
nshots = 10000,
noise_model = noise_model,
pauli_liouville = True,
)
122 changes: 0 additions & 122 deletions doc/source/code-examples/tutorials/quantum_networks/README.md

This file was deleted.

Loading

0 comments on commit ee4b1b1

Please sign in to comment.