Skip to content

Cirq --> pyQuil transpiler error for XX, YY, ZZ gates #386

Open
@ryanhill1

Description

There is a bug transpiling Cirq circuits containing the XXPowGate, YYPowGate or ZZPowGate to pyQuil. Below is a self-contained example showing the bug for the XXPowGate:

import cirq

from qbraid.transpiler import transpile
from qbraid.interface import circuits_allclose

# Create a quantum circuit with two qubits
q0, q1 = cirq.LineQubit.range(2)
cirq_in = cirq.Circuit()

# Add XX, YY, and ZZ gates to the circuit
exponents = [0.5, 1]
for theta in exponents:
    cirq_in.append(cirq.XXPowGate(exponent=theta).on(q0, q1))

pyquil_program = transpile(cirq_in, "pyquil")
cirq_out = transpile(pyquil_program, "cirq")

cirq_roundtrip_equal = circuits_allclose(cirq_in, cirq_out)

print(f"Cirq input:\n{cirq_in}\n")
print(f"Cirq -> pyQuil:\n{pyquil_program}\n")
print(f"pyQuil -> Cirq:\n{cirq_out}\n")
print(f"Cirq expected output:\n{cirq_in}\n")
print(f"Cirq roundtrip unitaries equal: {cirq_roundtrip_equal}")
Cirq input:
0: ───XX───────XX───
      │        │
1: ───XX^0.5───XX───

Cirq -> pyQuil:
RX(pi/2) 0
RX(pi/2) 1
X 0
X 1


pyQuil -> Cirq:
0: ───Rx(0.5π)───X───

1: ───Rx(0.5π)───X───

Cirq expected output:
0: ───XX───────XX───
      │        │
1: ───XX^0.5───XX───

Cirq roundtrip unitaries equal: False

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    bug 🐛Something isn't workinggood first issueGood for newcomerstranspiler 🚊Circuit conversions across program types

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions