-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
Information
- Qiskit Terra version: 0.19.0.dev0+0ee0824
- Python version: 3.9.6
- Operating system: Windows 11
What is the current behavior?
The following snippet
from qiskit import QuantumCircuit
from qiskit.circuit.library.standard_gates import RZXGate
import numpy as np
qc = QuantumCircuit(2)
qc.append(RZXGate(np.pi), [0, 1])
qc.append(RZXGate(np.pi / 2), [0, 1])
qc.qasm()
Produces
OPENQASM 2.0;
include "qelib1.inc";
gate rzx(param0) q0,q1 { h q1; cx q0,q1; rz(pi) q1; cx q0,q1; h q1; }
gate rzx_1491288775456(param0) q0,q1 { h q1; cx q0,q1; rz(pi/2) q1; cx q0,q1; h q1; }
qreg q[2];
rzx(pi) q[0],q[1];
rzx_1491288775456(pi/2) q[0],q[1];
As you can see, instead of creating a single rzx
instruction that uses param0
, it creates a single rzx
for each value present in the circuit.
Steps to reproduce the problem
This happens with at least all other RPPGate
s, where PP
is placeholder for some Pauli matrices. I haven't tested it with other parameterized gates.
What is the expected behavior?
I think the output QASM string should look like:
OPENQASM 2.0;
include "qelib1.inc";
gate rzx(param0) q0,q1 { h q1; cx q0,q1; rz(param0) q1; cx q0,q1; h q1; }
qreg q[2];
rzx(pi) q[0],q[1];
rzx(pi/2) q[0],q[1];
I tested it and using that string to build a QuantumCircuit
gives the intended circuit.
string = """OPENQASM 2.0;
include "qelib1.inc";
gate rzx(param0) q0,q1 { h q1; cx q0,q1; rz(param0) q1; cx q0,q1; h q1; }
qreg q[2];
rzx(pi) q[0],q[1];
rzx(pi/2) q[0],q[1];"""
qc = QuantumCircuit.from_qasm_str(string)
qc.decompose().draw()
Output:
q_0: ───────■─────────────■──────────────■───────────────■───────
┌───┐┌─┴─┐┌───────┐┌─┴─┐┌───┐┌───┐┌─┴─┐┌─────────┐┌─┴─┐┌───┐
q_1: ┤ H ├┤ X ├┤ Rz(π) ├┤ X ├┤ H ├┤ H ├┤ X ├┤ Rz(π/2) ├┤ X ├┤ H ├
└───┘└───┘└───────┘└───┘└───┘└───┘└───┘└─────────┘└───┘└───┘
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working