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

Clifford Simulator #1076

Merged
merged 190 commits into from
Dec 16, 2023
Merged
Show file tree
Hide file tree
Changes from 185 commits
Commits
Show all changes
190 commits
Select commit Hold shift + click to select a range
bc40f64
began to write the clifford backend
BrunoLiegiBastonLiegi Oct 26, 2023
63dab54
minor corrections + started implementation of M gate
BrunoLiegiBastonLiegi Oct 30, 2023
10dbfa6
finished M implementation but not working
BrunoLiegiBastonLiegi Nov 1, 2023
e8d4729
Fixed measurements
BrunoLiegiBastonLiegi Nov 3, 2023
51d94b8
simple renaming
BrunoLiegiBastonLiegi Nov 6, 2023
291ec66
added samples registration to measurement result
BrunoLiegiBastonLiegi Nov 6, 2023
7b2b6f7
Merge branch 'master' into clifford_simulator
BrunoLiegiBastonLiegi Nov 6, 2023
66c4624
Update src/qibo/backends/clifford.py
renatomello Nov 6, 2023
9242bc9
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Nov 6, 2023
ec6f21b
Update src/qibo/backends/clifford.py
renatomello Nov 6, 2023
4832214
consolidate files and minor changes
renatomello Nov 7, 2023
063371e
returning MeasurementOutcomes
BrunoLiegiBastonLiegi Nov 7, 2023
34d7295
Implemented Clifford object + rules for paulis
BrunoLiegiBastonLiegi Nov 7, 2023
f074299
added rule for CZ
BrunoLiegiBastonLiegi Nov 7, 2023
81a69be
finished implementation of single qubit gates rules
BrunoLiegiBastonLiegi Nov 9, 2023
7afe12f
Merge branch 'master' into clifford_simulator
renatomello Nov 9, 2023
5360da4
implemented tableu to state
BrunoLiegiBastonLiegi Nov 9, 2023
544ef11
fixed to state and added swap
BrunoLiegiBastonLiegi Nov 10, 2023
5725e0e
small fix to to state with strings
BrunoLiegiBastonLiegi Nov 10, 2023
6787253
Merge branch 'master' into clifford_simulator
renatomello Nov 12, 2023
acc82ce
fixed RY
BrunoLiegiBastonLiegi Nov 13, 2023
4f5890c
implemented iswap rule
BrunoLiegiBastonLiegi Nov 13, 2023
f842bfc
implemented CY
BrunoLiegiBastonLiegi Nov 13, 2023
18fc9c3
removed cached file
BrunoLiegiBastonLiegi Nov 13, 2023
3e0dbf6
implemented some more gates
BrunoLiegiBastonLiegi Nov 14, 2023
c7516e1
removed non clifford gates + updated clifford object
BrunoLiegiBastonLiegi Nov 14, 2023
4192c32
Merge branch 'master' into clifford_simulator
renatomello Nov 15, 2023
ff88c1b
Merge branch 'master' into clifford_simulator
renatomello Nov 15, 2023
905cb4a
fixed samples probabilities and frequencies calculation
BrunoLiegiBastonLiegi Nov 15, 2023
2e3c574
implemented FSWAP and ECR
BrunoLiegiBastonLiegi Nov 15, 2023
7b58441
fixed prob calculation
BrunoLiegiBastonLiegi Nov 16, 2023
03ce9ee
implemented CR decompositions, CY propably not working
BrunoLiegiBastonLiegi Nov 17, 2023
a42b3d8
Merge branch 'master' into clifford_simulator
renatomello Nov 18, 2023
1b82fda
trying to fix CY
BrunoLiegiBastonLiegi Nov 20, 2023
c5d6b9b
fixed CY
BrunoLiegiBastonLiegi Nov 20, 2023
f8d53de
small fix to exponent
BrunoLiegiBastonLiegi Nov 20, 2023
8c72221
delayed samples generation
BrunoLiegiBastonLiegi Nov 20, 2023
41489aa
added some tests
BrunoLiegiBastonLiegi Nov 21, 2023
e19dada
removed nqubits method from operations
BrunoLiegiBastonLiegi Nov 21, 2023
2e11048
fixed python 3.9 error + implemented add_shot_from_sample
BrunoLiegiBastonLiegi Nov 21, 2023
0a3f16d
Merge branch 'master' into clifford_simulator
renatomello Nov 21, 2023
574ed57
fixed collapsing measurements
BrunoLiegiBastonLiegi Nov 22, 2023
c7e5561
written some docstrings
BrunoLiegiBastonLiegi Nov 22, 2023
698ad98
more docstrings
BrunoLiegiBastonLiegi Nov 22, 2023
a0f208c
Merge branch 'master' into clifford_simulator
BrunoLiegiBastonLiegi Nov 22, 2023
64c4ff9
improved coverage
BrunoLiegiBastonLiegi Nov 22, 2023
eae3ee8
small fix
BrunoLiegiBastonLiegi Nov 23, 2023
673a46c
added test for registers
BrunoLiegiBastonLiegi Nov 23, 2023
8899a34
trying to fix a bug with bitflip noise
BrunoLiegiBastonLiegi Nov 23, 2023
79045be
written some docs
BrunoLiegiBastonLiegi Nov 24, 2023
b2eafaf
more docs
BrunoLiegiBastonLiegi Nov 27, 2023
944a068
fixed bug in circuitresult probabilities
BrunoLiegiBastonLiegi Nov 27, 2023
077e086
Merge branch 'master' into clifford_simulator
renatomello Nov 27, 2023
fa3d35f
fix typo
BrunoLiegiBastonLiegi Nov 27, 2023
d9251dc
fixed bitflip test
BrunoLiegiBastonLiegi Nov 27, 2023
7abefec
addressing comments
BrunoLiegiBastonLiegi Nov 27, 2023
6c6cb1a
added clifford backend to construct_backend
BrunoLiegiBastonLiegi Nov 27, 2023
fda22f7
added test for set_backend
BrunoLiegiBastonLiegi Nov 27, 2023
fd078c5
trying to fix the metrics test
BrunoLiegiBastonLiegi Nov 28, 2023
a57afdd
changed error message
BrunoLiegiBastonLiegi Nov 29, 2023
402a0da
Delete tests/test_backends_clifford.py~
renatomello Nov 29, 2023
4ea22cb
Delete tests/test_quantum_info_clifford.py~
renatomello Nov 29, 2023
7f3b2bd
Merge branch 'master' into clifford_simulator
renatomello Nov 30, 2023
dbd31d7
Update src/qibo/quantum_info/clifford.py
renatomello Nov 30, 2023
9fb46e7
Update src/qibo/quantum_info/clifford.py
renatomello Nov 30, 2023
23d6294
Update src/qibo/quantum_info/clifford.py
renatomello Nov 30, 2023
8cc69db
Update src/qibo/quantum_info/clifford.py
renatomello Nov 30, 2023
0d60ea2
Update src/qibo/quantum_info/clifford.py
renatomello Nov 30, 2023
325a536
Update src/qibo/quantum_info/clifford.py
renatomello Nov 30, 2023
f8bff06
Update src/qibo/quantum_info/clifford.py
renatomello Nov 30, 2023
b69780c
Update src/qibo/quantum_info/clifford.py
renatomello Nov 30, 2023
cd64b96
Update src/qibo/quantum_info/clifford.py
renatomello Nov 30, 2023
984f369
Update src/qibo/quantum_info/clifford.py
renatomello Nov 30, 2023
1fdf232
Update src/qibo/quantum_info/clifford.py
renatomello Nov 30, 2023
bc1516b
Update src/qibo/quantum_info/clifford.py
renatomello Nov 30, 2023
7f662f5
Update src/qibo/quantum_info/clifford.py
renatomello Nov 30, 2023
86d9ce0
Update src/qibo/quantum_info/clifford.py
renatomello Nov 30, 2023
f267bf3
Update src/qibo/quantum_info/clifford.py
renatomello Nov 30, 2023
ccef8e3
Update src/qibo/quantum_info/clifford.py
renatomello Nov 30, 2023
db4333c
Update src/qibo/quantum_info/clifford.py
renatomello Nov 30, 2023
9b3a20f
Update src/qibo/quantum_info/clifford.py
renatomello Nov 30, 2023
0ca7159
Update src/qibo/quantum_info/clifford.py
renatomello Nov 30, 2023
f848533
rename variables and capitalize Clifford
renatomello Nov 30, 2023
afe7f2b
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Nov 30, 2023
57f3796
refactoring names
renatomello Nov 30, 2023
1a691b9
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Nov 30, 2023
cd73bbd
tests
renatomello Nov 30, 2023
26bb235
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Nov 30, 2023
6017d7f
improved operator string product
BrunoLiegiBastonLiegi Nov 30, 2023
c25b9d6
added engine to clifford backend
BrunoLiegiBastonLiegi Dec 1, 2023
874c055
Update doc/source/api-reference/qibo.rst
BrunoLiegiBastonLiegi Dec 1, 2023
bf2e776
Merge branch 'master' into clifford_simulator
renatomello Dec 1, 2023
ca4f5a9
reorder variables
renatomello Dec 1, 2023
5ef5b5c
order code
renatomello Dec 1, 2023
203f0a1
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Dec 1, 2023
ef8941b
doc
renatomello Dec 1, 2023
a0cb0a9
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Dec 1, 2023
476d90b
Merge branch 'master' into clifford_simulator
renatomello Dec 1, 2023
317e383
Merge branch 'master' into clifford_simulator
renatomello Dec 1, 2023
0b25a1d
parallelized rowsum
BrunoLiegiBastonLiegi Dec 1, 2023
f2d59a0
small fix
BrunoLiegiBastonLiegi Dec 1, 2023
4c73830
fixed the repeated exec
BrunoLiegiBastonLiegi Dec 1, 2023
20cb984
Merge branch 'master' into clifford_simulator
renatomello Dec 2, 2023
572cf65
fix examples
renatomello Dec 2, 2023
6bea0da
remove extra CY
renatomello Dec 2, 2023
9c40fa8
make functions helper functions
renatomello Dec 2, 2023
e66c608
documentation
renatomello Dec 2, 2023
2002a25
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Dec 2, 2023
80d06b4
update lock file
renatomello Dec 2, 2023
896b992
Merge branch 'master' into clifford_simulator
renatomello Dec 2, 2023
8d6f2da
trying to fix cupy engine
BrunoLiegiBastonLiegi Dec 4, 2023
e0cc7a2
small fix
BrunoLiegiBastonLiegi Dec 4, 2023
c2d999a
Merge branch 'master' into clifford_simulator
renatomello Dec 5, 2023
aca4331
parallelized rowsum when possible
BrunoLiegiBastonLiegi Dec 5, 2023
716a225
fixing doctests
BrunoLiegiBastonLiegi Dec 5, 2023
a9600a8
fix to construct_backend
BrunoLiegiBastonLiegi Dec 5, 2023
19acc8f
fix: correcting clifford doctest
BrunoLiegiBastonLiegi Dec 5, 2023
4db97da
Merge branch 'master' into clifford_simulator
renatomello Dec 6, 2023
1e336b7
fix doc test
renatomello Dec 6, 2023
8de4ba7
fix doc test
renatomello Dec 6, 2023
1de5be7
no cover for gpu backends
renatomello Dec 6, 2023
9d3be4f
no cover for gpu backend `__init__`
renatomello Dec 6, 2023
8255265
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Dec 6, 2023
9336a28
fix function
renatomello Dec 6, 2023
043a98c
fix coverage
renatomello Dec 6, 2023
f2172bd
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Dec 6, 2023
b4affa1
test `from_symplectic_matrix`
renatomello Dec 6, 2023
c980a99
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Dec 6, 2023
fe5c9c0
fix: fix tes_samples_error
BrunoLiegiBastonLiegi Dec 6, 2023
69ce1b5
fixing tests for GPU
renatomello Dec 6, 2023
8042d5d
Merge branch 'clifford_simulator' of https://github.com/qiboteam/qibo…
renatomello Dec 6, 2023
1da699f
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Dec 6, 2023
2df4180
overwrite `cast`
renatomello Dec 6, 2023
847f2db
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Dec 6, 2023
2827c39
feat: using reduce inside of matrix_to_generators
BrunoLiegiBastonLiegi Dec 6, 2023
8700abb
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Dec 6, 2023
39ddc4a
fix test GPU
renatomello Dec 6, 2023
382be10
Merge branch 'clifford_simulator' of https://github.com/qiboteam/qibo…
renatomello Dec 6, 2023
6eba4e9
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Dec 6, 2023
dcf28c7
fix: fix destabilizers
BrunoLiegiBastonLiegi Dec 6, 2023
cf45625
bring modifications back
renatomello Dec 7, 2023
a843b65
fix destabilizer tests for GPU
renatomello Dec 7, 2023
dd44adb
fix tests GPU
renatomello Dec 7, 2023
1604ebf
fix tests
renatomello Dec 7, 2023
7ca3c3b
remove print
renatomello Dec 7, 2023
981ea42
fix tests
renatomello Dec 7, 2023
43f7b26
fix tests
renatomello Dec 7, 2023
2a52919
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Dec 7, 2023
2576df8
revert changes
renatomello Dec 7, 2023
fcd118b
feat: minor performance tweak
BrunoLiegiBastonLiegi Dec 7, 2023
fe87123
fix tests
renatomello Dec 7, 2023
db34b54
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Dec 7, 2023
5b0d6de
remove prints
renatomello Dec 7, 2023
0d45a94
fix: bugfix to _construct_operators + improved coverage
BrunoLiegiBastonLiegi Dec 8, 2023
f8d06f8
fix: removed unused nshots argument from apply_clifford
BrunoLiegiBastonLiegi Dec 8, 2023
bbc818c
fix: remove useless flatten
BrunoLiegiBastonLiegi Dec 8, 2023
66faf9d
fix: removed unnecessary vstacks
BrunoLiegiBastonLiegi Dec 8, 2023
115f48d
fix: improving coverage
BrunoLiegiBastonLiegi Dec 8, 2023
b8d4e58
include `TODO`
renatomello Dec 8, 2023
8ca18d1
renaming image
renatomello Dec 8, 2023
d693eef
reorder
renatomello Dec 9, 2023
5aac466
Merge branch 'master' into clifford_simulator
renatomello Dec 9, 2023
3149c91
Merge branch 'master' into clifford_simulator
renatomello Dec 11, 2023
6e0a55f
improving api ref
renatomello Dec 11, 2023
b4413e1
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Dec 11, 2023
3de9b35
improving docstring
renatomello Dec 11, 2023
be1b142
typo
renatomello Dec 11, 2023
0ece434
feat: added docstrings for _exponent and _rowsum
BrunoLiegiBastonLiegi Dec 11, 2023
a1383ee
improving docstring
renatomello Dec 11, 2023
ff01e3a
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Dec 11, 2023
c5b3980
api reference
renatomello Dec 11, 2023
0deafd0
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Dec 11, 2023
470f928
revert changes
renatomello Dec 11, 2023
6d88bd8
Merge branch 'clifford_simulator' of https://github.com/qiboteam/qibo…
renatomello Dec 11, 2023
46c09d0
revert changes
renatomello Dec 11, 2023
7a0677d
revert change
renatomello Dec 11, 2023
fd95402
feat: substituted * with & for improved performance
BrunoLiegiBastonLiegi Dec 11, 2023
e160bdf
testing solution
renatomello Dec 11, 2023
f39864a
revert changes
renatomello Dec 12, 2023
72e1306
revert changes
renatomello Dec 12, 2023
9ac4e59
feat: added another example to api-reference
BrunoLiegiBastonLiegi Dec 12, 2023
52872ea
fix doc test
renatomello Dec 12, 2023
8e551cd
Merge branch 'master' into clifford_simulator
renatomello Dec 12, 2023
d6b3234
fix doc test
renatomello Dec 12, 2023
67ba306
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Dec 12, 2023
c899ffc
try fixing test
renatomello Dec 12, 2023
e20e5e5
fix: increased tolerance in test_result.py
BrunoLiegiBastonLiegi Dec 12, 2023
6217f18
Merge branch 'master' into clifford_simulator
renatomello Dec 13, 2023
25484a0
Merge branch 'master' into clifford_simulator
renatomello Dec 14, 2023
166acad
Update src/qibo/backends/clifford.py
renatomello Dec 16, 2023
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
Binary file added doc/source/_static/symplectic_matrix.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
121 changes: 121 additions & 0 deletions doc/source/api-reference/qibo.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1368,6 +1368,71 @@ Pauli basis to computational basis
.. autofunction:: qibo.quantum_info.pauli_to_comp_basis


Phase-space Representation of Stabilizer States
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

A *stabilizer state* :math:`\ketbra{\psi}{\psi}` can be uniquely defined by
the set of its *stabilizers*, i.e. those unitary operators :math:`U` that have
:math:`\psi` as an eigenstate with eigenvalue :math:`1`.
In general, :math:`n`-qubit stabilizer states are stabilized by :math:`d = 2^n`
Pauli operators on said :math:`n` qubits.
However, it is known that the set of :math:`d` Paulis can be generated by only
:math:`n` unique members of the set.
In that case, indeed, the number of operators needed to represent a
stabilizer state reduces to :math:`n`.
Each one of these :math:`n` Pauli *generators* takes :math:`2n + 1` bits to specify,
yielding a :math:`n(2n+1)` total number of bits needed.
In particular, `Aaronson and Gottesman (2004) <aaronson_>`_ demonstrated that the application
of Clifford gates on stabilizer states can be efficiently simulated in this representation
at the cost of storing the generators of the *destabilizers*, in addition to the stabilizers.

A :math:`n`-qubit stabilizer state is uniquely defined by a symplectic matrix of the form

.. image:: ../_static/symplectic_matrix.png
:width: 2329px
:height: 1213px
:scale: 30 %
:align: center

where :math:`(x_{kl},z_{kl})` are the bits encoding the :math:`n`-qubits Pauli generator as

.. math::

P_{k} = \bigotimes_{l=1}^{n} \, i^{x_{kl} \, \oplus \, z_{kl}} \, X_{l}^{x_{kl}} \, Z_{l}^{z_{kl}}.

The :class:`qibo.quantum_info.clifford.Clifford` object is in charge of storing the
phase-space representation of a stabilizer state.
This object is automatically created after the execution of a Clifford circuit through the
:class:`qibo.backends.clifford.CliffordBackend`, but it can also be created by directly
passing a symplectic matrix to the constructor.

.. testsetup::

from qibo.quantum_info import Clifford
from qibo.backends import CliffordBackend, NumpyBackend

# construct the |00...0> state
backend = CliffordBackend(NumpyBackend())
symplectic_matrix = backend.zero_state(nqubits=3)
clifford = Clifford(symplectic_matrix, engine=NumpyBackend())

The generators of the stabilizers can be extracted with the
:meth:`qibo.quantum_info.clifford.Clifford.generators` method,
or the complete set of :math:`d = 2^{n}` stabilizers operators can be extracted through the
:meth:`qibo.quantum_info.clifford.Clifford.stabilizers` method.

.. testcode::

generators, phases = clifford.generators()
stabilizers = clifford.stabilizers()

The destabilizers can be extracted analogously with :meth:`qibo.quantum_info.clifford.Clifford.destabilizers`.

.. autoclass:: qibo.quantum_info.clifford.Clifford
:members:
:member-order: bysource


Metrics
^^^^^^^

Expand Down Expand Up @@ -1895,6 +1960,7 @@ Kraus operators as probabilistic sum of unitaries
for a limited set of operators. We leave to the user to decide how to
best use this function.


Utility Functions
^^^^^^^^^^^^^^^^^

Expand Down Expand Up @@ -2021,3 +2087,58 @@ variable.
.. autoclass:: qibo.backends.abstract.Backend
:members:
:member-order: bysource

Clifford Simulation
^^^^^^^^^^^^^^^^^^^

A special backend in qibo supports the simulation of Clifford circuits.
This :class:`qibo.backends.clifford.CliffordBackend` backend implements the phase-space formalism
introduced in `https://arxiv.org/abs/quant-ph/0406196 <aaronson_>`_ to efficiently simulate gate
application and measurements sampling in the stabilizers state representation.
The execution of a circuit through this backend creates a
:class:`qibo.quantum_info.clifford.Clifford` object that gives access to the final measured
samples through the :meth:`qibo.quantum_info.clifford.Clifford.samples` method,
similarly to :class:`qibo.result.CircuitResult`.
The probabilities and frequencies are computed starting from the samples by the
:meth:`qibo.quantum_info.clifford.Clifford.frequencies` and
:meth:`qibo.quantum_info.clifford.Clifford.probabilities` methods.

.. _aaronson: https://arxiv.org/abs/quant-ph/0406196

It is also possible to recover the standard state representation with the
:meth:`qibo.quantum_info.clifford.Clifford.state` method.
Note, however, that this process is inefficient as it involves the construction of all the
stabilizers starting from the generators encoded inside the symplectic matrix.

As for the other backends, the Clifford backend can be set with

.. testcode:: python

import qibo
qibo.set_backend("clifford", platform="numpy")

by specifying the engine used for calculation, if not provided the current :class:`qibo.backends.GlobalBackend` is used

.. testcode:: python
from qibo import set_backend
from qibo.backends import CliffordBackend

# setting numpy as the global backend
set_backend("numpy")
# the clifford backend will use the numpy backend as engine
backend = CliffordBackend()

Alternatively, a Clifford circuit can also be executed starting from the :class:`qibo.quantum_info.clifford.Clifford` object

.. code-block:: python

from qibo.quantum_info import Clifford, random_clifford

nqubits = 2
circuit = random_clifford(nqubits)
result = Clifford.from_circuit(circuit)


.. autoclass:: qibo.backends.clifford.CliffordBackend
:members:
:member-order: bysource
1 change: 1 addition & 0 deletions doc/source/code-examples/examples.rst
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ Here is an example of a circuit with 2 qubits:
# should print `tf.Tensor([1, 0, 0, 0])`
print(result.state())
# should print `np.array([1, 0, 0, 0])`

.. testoutput::
:hide:

Expand Down
10 changes: 9 additions & 1 deletion src/qibo/backends/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import os

from qibo.backends.abstract import Backend
from qibo.backends.clifford import CliffordBackend
from qibo.backends.npmatrices import NumpyMatrices
from qibo.backends.numpy import NumpyBackend
from qibo.backends.tensorflow import TensorflowBackend
Expand Down Expand Up @@ -33,6 +34,13 @@ def construct_backend(backend, platform=None, runcard=None):
from qibolab.backends import QibolabBackend # pylint: disable=E0401

return QibolabBackend(platform, runcard)
elif backend == "clifford":
if platform is not None: # pragma: no cover
if platform in ("cupy", "numba", "cuquantum"):
platform = construct_backend("qibojit", platform=platform)
else:
platform = construct_backend(platform)
return CliffordBackend(platform)

else: # pragma: no cover
raise_error(ValueError, f"Backend {backend} is not available.")
Expand Down Expand Up @@ -141,7 +149,7 @@ def set_device(device):
if device[0] != "/" or len(parts) < 2 or len(parts) > 3:
raise_error(
ValueError,
"Device name should follow the pattern: " "/{device type}:{device number}.",
"Device name should follow the pattern: /{device type}:{device number}.",
)
backend = GlobalBackend()
backend.set_device(device)
Expand Down
Loading
Loading