Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Regression in PyQuil CPHASE00 conversions #6714

Open
natestemen opened this issue Aug 29, 2024 · 0 comments
Open

Regression in PyQuil CPHASE00 conversions #6714

natestemen opened this issue Aug 29, 2024 · 0 comments
Labels
kind/bug-report Something doesn't seem to work. triage/accepted A consensus emerged that this bug report, feature request, or other action should be worked on

Comments

@natestemen
Copy link

natestemen commented Aug 29, 2024

Description of the issue

When converting a PyQuil program to a Cirq circuit using the cirq_rigetti.circuit_from_quil function the output differs between cirq versions 1.4.1 and 1.3.0. Specifically, in cirq==1.4.1, the CPHASE00 gate is converted into a custom USERGATE gate with complex matrix elements, while in cirq==1.3.0, the gate is correctly recognized and output as CPHASE00.

How to reproduce the issue

  1. Create a file pyquil_conv.py with the following script.

    from cirq_rigetti import circuit_from_quil
    from cirq_rigetti.quil_output import QuilOutput
    from pyquil import Program
    
    QUIL_PROGRAM = """
    RZ(pi/2) 0
    CPHASE00(pi/2) 0 1
    """
    
    p = Program(QUIL_PROGRAM)
    circ = circuit_from_quil(p.out())
    print(QuilOutput(circ.all_operations(), circ.all_qubits()))
  2. Run the script with cirq==1.4.1

    $ pip list | grep -E "cirq-core|cirq-rigetti"
    cirq-core                       1.4.1
    cirq-rigetti                    1.4.1
    $ python pyquil_conv.py
    # Created using Cirq.
    
    RZ(1.5707963267948966) 0
    DEFGATE USERGATE1:
        6.123233995736766e-17+1.0i, 0.0+0.0i, 0.0+0.0i, 0.0+0.0i
        0.0+0.0i, 1.0+0.0i, 0.0+0.0i, 0.0+0.0i
        0.0+0.0i, 0.0+0.0i, 1.0+0.0i, 0.0+0.0i
        0.0+0.0i, 0.0+0.0i, 0.0+0.0i, 1.0+0.0i
    USERGATE1 0 1
  3. Run the script with cirq==1.3.0

    $ pip list | grep -E "cirq-core|cirq-rigetti"
    cirq-core                1.3.0
    cirq-rigetti             1.3.0
    $ python pyquil_conv.py
    # Created using Cirq.
    
    RZ(1.5707963267948966) 0
    CPHASE00(1.5707963267948966) 0 1

Related

When adding support for pyquil v4 a similar example was found in #6281 (comment).

@natestemen natestemen added the kind/bug-report Something doesn't seem to work. label Aug 29, 2024
@pavoljuhas pavoljuhas added the triage/accepted A consensus emerged that this bug report, feature request, or other action should be worked on label Sep 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug-report Something doesn't seem to work. triage/accepted A consensus emerged that this bug report, feature request, or other action should be worked on
Projects
None yet
Development

No branches or pull requests

2 participants