Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add qibojit backend #427

Merged
merged 139 commits into from
Jul 9, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
139 commits
Select commit Hold shift + click to select a range
b93654e
Add qibojit backend
stavros11 Jun 9, 2021
6190377
Fix distributed circuit error
stavros11 Jun 9, 2021
83e3fdb
Make qubits tuple
stavros11 Jun 9, 2021
2f8534c
Fix density matrices in jit backend
stavros11 Jun 9, 2021
5b29691
Fix collapse result
stavros11 Jun 9, 2021
fc3cf53
Fix measure frequencies
stavros11 Jun 10, 2021
e1d8a84
Fix collapse result
stavros11 Jun 10, 2021
4a584ea
Fix tests
stavros11 Jun 10, 2021
8bc9762
Skip memory error tests
stavros11 Jun 10, 2021
6af0b5c
Disable bitflips when collapsing
stavros11 Jun 10, 2021
23e8190
Fix qibojit measurement tests
stavros11 Jun 10, 2021
d09f8f8
Change backend name
stavros11 Jun 10, 2021
bc0fce5
Fix loss casting for cma
stavros11 Jun 10, 2021
2088340
Fix loss casting
stavros11 Jun 10, 2021
ccbbf58
Revert "Fix loss casting"
stavros11 Jun 10, 2021
0304c47
Revert "Fix loss casting for cma"
stavros11 Jun 10, 2021
f14461f
Fix coverage
stavros11 Jun 10, 2021
e35a7b8
Fix coverage
stavros11 Jun 10, 2021
a217353
Fix coverage
stavros11 Jun 10, 2021
50dbbf2
Add dry run in benchmark script
stavros11 Jun 10, 2021
9f4611d
Add repetitions in benchmark script
stavros11 Jun 10, 2021
52cdef2
Log simulation time std
stavros11 Jun 12, 2021
0db2acf
Fix cupy setter in qibojit backend
stavros11 Jun 14, 2021
2e05c22
Fix backend agreement tests for cupy
stavros11 Jun 14, 2021
e31d195
Fix backend agreement tests
stavros11 Jun 15, 2021
7ce2a49
Fix backend matrix tests
stavros11 Jun 15, 2021
14fe11e
Fix gate tests for cupy
stavros11 Jun 15, 2021
4c30f6e
Fix core gate tests
stavros11 Jun 15, 2021
ba097a3
Fix measurement tests
stavros11 Jun 15, 2021
b49e9c2
Add repetitions in benchmark script
stavros11 Jun 10, 2021
d2588c6
Log simulation time std
stavros11 Jun 12, 2021
635a25a
Fix cupy setter in qibojit backend
stavros11 Jun 14, 2021
fa1e349
Update engine setter
stavros11 Jun 16, 2021
72b4192
Rename NumpyCustomBackend to JITCustomBackend
stavros11 Jun 16, 2021
da8feb4
Use return func instead of raising error compiling circuit
stavros11 Jun 16, 2021
839eaaa
Fix pylint
stavros11 Jun 16, 2021
99ed849
Fix coverage
stavros11 Jun 16, 2021
66d11c2
Fit ResetChannel tests for qibojit backend
stavros11 Jun 16, 2021
0462d35
Merge qibojit
stavros11 Jun 16, 2021
2a84bf9
Fix measurement tests
stavros11 Jun 16, 2021
e64d81d
Update measurement collapse tests
stavros11 Jun 16, 2021
b1144ca
Add assert_allclose in abstract backend
stavros11 Jun 16, 2021
b4bb077
Fix pylint
stavros11 Jun 16, 2021
81ee1e2
Fix CPU tests
stavros11 Jun 16, 2021
9e3c289
Merge branch 'master' into qibojit
stavros11 Jun 17, 2021
2e6ced2
Fix examples test
stavros11 Jun 17, 2021
efb84ca
Merge branch 'qibojit' into cupytests
stavros11 Jun 17, 2021
fb924c0
Fix metropolis threshold name in numpy backend
stavros11 Jun 17, 2021
85858e4
Merge qibojit
stavros11 Jun 17, 2021
e262690
Merge qibojit
stavros11 Jun 17, 2021
fec2273
Fix measurement tests
stavros11 Jun 17, 2021
5ee42dc
Fix gate tests
stavros11 Jun 17, 2021
4df13d6
Update cupy tensor types
stavros11 Jun 18, 2021
7492ca8
Update test callbacks and cirq
stavros11 Jun 18, 2021
b3c0dc6
Update Hamiltonian tests
stavros11 Jun 18, 2021
b78f523
Update state tests
stavros11 Jun 18, 2021
ba7c93d
Fix probabilistic tests
stavros11 Jun 18, 2021
16ae33c
Fix falqon test
stavros11 Jun 18, 2021
2d29ee1
Simplify backend tests
stavros11 Jun 18, 2021
78e2e17
Move matrix allocation to abstract backend
stavros11 Jun 18, 2021
311f015
Fix callback tests
stavros11 Jun 18, 2021
fd066a2
Update fusion tests
stavros11 Jun 19, 2021
44695fc
Update evolution tests
stavros11 Jun 19, 2021
10fbf8e
Add transfer arg in benchmarks
stavros11 Jun 21, 2021
9dbe039
Fix tf import in benchmark
stavros11 Jun 22, 2021
5509b3d
Fix coverage
stavros11 Jun 22, 2021
a120c70
Remove memory test skip
stavros11 Jun 27, 2021
b39c15c
Cupy device placement
stavros11 Jun 27, 2021
dde0d1f
Silence numpy device placement warning
stavros11 Jun 27, 2021
546a05f
Update VQE benchmark
stavros11 Jun 27, 2021
4966b4d
Fix evolution benchmark
stavros11 Jun 27, 2021
8b3e61c
Log number of threads
stavros11 Jun 27, 2021
84af3b7
Fix json loading
stavros11 Jun 27, 2021
6e471f6
Fix examples test
stavros11 Jun 28, 2021
f0fba90
Select qibojit threading layer
stavros11 Jun 29, 2021
8051a4c
Merge pull request #432 from qiboteam/cupytests
scarrazza Jun 30, 2021
bdff00b
Fix threading logging for GPU
stavros11 Jun 30, 2021
bcfbb30
Move thread setter and getter to backend
stavros11 Jul 1, 2021
0a77e23
Remove get_threads
stavros11 Jul 1, 2021
b1ddda8
Thread setter for jit backend
stavros11 Jul 1, 2021
c3559da
Use numba.set_num_threads
stavros11 Jul 1, 2021
932b37f
Set default numba threads
stavros11 Jul 1, 2021
8bb8db2
Fix pylint
stavros11 Jul 1, 2021
8f2d192
Include NUMBA_NUM_THREADS environment variable
stavros11 Jul 1, 2021
49dc093
Move setters to each backend
stavros11 Jul 1, 2021
a3d1ff5
Fix pylint
stavros11 Jul 1, 2021
d88a3b3
Merge pull request #434 from qiboteam/setthreads
scarrazza Jul 2, 2021
959f731
Make qibojit default and improve warnings
stavros11 Jul 3, 2021
22a3098
Remove warnings that do not use logger
stavros11 Jul 3, 2021
90f353a
Log level flag
stavros11 Jul 3, 2021
bed99e5
Update tf warning
stavros11 Jul 3, 2021
c9402da
Fix warning tests
stavros11 Jul 3, 2021
a85eff1
Fix distributed test
stavros11 Jul 3, 2021
2be283e
fixing syntax error
scarrazza Jul 3, 2021
7d84903
splitting docs by topic and application
scarrazza Jul 3, 2021
32bdc9e
adding qibojit
scarrazza Jul 3, 2021
285b407
updating installation instructions
scarrazza Jul 3, 2021
8f3fae9
Cast matrices when backend is changed to cupy
stavros11 Jul 4, 2021
a908761
changing backend order to match pull request 436
scarrazza Jul 4, 2021
87e5e83
Update Hamiltonian tests
stavros11 Jul 4, 2021
683b450
Remove numpy Hamiltonian tests
stavros11 Jul 4, 2021
e9c9303
Update gpu tests
stavros11 Jul 4, 2021
d171f6e
Fix adiabatic Hamiltonian casting
stavros11 Jul 4, 2021
6b7ef33
Fix coverage
stavros11 Jul 4, 2021
f39a6e9
resorting backends, and making qibojit default
scarrazza Jul 4, 2021
6ff50dc
improving indexing
scarrazza Jul 4, 2021
8c5fe1b
Merge pull request #435 from qiboteam/docup
scarrazza Jul 4, 2021
5daaa1e
Document log level variable
stavros11 Jul 5, 2021
56a50e8
Remove defaulteinsum and matmuleinsum from examples
stavros11 Jul 5, 2021
177d26d
Update backends section
stavros11 Jul 5, 2021
68f785a
adding note about cupy requirement
scarrazza Jul 5, 2021
5712247
adding qibojit to CI
scarrazza Jul 5, 2021
c8d6fb3
excluding parallel evaluation for qibojit
scarrazza Jul 6, 2021
5467c4e
disabling parallel on darwin
scarrazza Jul 6, 2021
3e84854
fixing missing import
scarrazza Jul 6, 2021
01dee8c
fix typo
scarrazza Jul 6, 2021
7861b84
updating parallel tests
scarrazza Jul 6, 2021
a9d251d
adding qibojit to windows tests
scarrazza Jul 6, 2021
517bfaf
Fix examples
stavros11 Jul 6, 2021
4277525
Fix efqae
stavros11 Jul 6, 2021
9774437
Skip hanging tests
stavros11 Jul 6, 2021
6737296
Remove all Tensorflow imports
stavros11 Jul 7, 2021
1afe8c9
Remove tf use
stavros11 Jul 7, 2021
ef54c2b
Fix reuploading example
stavros11 Jul 7, 2021
7eee9b8
fixing entropy_large_circuit test on GPU
scarrazza Jul 7, 2021
6db9413
removing large N for shor example
scarrazza Jul 7, 2021
37a00ec
skipping shor
scarrazza Jul 7, 2021
94390c3
moving to qibojit, unlocking shor
scarrazza Jul 7, 2021
8940731
fixing to numpy conversion, running all tests
scarrazza Jul 7, 2021
f4a3243
reducing EF_QAE iterations
scarrazza Jul 7, 2021
e6a1f45
trying single thread
scarrazza Jul 8, 2021
6f43204
cleanup
scarrazza Jul 8, 2021
9d7a949
fixing examples tests on gpu
scarrazza Jul 8, 2021
56abc57
adding logging info when changing backend / showing default device
scarrazza Jul 8, 2021
f73b07b
reducing unary footprint
scarrazza Jul 8, 2021
1d72d91
Merge pull request #438 from qiboteam/fixparalleljit
scarrazza Jul 8, 2021
31c569f
Merge pull request #437 from qiboteam/testqibojit
scarrazza Jul 9, 2021
c35f327
Merge pull request #436 from qiboteam/warnings
scarrazza Jul 9, 2021
978340d
updating configuration string
scarrazza Jul 9, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/rules.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,14 @@ jobs:
python -m pip install --upgrade pip
pip install pylint
pip install pytest-cov
pip install .[qibotf,docs,tests]
pip install .[qibojit,qibotf,docs,tests]
- name: Install package on Windows
if: startsWith(matrix.os, 'windows')
run: |
python -m pip install --upgrade pip
pip install pylint
pip install pytest-cov
pip install .[docs,tests]
pip install .[qibojit,docs,tests]
- name: Test with pylint
run: |
pylint src -E -d E1123,E1120
Expand All @@ -43,7 +43,7 @@ jobs:
- name: Test examples
if: startsWith(matrix.os, 'ubuntu') && matrix.python-version == '3.9'
run: |
pytest examples/
OMP_NUM_THREADS=1 pytest examples/
- name: Upload coverage to Codecov
if: startsWith(matrix.os, 'ubuntu')
uses: codecov/codecov-action@v1
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/wheels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,15 @@ jobs:
if: startsWith(matrix.os, 'windows') == 0
run: |
python -m pip install --upgrade pip
pip install qibotf pytest cirq ply sklearn
pip install qibojit qibotf pytest cirq ply sklearn
pip install -r requirements.txt
pip install qibo --no-index --find-links ./dist/
pytest --pyargs qibo
- name: Test wheels on windows
if: startsWith(matrix.os, 'windows')
run: |
python -m pip install --upgrade pip
pip install pytest cirq ply sklearn
pip install qibojit pytest cirq ply sklearn
pip install -r requirements.txt
pip install qibo --no-index --find-links ./dist/
pytest --pyargs qibo
Expand Down
25 changes: 12 additions & 13 deletions doc/source/advancedexamples.rst
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,11 @@ raised prompting the user to switch the default device using ``qibo.set_device``
Setting the number of CPU threads
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Qibo by default uses the ``"custom"`` operators backend. This backend uses
OpenMP instructions for the parallelization. In most cases will utilize all
available CPU threads. For small circuits the parallelization overhead may
decrease performance making single thread execution preferrable.
Qibo by default uses the ``qibojit`` or ``qibotf`` backends which are based on
custom operators. These backends uses OpenMP instructions for parallelization.
In most cases, utilizing all available CPU threads provides better performance.
However, for small circuits the parallelization overhead may decrease
performance making single thread execution preferrable.

You can restrict the number of threads by exporting the ``OMP_NUM_THREADS``
environment variable with the requested number of threads before launching Qibo,
Expand All @@ -81,8 +82,8 @@ or programmatically, during runtime, as follows:
# retrieve the current number of threads
current_threads = qibo.get_threads()

On the other hand, when using the ``"matmuleinsum"`` or ``"defaulteinsum"``
backends Qibo inherits Tensorflow's defaults for CPU thread configuration.
On the other hand, when using the ``tensorflow`` backend Qibo inherits
Tensorflow's defaults for CPU thread configuration.
Tensorflow allows restricting the number of threads as follows:

.. code-block:: python
Expand Down Expand Up @@ -561,7 +562,7 @@ refer to the :ref:`Optimizers <Optimizers>` section of the documentation.
Note that if the Stochastic Gradient Descent optimizer is used then the user
has to use a backend based on tensorflow primitives and not the default custom
backend, as custom operators currently do not support automatic differentiation.
To switch the backend one can do ``qibo.set_backend("matmuleinsum")``.
To switch the backend one can do ``qibo.set_backend("tensorflow")``.
Check the :ref:`How to use automatic differentiation? <autodiff-example>`
section for more details.

Expand Down Expand Up @@ -707,9 +708,8 @@ function.

.. code-block:: python

# switch backend to "matmuleinsum" or "defaulteinsum"
import qibo
qibo.set_backend("matmuleinsum")
qibo.set_backend("tensorflow")
import tensorflow as tf
from qibo import gates, models

Expand All @@ -733,9 +733,8 @@ function.
optimizer.apply_gradients(zip([grads], [params]))


Note that a backend that uses tensorflow primitives gates
(either ``"matmuleinsum"`` or ``"defaulteinsum"``) has to be used because
the default ``"custom"`` backend does not support automatic differentiation.
Note that the ``"tensorflow"`` backend has to be used here because ``"qibotf"``
and other custom backends do not support automatic differentiation.

The optimization procedure may also be compiled, however in this case it is not
possible to use :meth:`qibo.abstractions.circuit.AbstractCircuit.set_parameters` as the
Expand All @@ -745,7 +744,7 @@ For example:
.. code-block:: python

import qibo
qibo.set_backend("matmuleinsum")
qibo.set_backend("tensorflow")
import tensorflow as tf
from qibo import gates, models

Expand Down
132 changes: 124 additions & 8 deletions doc/source/applications.rst
Original file line number Diff line number Diff line change
@@ -1,27 +1,143 @@
Application tutorials
=====================
Applications
============

In this section we present some examples of quantum circuits applied to specific
problems.

_______________________

Applications by topic
---------------------

Complexity theory
^^^^^^^^^^^^^^^^^

.. toctree::
:maxdepth: 1

tutorials/aavqe/README.md
tutorials/grover3sat/README.md
tutorials/adiabatic3sat/README.md


Condensed Matter Physics
^^^^^^^^^^^^^^^^^^^^^^^^

.. toctree::
:maxdepth: 1

tutorials/aavqe/README.md


Cryptography
^^^^^^^^^^^^

.. toctree::
:maxdepth: 1

tutorials/hash-grover/README.md


Finance
^^^^^^^

.. toctree::
:maxdepth: 1

tutorials/unary/README.md


High-Energy Physics
^^^^^^^^^^^^^^^^^^^

.. toctree::
:maxdepth: 1

tutorials/qPDF/qPDF.ipynb


Quantum Physics
^^^^^^^^^^^^^^^

.. toctree::
:maxdepth: 1

tutorials/qsvd/README.md
tutorials/3_tangle/README.md
tutorials/adiabatic/README.md
tutorials/shor/README.md
tutorials/bell-variational/README.md
tutorials/falqon/README.md
tutorials/grover/README.md

Quantum Machine Learning
^^^^^^^^^^^^^^^^^^^^^^^^

.. toctree::
:maxdepth: 1

tutorials/variational_classifier/README.md
tutorials/reuploading_classifier/README.md
tutorials/autoencoder/README.md
tutorials/EF_QAE/README.md

_______________________

Applications by algorithm
-------------------------

Variational Quantum Circuits
^^^^^^^^^^^^^^^^^^^^^^^^^^^^

.. toctree::
:maxdepth: 1

tutorials/aavqe/README.md
tutorials/variational_classifier/README.md
tutorials/reuploading_classifier/README.md
tutorials/autoencoder/README.md
tutorials/qsvd/README.md
tutorials/3_tangle/README.md
tutorials/EF_QAE/README.md
tutorials/unary/README.md
tutorials/bell-variational/README.md
tutorials/qPDF/qPDF.ipynb


Grover's Algorithm
^^^^^^^^^^^^^^^^^^

.. toctree::
:maxdepth: 1

tutorials/grover3sat/README.md
tutorials/hash-grover/README.md
tutorials/grover/README.md


Shor's Factorization Algorithms
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

.. toctree::
:maxdepth: 1

tutorials/shor/README.md


Adiabatic Evolution
^^^^^^^^^^^^^^^^^^^

.. toctree::
:maxdepth: 1

tutorials/adiabatic/README.md
tutorials/adiabatic3sat/README.md
tutorials/EF_QAE/README.md
tutorials/shor/README.md
tutorials/qPDF/qPDF.ipynb
tutorials/bell-variational/README.md


FALQON
^^^^^^

.. toctree::
:maxdepth: 1

tutorials/falqon/README.md
tutorials/grover/README.md

Binary file modified doc/source/backends.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 6 additions & 7 deletions doc/source/examples.rst
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,9 @@ evaluation performance, e.g.:
.. code-block:: python

import numpy as np
# switch backend to "matmuleinsum" or "defaulteinsum"
# (slower than default "custom" backend)
# switch backend to "tensorflow"
import qibo
qibo.set_backend("matmuleinsum")
qibo.set_backend("tensorflow")
from qibo.models import Circuit
from qibo import gates

Expand All @@ -52,10 +51,10 @@ evaluation performance, e.g.:
init_state = np.ones(4) / 2.0 + i
c(init_state)

Note that compiling is only supported when native tensorflow gates are used.
This happens when the calculation backend is switched to ``"matmuleinsum"``
or ``"defaulteinsum"``. This backend is much slower than the default ``"custom"``
backend which uses custom tensorflow operators to apply gates.
Note that compiling is only supported when the native ``tensorflow`` backend
is used. This backend is much slower than ``qibotf`` which uses custom
tensorflow operators to apply gates.


How to print a circuit summary?
-------------------------------
Expand Down
Loading