qiboteam / qibo

A full-stack framework for quantum computing.
https://qibo.science
Apache License 2.0
294 stars 60 forks source link

KAK decomposition #1384

Closed marekgluza closed 3 months ago

marekgluza commented 4 months ago

Hi @ingoroth @Simone-Bordoni @Edoardo-Pedicillo

I'm starting this PR to structure the discussion about the KAK decomposition.

We are interested in 2-qubit unitaries. Suppose that we ignore the global phase. Then w.l.o.g. our target unitary is a special unitary in $\mathsf{SU}(4)$. The corresponding Lie algebra is $\mathsf{su}(4)$.

We have a constand drift Hailtonian $HD = \sigma{z}\otimes\sigma_{z}$, whereas we can arbitrarily control the local Hamiltonians $HC = \sum{i=x,y,z}(a{i}(t)\sigma{i}\otimes I + bi(t)I\otimes\sigma{i})$ and coefficients $a{i}(t),b{i}(t)$ can be arbitrarily strong.

Then we naturally obtain the Cartan decomposition $$\mathsf{su}(4) = \mathfrak{k} \oplus \mathfrak{p},$$ where the subalgebra $$\mathfrak{k} = \mathrm{span}{i\sigma{j}\otimes I, iI\otimes\sigma{j} \vert j = x,y,z}, $$ and $$\mathfrak{p} = \mathrm{span}{i\sigma_{j}\otimes \sigma{k} \vert j,k = x,y,z}.$$ Note that $$[ \mathfrak{k},\mathfrak{k} ] \subseteq \mathfrak{k},\quad [ \mathfrak{k},\mathfrak{p} ] \subseteq \mathfrak{p},\quad [ \mathfrak{p},\mathfrak{p} ] \subseteq \mathfrak{k}.$$ The Lie group corresponding to the Lie algebra $\mathfrak{k}$ is $\mathcal{K} = \exp(\mathfrak{k})$.

Now we can define a Cartan subalgebra (included in $\mathfrak{p}$) w.r.t. the decomposition $$\mathfrak{a} = \mathrm{span}{i\sigma_j\otimes\sigmaj \vert j = x,y,z}.$$ Then a decomposition $$U = K{1}AK_{2},$$ where $K_1,K_2\in\mathcal{K}$ and $A \in \exp(\mathfrak{a})$ always exists. By finding the exponent of $A$, one can find the minimal time it takes to generate the target unitary $U$.

codecov[bot] commented 4 months ago

Codecov Report

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

Project coverage is 99.84%. Comparing base (98a310a) to head (f14ed8e).

Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #1384 +/- ## ======================================= Coverage 99.84% 99.84% ======================================= Files 76 76 Lines 10844 10844 ======================================= Hits 10827 10827 Misses 17 17 ``` | [Flag](https://app.codecov.io/gh/qiboteam/qibo/pull/1384/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/1384/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=qiboteam) | `99.84% <ø> (ø)` | | 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.

marekgluza commented 4 months ago

Update: Thanks @ingoroth for providing a working KAK version

https://github.com/qiboteam/qibo/blob/f14ed8e9d0418d8ce9e348175a164253bc8e85ac/examples/transpiler/KAK_decomposition.py#L224-L228

Simone-Bordoni commented 4 months ago

In my opinion we should first find the more stable and fast way to implement the 2-qubit KAK decomposition and put it in Qibo. Then we can think of how to generalize the block decomposition and the KAK to n-qubits. After we have a working KAK decomposition for two qubits it should be easy to implement a new transpiler pass to optimize circuits with blocks containing more than 3 two-qubit gates.

marekgluza commented 4 months ago

After we have a working KAK decomposition for two qubits

yep I think the one from Ingo here should work https://github.com/qiboteam/qibo/blob/f14ed8e9d0418d8ce9e348175a164253bc8e85ac/examples/transpiler/KAK_decomposition.py#L224-L228

marekgluza commented 3 months ago

We will next close this PR:

Thanks Changsoo, please close after posting the links to other existing implementations

We can pick it up in the future if need arises

csookim commented 3 months ago

qiskit KAK implementation

https://github.com/Qiskit/qiskit/blob/3e7f8b8018d90c94c84d31bb8db68d53f3a1afe0/qiskit/synthesis/two_qubit/two_qubit_decompose.py

cirq KAK implementation

https://github.com/quantumlib/Cirq/blob/v1.4.1/cirq-core/cirq/linalg/decompositions.py#L812-L881 https://github.com/quantumlib/Cirq/blob/v1.4.1/cirq-core/cirq/linalg/diagonalize.py