Main Challenge:
An arbitrary two-qubit gate must be decomposed into some single-qubit gates and CNOT gates to be executed on a quantum computer. Write a program to implement the two-qubit gate decomposition.
Input:
An arbitrary two-qubit gate (an arbitrary 4X4 unitary matrix).
Output:
A sequence of single-qubit gates and CNOT gates.
Example:
- Input: a two-qubit Control-Z (CZ) gate on two qubits q1 and q2
- Output: Hadamard gate (H) on q2, CNOT on q1 q2, Hadamard gate (H) on q2
-
test_gate_decomp(N)
: Test the decomposition, N specifies the number of generated test cases. -
gate_decomp(U)
: Return the decomposition of an arbitrary 2-qubit gate$U$ .
Kraus and Cirac proposed a decomposition method [1] based on the isomorphism between
In my implementation, I referred to KAK1 decomposition described in [2] and [3]. The method in [3] is not correct for the implementation of gsvd() in Matlab. I also leveraged the generalized SVD function gsvd() to simplify the code. However, the Matlab implementation didn't guarantee that
I implemented the decomposition using element rearrangement and SVD. After reordering the elements, the new matrix can be rank-1. Then SVD will solve the two vectors corresponding to the biggest eigenvalue, which can be reordered into two 2*2 unitary matrices. This is a common method used in computer vision and other fields known as Nearest Kronecker Problem [4].
I implemented the optimal decomposition of
Then we just need to combine the single-qubit gates and the overall decomposition can be described as follows.
function [R_a1, R_b1, R_a2, R_b2, R_b3, R_a4, R_b4] = gate_decomp(U)
% This function gives the decompostion of arbitrary 2-qubit gate.
% Final decompostion result:
% ===== ====== ======= ====== ====== ======= ======
% -| |- --|R_a1|--| |--|R_a2|--| |----------| |--|R_a4|--
% | U | => ====== |CNOT2| ====== |CNOT| ====== |CNOT2| ======
% -| |- --|R_b1|--| |--|R_b2|--| |--|R_b3|--| |--|R_b4|--
% ===== ====== ======= ====== ====== ====== ======= ======
%
[1] Optimal Creation of Entanglement Using a Two--Qubit Gate, https://arxiv.org/abs/quant-ph/0011050.
[2] An Introduction to Cartan's KAK Decomposition for QC Programmers, https://arxiv.org/abs/quant-ph/0507171.
[3] Universal quantum circuit for n-qubit quantum gate: A programmable quantum gate, https://arxiv.org/abs/quant-ph/0602174.
[4] Kronecker Decomposition for Image Classification, https://www.imageclef.org/system/files/CLEF2016_Kronecker_Decomposition.pdf.
[5] Optimal Quantum Circuits for General Two-Qubit Gates, https://arxiv.org/abs/quant-ph/0308006.