5

Following @DaftWullie's answer I tried to simulate the circuit given in Fig. 4 of the paper (arXiv pre-print): Quantum circuit design for solving linear systems of equations (Cao et al, 2012), on Quirk.


The relevant circuit in the arXiv pre-print by Cao et al is:

enter image description here

Please note that (I think) the $e^{-iAt_0/2^s}$ (s.t. $1\leq s \leq 4$) gates in the circuit should actually be $e^{+iAt_0/2^s}$ gates instead. That's probably a misprint in the paper.


You will find the equivalent Quirk simulated circuit here. The labellings of the gates (along with the matrix entries) can be seen from the dashboard by hovering over them. The matrix entries may also be obtained from the JSON code in the URL. You might want to use a JSON formatter for that purpose.

The rotation gates used in the paper are $R(8\pi/2^{r-1}),R(4\pi/2^{r-1}),R(2\pi/2^{r-1}),R(\pi/2^{r-1})$. On page 4 they mentioned that higher the value of $r$ they greater is the accuracy. So I took $r=7$.

I created the custom gates $R_y(8\pi/2^{r-1})$, $R_y(4\pi/2^{r-1})$, $R_y(2\pi/2^{r-1})$ & $R_y(\pi/2^{r-1})$, using the definition of the $R_y$ matrices as:

$$R_y(\theta) = \left(\begin{matrix}\cos(\theta/2) & \sin(\theta/2) \\ -\sin(\theta/2) & \cos(\theta/2) \end{matrix}\right)$$

Now, the output state of the "input register" should have been

$$\frac{-|00\rangle + 7|01\rangle + 11|10\rangle + 13|11\rangle}{\sqrt{340}}$$ i.e. $$-0.0542326|00\rangle + 0.379628|01\rangle + 0.596559|10\rangle + 0.705024|11\rangle$$

However, I'm getting the output state of the input register as

$$-(-0.05220|00\rangle+0.37913|01\rangle+0.59635|10\rangle+0.70562|11\rangle)$$

That is, there's a extraneous global phase of $-1$ in the final output. I'm not sure whether I have made a mistake in the implementation of the circuit OR whether the output of the circuit actually supposed to be accompanied with the global phase.

@DaftWullie mentions:

If it's a global phase, what does it matter? Everything is always "up to a global phase"

That sure is logical! However, I want to be sure that I'm not making any silly error in the implementation itself. I wonder that if there's actually supposed to be a global phase of $-1$, why they didn't explicitly mention it in the paper? I find that a bit surprising. (Indeed, yes, I should perhaps directly contact the authors, but maybe someone here might be able to spot the silly mistake (on my part) quicker! :)

In case you have any questions about my simulation, please feel free to ask in the comments. I'll be happy to clarify.

Sanchayan Dutta
  • 17,497
  • 7
  • 48
  • 110
  • 1
    I’d start by trying a couple of different things. First, different values of r. Perhaps r=5? Then i’d Start properly debugging. Things like giving the input state as an eigenvector and checking what the output is from the Fourier Transform, before the computation of the inverse, and confirm that it is what you think. Equally, if you have to ask about the ON state, why not just try it? Make a $|1\rangle$ and measure it! – DaftWullie Jul 15 '18 at 05:23
  • Thinking about it, the circuit should be more accurate for larger r, so set it big! I’m also not sure about the QFT step. I think the QFT and it’s inverse should be swapped. – DaftWullie Jul 15 '18 at 05:31
  • That’s a good point. Your original circuit just has b=00. One of my suggestions was to try changing b... – DaftWullie Jul 16 '18 at 05:03
  • @DaftWullie Geting the exact output as claimed in the paper now: https://goo.gl/v4JbRw. I noticed that if we use $e^{+iAt}$ in the QPE step we must necessarily use the inverse QFT gate. However, strangely the final result seems to have an overall factor of $-1$. I used a "Sign Flip" gate at the end to correct this but not sure from where the extraneous $-1$ is appearing in the global phase. Any idea? – Sanchayan Dutta Jul 16 '18 at 13:13
  • If it's a global phase, what does it matter? Everything is always "up to a global phase" – DaftWullie Jul 16 '18 at 14:12
  • What conclusion did you come to about the swap gates? – DaftWullie Jul 19 '18 at 05:13
  • @DaftWullie Nothing yet. In the Quirk simulation, no SWAP gate was needed and logically shouldn't be needed as you had mentioned. However, I still couldn't find the bug in Nelimee's code. It still requires a SWAP and un-SWAP to work (line 149 and 164). – Sanchayan Dutta Jul 19 '18 at 15:53
  • Note: Quirk does include a "sign flip" gate. It calls it the "Ne-Gate"; it's in the "silly" section. In general you shouldn't worry too much about global phase. It could be as simple as e.g. rotating by 90 degrees instead of -270 degrees somewhere (which ends up causing a minus sign to appear due to how SU2 double-covers SO3). – Craig Gidney Aug 03 '18 at 07:54
  • @SanchayanDutta, Can you please tell me that how did you create $e^{iAt/16}$ gate in quirk – Omkar Apr 02 '20 at 18:19
  • @Omkar I basically computed the matrix exponential using an online software and plugged the parameters in the custom gate creation feature in Quirk. – Sanchayan Dutta Apr 03 '20 at 21:09
  • @DaftWullie "If it's a global phase, what does it matter?" It matters e.g. when it comes to time optimal implementations of unitary gates, see here, chap. IIIA – draks ... Apr 27 '20 at 11:09

0 Answers0