QuTech-Delft / OpenQL

OpenQL: A Portable Quantum Programming Framework for Quantum Accelerators. https://dl.acm.org/doi/10.1145/3474222
https://openql.readthedocs.io
Other
99 stars 44 forks source link

Bug Report: unitary decomposition fails to preserve phases #386

Open DevelopDaily opened 3 years ago

DevelopDaily commented 3 years ago

Here is a simple unitary matrix:

(0.707107,0)    (0,0)        (0.707107,0)     (0,0) 
(0,0)           (0.5,0.5)    (0,0)            (0.5,0.5) 
(0.707107,0)    (0,0)        (-0.707107,0)    (0,0) 
(0,0)           (0.5,0.5)    (0,0)            (-0.5,-0.5) 

Apply the matrix to |0>, and you will get (0.707107, 0, 0.707107, 0)^T.

Apply the gates generated by the unitary class to the same state |0>, you will not get the same result.

jvanstraten commented 3 years ago

QX gives me

  [p = +0.4999980]  (+0.6532819,-0.2705933) |00> +
  [p = +0.5000020]  (+0.6532845,-0.2705944) |10> +

when applying the sequence of gates produced by decomposition on 29fc44d (which is surely equivalent to the current develop branch in terms of unitary decomposition) to |00>. I'm not really a quantum guy, but to me that looks like it differs only in global phase to what you got, which cannot be observed by measurement or manipulated by gates (and depends on how you define the rz/ry gates). So this doesn't look like a bug to me.

DevelopDaily commented 3 years ago

Your statement is partially correct. In a lot of applications, the global phase can be indeed ignored for the reason as you stated.

But, for one of the most important quantum algorithms - Quantum Phase Estimation, the whole thing is about the phase. The current implementation of the unitary decomposition in the OpenQL is unable to support any quantum phase estimation applications.