Open BrunoLiegiBastonLiegi opened 7 months ago
@renatomello did I forget anything?
The Clifford.to_circuit
method, but there is already a #TODO annotation in the code for it
One thing I forgot to mention is that we need a way to enumerate the Cliffords for a given number of qubits. Maybe a conversion from one integer to a symplectic matrix. This is important for quantum_info.random_clifford
because it is necessary for randomized benchmarking protocols in qibocal
.
@BrunoLiegiBastonLiegi we should also add a few extra methods to the Clifford class, e.g. a compose
that composes two Clifford objects, an unitary
method like the one in the Circuit class, etc. And I insist we should still have a similar method to the add
method of the Circuit class.
@BrunoLiegiBastonLiegi For possible improvements related to the CuQuantum
backend you might want to check their documentation to see if there some primitives that you can exploit in your implementation of the clifford backend.
@scarrazza @BrunoLiegiBastonLiegi @alecandido @AlejandroSopena just to add to the already aforementioned issue(s): PennyLane added a new Clifford simulator with stim
as engine https://github.com/PennyLaneAI/pennylane/releases/tag/v0.35.0
1076 is introducing in qibo a way for simulating clifford circuits efficiently, several improvements can still be introduced on top of that though:
CliffordBackend
is backend agnostic, in the sense that any one of the backend available in qibo and qibojit right now (except for theTensorflowBackend
) can be used as engines for performing the computation happening under the hood of theCliffordBackend
. In practice, though, the only difference is whether numpy or cupy primitives are used. Therefore, there's no difference between using, for example, theNumbaBackend
orNumpyBackend
as engine right now. Numba parallelization can be implemented using the@njit(parallel=True)
decorator with the clifford operations that define how gates act in the phase space. Similarly custom cuda kernels can be implemented in cupy using the@jit.rawkernel()
decorator on the clifford operations.5 ^ 3
is faster thannp.array([True, False, True]) ^ np.array([False, True, True])
. Therefore, a substantial speed up might be obtained by rethinking the symplectic matrix in terms of the integers encoded by its rows and columns, however, this would require to rewrite also all the clifford gates in the new representation.with
theta_switch
a function applying the repeated pattern (and I chose|
at random, any operator would be fine).prange
function for explicit parallelization withnumba
or letnumba
take care of the parallelization automatically.np.packbits
to pack the columns of the matrix before execution and unpack them at the end.EXTRA:
Clifford.to_circuit
methodStimBackend
usestim
also for sampling measurements and not only for simulating the tableu. An easy trick would be to convert the tableu to a circuit and then sample from it@renatomello did I forget anything?