-
Notifications
You must be signed in to change notification settings - Fork 49
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
ECR gate not properly supported in QASM export #506
Comments
Thanks for the suggestion. I can imagine use cases that require the QASM generation to be more flexible. Perhaps we can add a flag to disable checking whether the gates are in the specified header lib. Any thoughts @cqc-alec ? |
I'm not sure. Is what qiskit produces valid qasm? (It doesn't seem to include any extra headers.) We want the output of the converter to be readable by general qasm parsers. |
Qiskit provides custom gate definitions just as in the example above for any gate that is not in
currently produces OPENQASM 2.0;
include "qelib1.inc";
gate rzx(param0) q0,q1 { h q1; cx q0,q1; rz(-pi/4) q1; cx q0,q1; h q1; }
gate rzx(param0) q0,q1 { h q1; cx q0,q1; rz(pi/4) q1; cx q0,q1; h q1; }
gate ecr q0,q1 { rzx(pi/4) q0,q1; x q0; rzx(-pi/4) q0,q1; }
qreg q[2];
ecr q[0],q[1]; Note that the Qiskit output isn't correct at the moment (it contains a duplicate definition of the The proper output that qiskit would strive for is the one shown in the first post, i.e., OPENQASM 2.0;
include "qelib1.inc";
gate rzx(param0) q0,q1 { h q1; cx q0,q1; rz(param0) q1; cx q0,q1; h q1; }
gate ecr q0,q1 { rzx(pi/4) q0,q1; x q0; rzx(-pi/4) q0,q1; }
qreg q[2];
ecr q[0],q[1]; |
Ah I see, so the suggestion is to add gate definitions to the generated qasm. Yes that sounds like it would be useful! |
Hello @burgholzer, with pull request #612 our qasm generating methods will now auto generate gate definitions for any |
Awesome! Many thanks. I'll surely check this out soon 👍🏻 |
The following simple code snippet
Unexpectedly (to me) raises an exception
While it is, of course, true that the
ecr
gate is not part of the standardqelib1.inc
, I would have expectedtket
to provide a corresponding QASM gate definition. Specifically, I would have expected the above script to produce something likesimilar to how
qiskit
itself dumps such circuits.pytket version: 1.5.2
os: Ubuntu 22.04
python version: 3.10.6
The text was updated successfully, but these errors were encountered: