Skip to content

QASM instruction not parameterized for two-qubit Pauli rotation gates #7172

@epelaaez

Description

@epelaaez

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 RPPGates, 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

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions