softwareQinc / staq

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

Swap mapping issues: final states of 7 qubits #28

Closed DevelopDaily closed 4 years ago

DevelopDaily commented 4 years ago

Thanks for the previous qppfix. The Grover's algorithm circuit works fine now, for all the physical devices, and for both swapand steiner.

Here is a test case to reveal another possible bug.

128_2_1.zip

It produces a final periodic state like this:

>> Final state:
    0 
0.125 
    0 
0.125 
.
.
.
    0 
0.125 

Now, run this:

./staq -S -m -O1 -d square -M swap -l bestfit -f qasm -o 128_2_1_staq.qasm 128_2_1.qasm

The 128_2_1_staq.qasm produces a final (virtual) state like this: 64zeros followed by 64values of 0.125. The interpretation is based on // Output layout (physical --> virtual) info.

>> Final state:
    0 
.
.
.
    0 
0.125 
.
.
.
0.125 

That is wrong. By the way, it works perfectly if the steineris used.

The problem seems to happen when the number of qubits increases. For example, here is a similar test case with fewer qubits. The swapworks as expected.

32_2_1.zip

meamy commented 4 years ago

Thanks for the report! Sorry it's taken awhile to get to.

I just tried it and got the same result as you. I think what's really happening is that q[2] is mapped to the original circuit's qs[6]. The only way I can make sense of this so far is if there's a second level of indirection going on somewhere, since there's q[2] --> qs[0] and q[0] --> qs[6]. I'll review the code again and try to untangle these permutations.

meamy commented 4 years ago

Found the problem, it's fixed now. I also removed the initial layout information by default as it's maybe more confusing than it is useful.

Thanks!