-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
QASM output for multiple R gates #11017
Comments
This is in principle a duplicate of #5082, which requires a larger rework of our data model to handle (which we are working on, I promise! - it's just a very very big change), but the reason you only see this after a re-import from the OQ2 string is because Qiskit can't know for certain that it's safe for it to use its built-in We're currently reworking how we'll define header files for OpenQASM 2, which will make this easier, but in the meantime, a direct workaround is to replace the legacy from qiskit import qasm2
from qiskit.circuit.library import RGate
prog = """
OPENQASM 2.0;
include "qelib1.inc";
gate r(param0,param1) q0 { u3(param0,param1 - pi/2,pi/2 - 1.0*param1) q0; }
qreg q[2];
r(0.1,0.1) q[0];
r(0.5,0.5) q[1];
"""
custom_instructions = list(qasm2.LEGACY_CUSTOM_INSTRUCTIONS)
custom_instructions.append(qasm2.CustomInstruction("r", 2, 1, RGate))
qc = qasm2.loads(prog, custom_instructions=custom_instructions)
print(qasm2.dumps(qc)) I think you'll get what you expect. edit: just modified the code block - I'd flipped the arguments in |
The gist of #10737 (linked above) is that we're going to start exposing new header files called things like |
Thanks @jakelishman for the detailed response! I close this issue, since it is a duplicate of #5082. |
Environment
What is happening?
I create a
QuantumCircuit
from aqasm
string that contains multipleR
gates. E.g.:Generating the
qasm
string from the previously generatedQuantumCircuit
does result in theR
gates being defined multiple times:How can we reproduce the issue?
The text was updated successfully, but these errors were encountered: