Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The final states of the output from staq mismatch those of the input #43

Closed
DevelopDaily opened this issue Dec 14, 2021 · 6 comments
Closed

Comments

@DevelopDaily
Copy link

I just notice your update on the #34 and thank you for the effort.

But, it still does not produce the correct results.

I attach an input.qasm and you can do this to produce two output files.

./staq -S -O2 -o out2.qasm input.qasm
./staq -S -O3 -o out3.qasm input.qasm

Then, you can run each of the input.qasm, out2.qasm, out3.qasm with qpp example program qpp_qasm.

The final states from executing the three files are different from each other. The phases are different.

I tried both qpp and staq without USE_QISKIT_SPECS. The problem exists.

Then, I tried both qpp and staq with USE_QISKIT_SPECS. The problem still exists.

input.zip

@vsoftco
Copy link
Member

vsoftco commented Dec 14, 2021

@DevelopDaily Thanks! Will take a look and fix asap. btw, do you have any "minimal" (shorter) example that reproduces the issue?

@DevelopDaily
Copy link
Author

Here is the minimal version:

OPENQASM 2.0;
include "qelib1.inc";
gate ccc ctrl, ctrl_1, ctrl_2, q0, q1, q2
{
    crz(((pi/2)/2)+(pi/2)) ctrl, q0;
}

qreg q[3];
qreg ctrl_0[1];
qreg ctrl_1[1];
qreg ctrl_2[1];

x ctrl_0[0];

ccc ctrl_0[0], ctrl_1[0], ctrl_2[0], q[0], q[1], q[2];

@525125
Copy link
Contributor

525125 commented Dec 15, 2021

This should be fixed as of c56c958 and softwareQinc/qpp@470e386, both with and without USE_QISKIT_SPECS.

The issue was a difference between qelib1.inc's crz definition and the corresponding matrix in qpp's lookup table.

@525125
Copy link
Contributor

525125 commented Dec 15, 2021

FYI: We've now changed the option to USE_OPENQASM2_SPECS, and it is OFF by default.

@DevelopDaily
Copy link
Author

Great. Thanks. Working like a charm now.

May I suggest you review these two sample qelib1.inc files too? Are they consistent with what you fixed today? Sometimes, people may want to add more gates to the files to do testing or something. If they reference them, they may get confused.

https://github.com/softwareQinc/qpp/blob/main/qasmtools/qasm/generic/qelib1.inc
https://github.com/softwareQinc/staq/blob/main/qasmtools/qasm/generic/qelib1.inc

@525125
Copy link
Contributor

525125 commented Dec 16, 2021

We have two versions of qelib1.inc (see https://github.com/softwareQinc/staq/blob/main/qasmtools/include/qasmtools/parser/preprocessor.hpp).

One is for USE_OPENQASM2_SPECS=ON, which is the same as the official OpenQASM 2 standard library, and is the same as the two linked files. The other is for USE_OPENQASM2_SPECS=OFF, which is the one that was changed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants