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

Improvements on top of the Clifford Simulator #1128

Open
6 tasks done
BrunoLiegiBastonLiegi opened this issue Dec 8, 2023 · 5 comments
Open
6 tasks done

Improvements on top of the Clifford Simulator #1128

BrunoLiegiBastonLiegi opened this issue Dec 8, 2023 · 5 comments
Assignees
Labels
documentation Improvements or additions to documentation enhancement New feature or request quantum_info module PRs and issues related to the quantum information module

Comments

@BrunoLiegiBastonLiegi
Copy link
Contributor

BrunoLiegiBastonLiegi commented Dec 8, 2023

#1076 is introducing in qibo a way for simulating clifford circuits efficiently, several improvements can still be introduced on top of that though:

  • Currently the CliffordBackend is backend agnostic, in the sense that any one of the backend available in qibo and qibojit right now (except for the TensorflowBackend) can be used as engines for performing the computation happening under the hood of the CliffordBackend. In practice, though, the only difference is whether numpy or cupy primitives are used. Therefore, there's no difference between using, for example, the NumbaBackend or NumpyBackend 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.
  • Add support for clifford noise channels through repeated execution, as it works for collapsing measurements already.
  • Come up with a way for representing ensembles of states in the phase space which is what you get when collapsing measurement or noise channels are present in the circuit. This https://arxiv.org/abs/2002.06181 might provide some ideas.
  • Currently the action of a clifford gate in the phase space is represented by a series of row or column wise operations on the symplectic matrix, like for example swapping rows or summing columns. It would be more flexible to have a matrix multiplication representation for each operation.
  • As per suggestion of @AlejandroSopena and @alecandido, it might be a good idea to integrate stim as a separate alternative clifford backend.
  • The clifford gates + the T gate form a universal basis for computation, several methods exist for simulating circuits decomposed in this basis with a cost that grows exponentially only in the number of T gates present. An additional hybrid clifford backend could be implemented following this idea.
  • Python native ints appear to be faster than numpy arrays of bools with boolean algebra. Namely, the operation 5 ^ 3 is faster than np.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.
  • (@alecandido) It would really be nice to have a syntax for gates composition in order to avoid the repetition of patterns, to make it something like:
    theta_switch(
        theta,
        I,
        X | CY | X | CNOT,
        CZ | X | CZ | X,
        CNOT | X | CY | X,
        symplectic_matrix, control_q, target_q, nqubits
    )

with theta_switch a function applying the repeated pattern (and I chose | at random, any operator would be fine).

  • (@alecandido) Verify whether it is better to use the prange function for explicit parallelization with numba or let numba take care of the parallelization automatically.
  • (@alecandido) Try to use np.packbits to pack the columns of the matrix before execution and unpack them at the end.
  • Parallelize the measurements on different qubits.

EXTRA:

c = tableau.to_circuit(state)
c.append("M", range(qubits))
s = c.compiler_sampler()

@renatomello did I forget anything?

Tasks

Preview Give feedback
  1. documentation enhancement
    renatomello
  2. enhancement quantum_info module
    BrunoLiegiBastonLiegi
  3. enhancement
    BrunoLiegiBastonLiegi
  4. documentation enhancement quantum_info module
    BrunoLiegiBastonLiegi
  5. enhancement quantum_info module
    BrunoLiegiBastonLiegi
  6. dependencies documentation quantum_info module
    renatomello
@BrunoLiegiBastonLiegi BrunoLiegiBastonLiegi added the enhancement New feature or request label Dec 8, 2023
@renatomello
Copy link
Contributor

@renatomello did I forget anything?

The Clifford.to_circuit method, but there is already a #TODO annotation in the code for it

@renatomello
Copy link
Contributor

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.

@renatomello
Copy link
Contributor

@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.

@scarrazza scarrazza added this to the Qibo 0.2.5 milestone Jan 9, 2024
@andrea-pasquale
Copy link
Contributor

@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.

@renatomello renatomello added the quantum_info module PRs and issues related to the quantum information module label Jan 27, 2024
@MatteoRobbiati MatteoRobbiati modified the milestones: Qibo 0.2.5, Qibo 0.2.6 Feb 28, 2024
@renatomello
Copy link
Contributor

renatomello commented Mar 5, 2024

@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

@renatomello renatomello added the documentation Improvements or additions to documentation label Mar 5, 2024
@scarrazza scarrazza modified the milestones: Qibo 0.2.6, Qibo 0.2.7 Mar 13, 2024
@scarrazza scarrazza modified the milestones: Qibo 0.2.7, Qibo 0.2.8 Apr 5, 2024
@scarrazza scarrazza modified the milestones: Qibo 0.2.8, Qibo 0.2.9 May 23, 2024
@scarrazza scarrazza modified the milestones: Qibo 0.2.9, Qibo 0.2.10 Jun 25, 2024
@scarrazza scarrazza removed this from the Qibo 0.2.10 milestone Jul 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation enhancement New feature or request quantum_info module PRs and issues related to the quantum information module
Projects
None yet
Development

No branches or pull requests

6 participants