rigetti / pyquil

A Python library for quantum programming using Quil.
http://docs.rigetti.com
Apache License 2.0
1.4k stars 342 forks source link

DEFCIRCUIT cannot parse a definition on fixed qubits #1744

Open mhodson-rigetti opened 7 months ago

mhodson-rigetti commented 7 months ago

Pre-Report Checklist

Issue Description

The following pyquil program parses OK:

DEFCIRCUIT SX_CYCLE:
    RX(pi/2) 1
    RX(pi/2) 2
    RX(pi/2) 4
    RX(pi/2) 5

However, the following variant does not parse:

DEFCIRCUIT SX_CYCLE 1 2 4 5:
    RX(pi/2) 1
    RX(pi/2) 2
    RX(pi/2) 4
    RX(pi/2) 5

The error is:

PyProgramError: error while parsing: at line 1, column 1 (COMMAND(DEFCIRCUIT)): failed to parse arguments for DEFCIRCUIT

According to the the Quil spec a DEFCIRCUIT should support numeric qubit identifiers in this context. Labels are supported, but in this instance we're trying to define a circuit that is equivalent to a DEFCAL on specific qubits.

The following version works but would allow use on sites other than (1, 2, 4, 5):

DEFCIRCUIT SX_CYCLE q0 q1 q2 q3:
    RX(pi/2) q0
    RX(pi/2) q1
    RX(pi/2) q2
    RX(pi/2) q3

Environment Context

Operating System: Ubuntu LTS 20.04.3

Python Version (python -V): 3.10.12

Quilc Version (quilc --version): 1.26.0 (docker)

QVM Version (qvm --version): Latest (docker)

PyQuil version: 4.6.2