Installation instructions#
Operating systems support#
In the table below we summarize the status of pre-compiled binaries distributed with pypi for the packages listed above.
Operating System |
qibo |
qibojit |
Tensorflow |
Pytorch |
---|---|---|---|---|
Linux x86 |
Yes |
Yes |
Yes |
Yes |
MacOS >= 10.15 |
Yes |
Yes |
Yes |
Yes |
Windows |
Yes |
Yes |
Yes |
Yes |
Note
All packages are supported for Python >= 3.9.
Backend installation#
qibo#
The qibo
is the base required package which includes the language API and a
lightweight cross-platform simulator based on numpy
. In order to accelerate
simulation please consider specialized backends listed in
Simulation backends.
Installing with pip#
The installation using pip
is the recommended approach to install Qibo.
Make sure you have Python 3.9 or greater, then use pip
to install qibo
with:
pip install qibo
The pip
program will download and install all the required
dependencies for Qibo.
Installing from source#
The installation procedure presented in this section is useful when you have to develop the code from source.
In order to install Qibo from source, you can simply clone the GitHub repository with
git clone https://github.com/qiboteam/qibo.git
cd qibo
pip install .
qibojit#
The qibojit
package contains a simulator implementation based on
just-in-time (JIT) custom kernels using numba
and cupy. We also provide another implementation based
on cuQuantum primitives available
when running Qibo on GPU.
This backend is used by default, however, if needed, in order to switch to the
qibojit
backend please do:
import qibo
qibo.set_backend("qibojit")
Custom cupy kernels will be used by default if a GPU is available and
custom numba kernels if a GPU is not available.
If a GPU is available it is possible to switch to the cuQuantum implementation
using the platform
argument, for example:
import qibo
# switch to the cuquantum implementation
qibo.set_backend("qibojit", platform="cuquantum")
# switch to custom numba kernels (even if a GPU is available)
qibo.set_backend("qibojit", platform="numba")
Installing with pip#
The installation using pip
is the recommended approach to install
qibojit
.
In order to install the package use the following command:
pip install qibojit
Note
The pip
program will download and install all the required
dependencies except cupy and/or
cuQuantum
which are required for GPU acceleration.
The cuQuantum dependency is optional, as it is required only for
the cuquantum
platform. Please install cupy by following the
instructions from the official website for your GPU hardware.
The installation instructions for cuQuantum
are available in the official documentation.
qibojit
is compatible with
cuQuantum SDK v22.03
and
cuQuantum SDK v22.05.
Installing from source#
The installation procedure presented in this section is useful if you have to develop the code from source.
In order to install the package perform the following steps:
git clone https://github.com/qiboteam/qibojit.git
cd qibojit
Then proceed with the qibojit
installation using pip
pip install .
numpy#
The qibo
base package is distributed with a lightweight quantum simulator
shipped with the qibo base package. No extra packages are required.
This backend is used by default if qibojit
or tensorflow
are not
installed, however, if needed, in order to switch to the numpy
backend
please do:
import qibo
qibo.set_backend("numpy")
Backends with automatic differentiation support#
If you need automatic differentiation support, for tracing gradients of your quantum algorithm or for building some quantum machine learning routine, the right backends for you are those provided by the Qiboml package.
In particular, Qiboml currently support Pytorch and Tensorflow interfaces, integrating the qibo functionalities into these well-known machine learning frameworks. Quantum layers can be constructed and added to your Pytorch or Tensorflow models, and trained using any supported optimization routine.
In order to use these quantum machine learning backends please make sure the preferred package is installed following Tensorflow’s or Pytorch’s installation instructions.
To switch to Tensorflow or Pytorch backend please do:
import qibo
# in case of Tensorflow
qibo.set_backend(backend="qiboml", platform="tensorflow")
# in case of Pytorch
qibo.set_backend(backend="qiboml", platform="pytorch")
In order to start using automatic differentiation tools with Qibo, we recommend the installation using:
pip install qibo qiboml tensorflow
or
pip install qibo qiboml torch