Skip to content

qasm3 returns wrong results with pauli evolution gate #11954

@LenaPer

Description

@LenaPer

When trying to turn this circuit into a qasm3 :

from qiskit.circuit import QuantumCircuit, ParameterVector
from qiskit.circuit.library import PauliEvolutionGate
from qiskit.quantum_info import SparsePauliOp
from qiskit.qasm3 import dumps, loads, dump, load

t = ParameterVector("t", 3)
X, Y, Z = SparsePauliOp("X"), SparsePauliOp("Y"), SparsePauliOp("Z")
op1, op2, op3 = (X^X), (Y^Y), (Z^Z)
evo1 = PauliEvolutionGate(op1, time=t[0])
evo2 = PauliEvolutionGate(op2, time=t[1])
evo3 = PauliEvolutionGate(op3, time=t[2])
 
dec0 = QuantumCircuit(2)
dec0.append(evo1, range(2))
dec0.append(evo2, range(2))
dec0.append(evo3, range(2))
dec0.count_ops() #returns OrderedDict([('PauliEvolution', 3)])

after dumping into a qasm3, we would expect the qasm to have 3 different gates for the XX, YY, ZZ but it only looks into the first Pauli evolution gate and repeats it 3 times :

q0 = dumps(dec0)
print(q0)
#returns 
OPENQASM 3.0;
include "stdgates.inc";
input float[64] _t_0_;
input float[64] _t_1_;
input float[64] _t_2_;
gate rxx_4948547280(_t_0_) _gate_q_0, _gate_q_1 {
  h _gate_q_0;
  h _gate_q_1;
  cx _gate_q_0, _gate_q_1;
  rz(2.0*_t_0_) _gate_q_1;
  cx _gate_q_0, _gate_q_1;
  h _gate_q_1;
  h _gate_q_0;
}
gate PauliEvolution(_t_0_) _gate_q_0, _gate_q_1 {
  rxx_4948547280(2.0*_t_0_) _gate_q_0, _gate_q_1;
}
qubit[2] q;
PauliEvolution(_t_0_) q[0], q[1];
PauliEvolution(_t_1_) q[0], q[1];
PauliEvolution(_t_2_) q[0], q[1];

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingmod: qasm3Related to OpenQASM 3 import or export

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions