Skip to content

Commit

Permalink
Merge branch 'master' into fix_dbi_notebook
Browse files Browse the repository at this point in the history
  • Loading branch information
renatomello committed Jul 31, 2024
2 parents 10f559c + fb64fcf commit f3a0955
Show file tree
Hide file tree
Showing 93 changed files with 4,616 additions and 2,397 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python-version: [ 3.9, '3.10', '3.11', '3.12']
uses: qiboteam/workflows/.github/workflows/deploy-pip-poetry.yml@main
uses: qiboteam/workflows/.github/workflows/deploy-pip-poetry.yml@v1
with:
os: ${{ matrix.os }}
python-version: ${{ matrix.python-version }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
deploy-docs:
needs: [evaluate-label]
uses: qiboteam/workflows/.github/workflows/deploy-ghpages-latest-stable.yml@main
uses: qiboteam/workflows/.github/workflows/deploy-ghpages-latest-stable.yml@v1
with:
python-version: "3.10"
package-manager: "poetry"
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/rules.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python-version: [ 3.9, '3.10', '3.11', '3.12']
uses: qiboteam/workflows/.github/workflows/rules-poetry.yml@main
python-version: [3.9, "3.10", "3.11", "3.12"]
uses: qiboteam/workflows/.github/workflows/rules-poetry.yml@v1
with:
os: ${{ matrix.os }}
python-version: ${{ matrix.python-version }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/selfhosted.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ concurrency:
jobs:
build:
if: contains(join(github.event.pull_request.labels.*.name), 'run-on')
uses: qiboteam/workflows/.github/workflows/selfhosted.yml@main
uses: qiboteam/workflows/.github/workflows/selfhosted.yml@v1
with:
used-labels: ${{ toJSON(github.event.pull_request.labels.*.name) }}
python-version: "3.10"
Expand Down
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ repos:
- id: isort
args: ["--profile", "black"]
- repo: https://github.com/asottile/pyupgrade
rev: v3.16.0
rev: v3.17.0
hooks:
- id: pyupgrade
- repo: https://github.com/hadialqattan/pycln
Expand Down
118 changes: 118 additions & 0 deletions CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
# Qibo Code of Conduct

In the interest of fostering an open and welcoming environment, we as
contributors and maintainers pledge to make participation in our project and our
community a harassment-free experience for everyone, regardless of age, body
size, disability, ethnicity, gender identity and expression, level of
experience, nationality, personal appearance, race, religion, or sexual identity
and orientation.

## Our Standards

Examples of behavior that contributes to creating a positive environment
include:

* Using welcoming and inclusive language.
* Being respectful of differing viewpoints and experiences.
* Gracefully accepting constructive criticism.
* Focusing on what is best for the community.
* Showing empathy towards other community members.

Examples of unacceptable behavior by participants include:

* The use of sexualized language or imagery and unwelcome sexual attention or
advances.
* Trolling, insulting/derogatory comments, and personal or political attacks.
* Public or private harassment.
* Publishing others' private information, such as a physical or electronic
address, without explicit permission.
* Conduct which could reasonably be considered inappropriate for the forum in
which it occurs.

All Qibo forums and spaces are meant for professional interactions, and any
behavior which could reasonably be considered inappropriate in a professional
setting is unacceptable.


## Our Responsibilities

Project maintainers are responsible for clarifying the standards of acceptable
behavior and are expected to take appropriate and fair corrective action in
response to any instances of unacceptable behavior.

Project maintainers have the right and responsibility to remove, edit, or reject
comments, commits, code, wiki edits, issues, and other contributions that are
not aligned to this Code of Conduct, or to ban temporarily or permanently any
contributor for other behaviors that they deem inappropriate, threatening,
offensive, or harmful.


## Scope

This Code of Conduct applies to all content on https://qibo.science, Qibo's
GitHub organization, or any other official Qibo web presence allowing for
community interactions, as well as at all official Qibo events, whether offline
or online.

The Code of Conduct also applies within project spaces and in public spaces
whenever an individual is representing Qibo or its community. Examples of
representing a project or community include using an official project e-mail
address, posting via an official social media account, or acting as an appointed
or de facto representative at an online or offline event.


## Conflict Resolution

Conflicts in an open source project can take many forms, from someone having a
bad day and using harsh and hurtful language in the issue queue, to more serious
instances such as sexist/racist statements or threats of violence, and
everything in between.

If the behavior is threatening or harassing, or for other reasons requires
immediate escalation, please see below.

However, for the vast majority of issues, we aim to empower individuals to first
resolve conflicts themselves, asking for help when needed, and only after that
fails to escalate further. This approach gives people more control over the
outcome of their dispute.

If you are experiencing or witnessing conflict, we ask you to use the following
escalation strategy to address the conflict:

1. Address the perceived conflict directly with those involved, preferably in a
real-time medium.
2. If this fails, get a third party (e.g. a mutual friend, and/or someone with
background on the issue, but not involved in the conflict) to intercede.
3. If you are still unable to resolve the conflict, and you believe it rises to
harassment or another code of conduct violation, report it.

## Reporting Violations

Violations of the Code of Conduct can be reported to Qibo's Project Coordinator,
Stefano Carrazza (stefano.carrazza@unimi.it). The Project Coordinator will
determine whether the Code of Conduct was violated, and will issue an
appropriate sanction, possibly including a written warning or expulsion from the
project, project sponsored spaces, or project forums. We ask that you make a
good-faith effort to resolve your conflict via the conflict resolution policy
before submitting a report.

Violations of the Code of Conduct can occur in any setting, even those unrelated
to the project. We will only consider complaints about conduct that has occurred
within one year of the report.


## Enforcement

If the Project Coordinator receive a report alleging a violation of the Code of
Conduct, the Project Coordinator will notify the accused of the report, and
provide them an opportunity to discuss the report before a sanction is issued.
The Project Coordinator will do his utmost to keep the reporter anonymous. If
the act is ongoing (such as someone engaging in harassment), or involves a
threat to anyone's safety (e.g. threats of violence), the Project Coordinator
may issue sanctions without notice.


## Attribution

This Code of Conduct is adapted from the Contributor Covenant, version 1.4,
available at https://contributor-covenant.org/version/1/4.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ To get in touch with the community and the developers, consider joining the Qibo

[![Matrix](https://img.shields.io/matrix/qibo%3Amatrix.org?logo=matrix)](https://matrix.to/#/#qibo:matrix.org)

If you have a question about the project, please contact us with [📫](mailto:qiboteam@qibo.science).

## Supporters and collaborators

- Quantum Research Center, Technology Innovation Institute (TII), United Arab Emirates
Expand Down
109 changes: 107 additions & 2 deletions doc/source/api-reference/qibo.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1930,6 +1930,18 @@ Anticommutator
.. autofunction:: qibo.quantum_info.anticommutator


Partial trace
"""""""""""""

.. autofunction:: qibo.quantum_info.partial_trace


Matrix exponentiation
"""""""""""""""""""""

.. autofunction:: qibo.quantum_info.matrix_exponentiation


Quantum Networks
^^^^^^^^^^^^^^^^

Expand All @@ -1940,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 @@ -2365,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 @@ -2506,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,
)

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Loading

0 comments on commit f3a0955

Please sign in to comment.