softwareQinc / staq

Full-stack quantum processing toolkit
https://iopscience.iop.org/article/10.1088/2058-9565/ab9359/pdf
MIT License
154 stars 28 forks source link

Mapping issues continued: non-trivial circuits #27

Closed DevelopDaily closed 4 years ago

DevelopDaily commented 4 years ago

I attach a non-trivial circuit (grover.qasm) to illustrate another problem.

grover.zip

It is a simple 3-qubit Grover's algorithm that renders a final state with the winner 6, as shown here:

>> Final state:
0.0794641 + 0.0386956i
0.0794675 + 0.0386923i
 0.0794644 + 0.038689i
0.0794666 + 0.0386924i
0.0794661 + 0.0386921i
0.0794668 + 0.0386947i
 -0.874177 - 0.425596i
 0.0794668 + 0.038692i

As you can see, the 6 with a probability 95% stands out. That is perfect.

Now, run this:

./staq -S -m -O1 -d square -M steiner -l bestfit -f qasm -o grover_staq.qasm grover.qasm

The grover_staq.qasm produces a final state like this:

>> Final state:
 -0.0632695 + 0.318087i
-0.0844088 + 0.0778586i
  -0.118019 - 0.185286i
  -0.470594 - 0.208363i
  -0.259683 + 0.105562i
 -0.0452083 + 0.179949i
  -0.232798 - 0.294897i
  0.560054 - 0.0259715i

That is wrong because no clear winner stands out.

meamy commented 4 years ago

That's interesting. It looks like the error originates in the mapping phase. It seems to happen even with the fully connected architecture which leads me to believe it's an issue with the translation from rz and ry to the native U gates. I'm away for a few days but I'll try to further pinpoint this and fix it ASAP.

meamy commented 4 years ago

It turns out this problem was with the openQASM parser in Quantum++. It's fixed in the master branch now.