qiboteam / qibo

A framework for quantum computing
https://qibo.science
Apache License 2.0
287 stars 58 forks source link

Adjusting Clifford condition in `gates.GPI2` #1399

Closed MatteoRobbiati closed 2 months ago

MatteoRobbiati commented 2 months ago

Checklist:

codecov[bot] commented 2 months ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 99.99%. Comparing base (d8cc501) to head (8513ff0).

Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #1399 +/- ## ======================================= Coverage 99.99% 99.99% ======================================= Files 78 78 Lines 11192 11195 +3 ======================================= + Hits 11191 11194 +3 Misses 1 1 ``` | [Flag](https://app.codecov.io/gh/qiboteam/qibo/pull/1399/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=qiboteam) | Coverage Δ | | |---|---|---| | [unittests](https://app.codecov.io/gh/qiboteam/qibo/pull/1399/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=qiboteam) | `99.99% <100.00%> (ø)` | | Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=qiboteam#carryforward-flags-in-the-pull-request-comment) to find out more.

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

AlejandroSopena commented 2 months ago

Yes, it is because $GPI2(0)=\sigma_x$, $GPI2(\pi/2)=\sigma_y$, $GPI2(\pi)=-\sigma_x$ and $GPI2(3\pi/2)=-\sigma_y$, where $\sigma_j$ are the Pauli matrices.

renatomello commented 2 months ago

Yes, it is because GPI2(0)=σx, GPI2(π/2)=σy, GPI2(π)=−σx and GPI2(3π/2)=−σy, where σj are the Pauli matrices.

I don't see it from the $GPI2$ matrix representation.

AlejandroSopena commented 2 months ago

Sorry, you are right. This happens for the GPI gate but not for GPI2.
It can be checked that it is a Clifford with the following code:

paulis = [gates.X(0).matrix(), gates.Y(0).matrix(), gates.Z(0).matrix()]
for p in paulis:
    for t in [0, np.pi/2, np.pi, 3*np.pi/2, 2*np.pi]:
        gate = gates.GPI2(0, t).matrix()
        gate1 = gate@p@gate.transpose().conj()
        print(gate1)
alecandido commented 2 months ago

That's an error: GPI2 is always a rotation by $\pi/2$, not $\pi$. So, they are square roots of Pauli's.

E.g., cf. https://ionq.com/docs/getting-started-with-native-gates#gpi2

AlejandroSopena commented 2 months ago

In the previous code I was printing gate instead of gate1. Now it can be seen that it maps paulis to paulis up to phases.

alecandido commented 2 months ago

@AlejandroSopena of course, my comment was referred not to the one directly above, but to the previous one, i.e. https://github.com/qiboteam/qibo/pull/1399#issuecomment-2255730701