Skip to content

Incorrect unitary of controlled QasmUGate? #5959

@ArfatSalman

Description

@ArfatSalman

Description of the issue
It seems like the unitary of controlled QasmUGate is not correct with qiskit's CU3Gate.

How to reproduce the issue

import cirq
from cirq.circuits.qasm_output import QasmUGate
import numpy as np

cu3 = QasmUGate(
    0.9284573101905567 / np.pi, 
    0.45091656513571715 / np.pi, 
    3.783886899929776 / np.pi).controlled(num_controls=1)

qr_cirq = [cirq.NamedQubit('q' + str(i)) for i in range(2)]
circuit = cirq.Circuit(
    cu3(qr_cirq[1], qr_cirq[0])
)

cirq_unitary = cirq.unitary(circuit)


import qiskit
from qiskit import QuantumCircuit, ClassicalRegister, QuantumRegister
from qiskit.circuit.library.standard_gates import CU3Gate

qr = QuantumRegister(2, name='qr')
cr = ClassicalRegister(2, name='cr')
qc = QuantumCircuit(qr, cr, name='qc')

qc.append(CU3Gate(0.9284573101905567,0.45091656513571715,3.783886899929776), qargs=[qr[1], qr[0]], cargs=[])

from qiskit import Aer, transpile, execute
backend = Aer.get_backend('unitary_simulator')
qiskit_unitary = execute(qc, backend).result().get_unitary(qc)

print(cirq.equal_up_to_global_phase(qiskit_unitary, cirq_unitary)) 
# False

As per the docs,
Screenshot 2022-12-11 at 19 38 53

U3Gate corresponds to QasmUGate with half turns. So I am expecting the controlled version to correspond to CU3Gate. However, the unitaries are different for some reason.

Cirq version
1.0.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/gatesarea/qasmkind/bug-reportSomething doesn't seem to work.triage/acceptedA consensus emerged that this bug report, feature request, or other action should be worked on

    Type

    No type

    Projects

    Status

    No status

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions