Closed marekgluza closed 3 months ago
All modified and coverable lines are covered by tests :white_check_mark:
Project coverage is 99.84%. Comparing base (
98a310a
) to head (f14ed8e
).
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
Update: Thanks @ingoroth for providing a working KAK version
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.
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
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
qiskit KAK implementation
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
Hi @ingoroth @Simone-Bordoni @Edoardo-Pedicillo
I'm starting this PR to structure the discussion about the KAK decomposition.
In the files on this branch I added a notebook by @jeongrak-son which seems to work for 2 qubit XXZ + magnetic field.
[ ] @ingoroth has a different implementation idea and @ingoroth could you push to this branch your suggestion here? We can refactor later and we could discuss in the qibo meeting on Wednesday
[ ] Once we agree which approach will give the most stability then we can rewrite this post to document the PR and eventually merge
[ ] @csookim is a new intern at CQT and @scarrazza let's discuss if a generalization to any number of qubits https://arxiv.org/abs/quant-ph/0406176 would be useful?
[ ] @renatomello do you have an opinion about adding systematic compiling into CNOTs of general unitaries?
[ ] @Simone-Bordoni pointed out that KAK should be applied here https://github.com/qiboteam/qibo/blob/98a310a41521c65589ec42a0f0c3377350c58dc4/src/qibo/transpiler/blocks.py#L99-L104
[ ] if we agree to implement such new feature we could extend the transpiler to block into $n$ qubit unitaries and then if the block has more than $O(4^n)$ unitaries then the quantum Shannon decomposition methods will compress the circuit (For example based on the scaling here https://en.wikipedia.org/wiki/Igor_L._Markov#Quantum_computing if a 3 qubit block has more than 20 CNOTs then it can be recompiled with a gain)
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$.