1
$\begingroup$

Is there a way to know what does it does qiskit in the step Optimize1qGatesDecomposition?

What I can see is that each time qiskit wants to represent a rotation in SU(2) like $U(\theta,\alpha,\gamma)$, in order to write it in terms of $R_z$ and $\sqrt{X}$ gates, it writes $$ R_z(\alpha)\sqrt{X} R(\theta+\pi)\sqrt{X} R_z(\gamma). $$

However, when one has two such matrix multiplications

$$ R_z(\alpha_1)\sqrt{X} R(\theta_1)\sqrt{X} R_z(\gamma_!) \times R_z(\alpha_2)\sqrt{X} R(\theta_2)\sqrt{X} R_z(\gamma_2) $$

the optimization step ends up with a matrix like

$$ R_z(\alpha_3)\sqrt{X} R(x)\sqrt{X} R_z(\gamma_4), $$

where the angle $x$ is not necessarily the sum of the previous $\theta_i$'s (sometimes is not even $\theta_1 + \theta_2 + \pi$).

$\endgroup$

1 Answer 1

0
$\begingroup$

The transpiler pass Optimize1qGatesDecomposition searches for sequences of single-qubit gates, then for each sequence:

  • Gets the matrix representation of each gate and combines them into one matrix using matrix multiplication.
  • Resynthesizes the result matrix using OneQubitEulerDecomposer into the proper basis.
  • Replaces the original sequence with the resynthesized one.

The synthesize basis is selected based on the basis argument if exists. Otherwise, the target basis is used. In your case the basis ZSXX is used. So, the matrix

\begin{align}\begin{aligned}\newcommand{\th}{\frac{\theta}{2}}\\\begin{split} \begin{pmatrix} \cos\left(\th\right) & -e^{i\lambda}\sin\left(\th\right) \\ e^{i\phi}\sin\left(\th\right) & e^{i(\phi+\lambda)}\cos\left(\th\right) \end{pmatrix}\end{split}\end{aligned}\end{align} is synthesized into $$e^{i\gamma} R_Z(\phi+\pi).\sqrt{X}.R_Z(\theta+\pi).\sqrt{X}.R_Z(\lambda)$$

where $\gamma$ is a phase parameter.


Note: You can access the source code of Optimize1qGatesDecomposition from here.

$\endgroup$
3
  • $\begingroup$ Try out the product of two such matrices that you say. I'm finding that it is a numerical argument in most of the cases... $\endgroup$ Sep 15 at 15:05
  • $\begingroup$ The problem is in the product of two general SU(2) matrices, that is decomposed as $R_z(\alpha)\sqrt{X}R_z(\beta)\sqrt{X}R_z(\gamma)$, might not have the same determinant as the factors that multiply it. For instance, the decomposition you wrote is an SU(2) (I believe), while the product of two SU(2)'s is written, in general, as an U(2) matrix (c.f. my previous expression in this answer...). $\endgroup$ Sep 15 at 15:10
  • $\begingroup$ This why we have a phase parameter $\gamma$ in the synthesized circuit. You can check that the value of circuit.global_phase is different after calling Optimize1qGatesDecomposition than before. $\endgroup$ Sep 15 at 16:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.