quil.instructions

class Instruction:

A Quil instruction. Each variant corresponds to a possible type of Quil instruction.

Variants:

  • arithmetic: An arithmetic expression defined by an Arithmetic.
  • binary_logic: A binary expression defined by a BinaryLogic.
  • calibration_definition: Corresponds to a DEFCAL instruction (not DEFCAL MEASURE)
  • defined by a Calibration.
  • capture: Corresponds to a CAPTURE instruction
  • calibration: Corresponds to a DEFCAL instruction.
  • circuit_definition: Corresponds to a DEFCIRCUIT instruction and its body,
  • defined by a CircuitDefinition.
  • convert: Corresponds to a CONVERT instruction.
  • comparison: Corresponds to a comparison of two MemoryReferences
  • declaration: Corresponds to a DECLARE statement defined by a Declaration.
  • delay: Corresponds to a DELAY instruction.
  • exchange: Corresponds to an EXCHANGE instruction.
  • fence: Corresponds to a FENCE instruction.
  • frame_definition: Corresponds to a DEFFRAME statement, defined by a FrameDefinition.
  • gate: A Quil quantum gate instruction defined by a Gate.
  • gate_definition: A quantum gate definition defined by a GateDefinition.
  • halt: Corresponds to the HALT instruction. No inner data.
  • include: Corresponds to an INCLUDE directive.
  • jump: Corresponds to a JUMP instruction
  • jump_when: Corresponds to a JUMP-WHEN instruction
  • jump_unless: Corresponds to a JUMP-UNLESS instruction
  • label: Corresponds to a LABEL
  • load: Corresponds to a LOAD instruction.
  • measure_calibration_definition: Corresponds to a DEFCAL MEASURE instruction. Defined by a MeasureCalibrationDefinition.
  • measurement: Corresponds to a MEASURE instruction.
  • move: Corresponds to a MOVE instruction.
  • nop: Corresponds to the NOP instruction. No inner data.
  • pragma: Corresponds to a PRAGMA instruction.
  • pulse: Corresponds to a PULSE instruction.
  • raw_capture: Corresponds to a RAW-CAPTURE instruction.
  • reset: Corresponds to a RESET instruction.
  • set_frequency: Corresponds to a SET-FREQUENCY instruction.
  • set_phase: Corresponds to a SET-PHASE instruction.
  • set_scale: Corresponds to a SET-SCALE instruction.
  • shift_frequency: Corresponds to a SHIFT-FREQUENCY instruction.
  • shift_phase: Corresponds to a SHIFT-PHASE instruction.
  • store: Corresponds to a STORE instruction.
  • swap_phases: Corresponds to a SWAP-PHASES instruction.
  • unary_logic: Corresponds to a unary operation on a MemoryReference.
  • waveform_definition: A waveform defined by a WaveformDefinition.
  • wait: Corresponds to a WAIT instruction. No inner data.

As seen above, some variants contain inner data that fully specify the instruction. For example, the gate variant contains a Gate. This is in contrast to variants like halt that have no inner data because they require none to fully specify an instruction. This difference is important for determining which methods are available for each variant.

Methods (for each variant):

  • is_*: Returns True if the instruction is that variant, False otherwise.

If the variant has inner data (e.g. gate):

  • as_*: Returns the inner data if it is the given variant, None otherwise.
  • to_*: Returns the inner data if it is the given variant, raises ValueError otherwise.
  • from_*: Creates a new Instruction of the given variant from an instance of the inner type.

If the variant doesn't have inner data (e.g. halt)

def from_calibration_definition(inner: quil.instructions.Calibration) -> quil.instructions.Instruction:
def from_circuit_definition( inner: quil.instructions.CircuitDefinition) -> quil.instructions.Instruction:
def from_frame_definition( inner: quil.instructions.FrameDefinition) -> quil.instructions.Instruction:
def new_halt() -> quil.instructions.Instruction:
def from_measure_calibration_definition( inner: quil.instructions.MeasureCalibrationDefinition) -> quil.instructions.Instruction:
def new_nop() -> quil.instructions.Instruction:
def from_waveform_definition( inner: quil.instructions.WaveformDefinition) -> quil.instructions.Instruction:
def new_wait() -> quil.instructions.Instruction:
def is_arithmetic(self) -> bool:
def as_arithmetic(self) -> Optional[quil.instructions.Arithmetic]:
def to_arithmetic(self) -> quil.instructions.Arithmetic:
def is_binary_logic(self) -> bool:
def as_binary_logic(self) -> Optional[quil.instructions.BinaryLogic]:
def to_binary_logic(self) -> quil.instructions.BinaryLogic:
def is_calibration_definition(self) -> bool:
def as_calibration_definition(self) -> Optional[quil.instructions.Calibration]:
def to_calibration_definition(self) -> quil.instructions.Calibration:
def is_capture(self) -> bool:
def as_capture(self) -> Optional[quil.instructions.Capture]:
def to_capture(self) -> quil.instructions.Capture:
def is_circuit_definition(self) -> bool:
def as_circuit_definition(self) -> Optional[quil.instructions.CircuitDefinition]:
def to_circuit_definition(self) -> quil.instructions.CircuitDefinition:
def is_convert(self) -> bool:
def as_convert(self) -> Optional[quil.instructions.Convert]:
def to_convert(self) -> quil.instructions.Convert:
def is_comparison(self) -> bool:
def as_comparison(self) -> Optional[quil.instructions.Comparison]:
def to_comparison(self) -> quil.instructions.Comparison:
def is_declaration(self) -> bool:
def as_declaration(self) -> Optional[quil.instructions.Declaration]:
def to_declaration(self) -> quil.instructions.Declaration:
def is_delay(self) -> bool:
def as_delay(self) -> Optional[quil.instructions.Delay]:
def to_delay(self) -> quil.instructions.Delay:
def is_exchange(self) -> bool:
def as_exchange(self) -> Optional[quil.instructions.Exchange]:
def to_exchange(self) -> quil.instructions.Exchange:
def is_fence(self) -> bool:
def as_fence(self) -> Optional[quil.instructions.Fence]:
def to_fence(self) -> quil.instructions.Fence:
def is_frame_definition(self) -> bool:
def as_frame_definition(self) -> Optional[quil.instructions.FrameDefinition]:
def to_frame_definition(self) -> quil.instructions.FrameDefinition:
def is_gate(self) -> bool:
def as_gate(self) -> Optional[quil.instructions.Gate]:
def to_gate(self) -> quil.instructions.Gate:
def is_gate_definition(self) -> bool:
def as_gate_definition(self) -> Optional[quil.instructions.GateDefinition]:
def to_gate_definition(self) -> quil.instructions.GateDefinition:
def is_halt(self) -> bool:
def is_include(self) -> bool:
def as_include(self) -> Optional[quil.instructions.Include]:
def to_include(self) -> quil.instructions.Include:
def is_jump(self) -> bool:
def as_jump(self) -> Optional[quil.instructions.Jump]:
def to_jump(self) -> quil.instructions.Jump:
def is_jump_when(self) -> bool:
def as_jump_when(self) -> Optional[quil.instructions.JumpWhen]:
def to_jump_when(self) -> quil.instructions.JumpWhen:
def is_jump_unless(self) -> bool:
def as_jump_unless(self) -> Optional[quil.instructions.JumpUnless]:
def to_jump_unless(self) -> quil.instructions.JumpUnless:
def is_label(self) -> bool:
def as_label(self) -> Optional[quil.instructions.Label]:
def to_label(self) -> quil.instructions.Label:
def is_load(self) -> bool:
def as_load(self) -> Optional[quil.instructions.Load]:
def to_load(self) -> quil.instructions.Load:
def is_measure_calibration_definition(self) -> bool:
def as_measure_calibration_definition(self) -> Optional[quil.instructions.MeasureCalibrationDefinition]:
def to_measure_calibration_definition(self) -> quil.instructions.MeasureCalibrationDefinition:
def is_measurement(self) -> bool:
def as_measurement(self) -> Optional[quil.instructions.Measurement]:
def to_measurement(self) -> quil.instructions.Measurement:
def is_move(self) -> bool:
def as_move(self) -> Optional[quil.instructions.Move]:
def to_move(self) -> quil.instructions.Move:
def is_nop(self) -> bool:
def is_pragma(self) -> bool:
def as_pragma(self) -> Optional[quil.instructions.Pragma]:
def to_pragma(self) -> quil.instructions.Pragma:
def is_pulse(self) -> bool:
def as_pulse(self) -> Optional[quil.instructions.Pulse]:
def to_pulse(self) -> quil.instructions.Pulse:
def is_raw_capture(self) -> bool:
def as_raw_capture(self) -> Optional[quil.instructions.RawCapture]:
def to_raw_capture(self) -> quil.instructions.RawCapture:
def is_reset(self) -> bool:
def as_reset(self) -> Optional[quil.instructions.Reset]:
def to_reset(self) -> quil.instructions.Reset:
def is_set_frequency(self) -> bool:
def as_set_frequency(self) -> Optional[quil.instructions.SetFrequency]:
def to_set_frequency(self) -> quil.instructions.SetFrequency:
def is_set_phase(self) -> bool:
def as_set_phase(self) -> Optional[quil.instructions.SetPhase]:
def to_set_phase(self) -> quil.instructions.SetPhase:
def is_set_scale(self) -> bool:
def as_set_scale(self) -> Optional[quil.instructions.SetScale]:
def to_set_scale(self) -> quil.instructions.SetScale:
def is_shift_frequency(self) -> bool:
def as_shift_frequency(self) -> Optional[quil.instructions.ShiftFrequency]:
def to_shift_frequency(self) -> quil.instructions.ShiftFrequency:
def is_shift_phase(self) -> bool:
def as_shift_phase(self) -> Optional[quil.instructions.ShiftPhase]:
def to_shift_phase(self) -> quil.instructions.ShiftPhase:
def is_store(self) -> bool:
def as_store(self) -> Optional[quil.instructions.Store]:
def to_store(self) -> quil.instructions.Store:
def is_swap_phases(self) -> bool:
def as_swap_phases(self) -> Optional[quil.instructions.SwapPhases]:
def to_swap_phases(self) -> quil.instructions.SwapPhases:
def is_unary_logic(self) -> bool:
def as_unary_logic(self) -> Optional[quil.instructions.UnaryLogic]:
def to_unary_logic(self) -> quil.instructions.UnaryLogic:
def is_waveform_definition(self) -> bool:
def as_waveform_definition(self) -> Optional[quil.instructions.WaveformDefinition]:
def to_waveform_definition(self) -> quil.instructions.WaveformDefinition:
def is_wait(self) -> bool:
def to_quil(self) -> str:

Attempt to convert the instruction to a valid Quil string. Raises an exception if the instruction can't be converted to valid Quil.

def to_quil_or_debug(self) -> str:

Convert the instruction to a Quil string. If any part of the instruction can't be converted to valid Quil, it will be printed in a human-readable debug format.

def is_quil_t(self) -> bool:

Returns True if the instruction is a Quil-T instruction, False otherwise.

class Arithmetic:
def to_quil(self) -> str:

Attempt to convert the instruction to a valid Quil string. Raises an exception if the instruction can't be converted to valid Quil.

def to_quil_or_debug(self) -> str:

Convert the instruction to a Quil string. If any part of the instruction can't be converted to valid Quil, it will be printed in a human-readable debug format.

class ArithmeticOperand:

A Quil arithmetic operand.

Variants:

  • literal_integer: An integer literal.
  • literal_real: A real numbered literal.
  • memory_reference: A Quil MemoryReference.

Methods (for each variant):

  • is_*: Returns True if the operand is that variant, False otherwise.
  • as_*: Returns the inner data if it is the given variant, None otherwise.
  • to_*: Returns the inner data if it is the given variant, raises ValueError otherwise.
  • from_*: Creates a new ArithmeticOperand of the given variant from an instance of the inner type.
def from_literal_integer(inner: int) -> quil.instructions.ArithmeticOperand:
def from_literal_real(inner: float) -> quil.instructions.ArithmeticOperand:
def inner(self) -> Union[int, float, quil.instructions.MemoryReference]:

Returns the inner value of the variant. Raises a RuntimeError if inner data doesn't exist.

def is_literal_integer(self) -> bool:
def as_literal_integer(self) -> Optional[int]:
def to_literal_integer(self) -> int:
def is_literal_real(self) -> bool:
def as_literal_real(self) -> Optional[float]:
def to_literal_real(self) -> float:
def is_memory_reference(self) -> bool:
def as_memory_reference(self) -> Optional[quil.instructions.MemoryReference]:
def to_memory_reference(self) -> quil.instructions.MemoryReference:
def to_quil(self) -> str:

Attempt to convert the instruction to a valid Quil string. Raises an exception if the instruction can't be converted to valid Quil.

def to_quil_or_debug(self) -> str:

Convert the instruction to a Quil string. If any part of the instruction can't be converted to valid Quil, it will be printed in a human-readable debug format.

class ArithmeticOperator:

Create a collection of name/value pairs.

Example enumeration:

>>> class Color(Enum):
...     RED = 1
...     BLUE = 2
...     GREEN = 3

Access them by:

  • attribute access::
>>> Color.RED
<Color.RED: 1>
  • value lookup:
>>> Color(1)
<Color.RED: 1>
  • name lookup:
>>> Color['RED']
<Color.RED: 1>

Enumerations can be iterated over, and know how many members they have:

>>> len(Color)
3
>>> list(Color)
[<Color.RED: 1>, <Color.BLUE: 2>, <Color.GREEN: 3>]

Methods can be added to enumerations, and members can have their own attributes -- see the documentation for details.

def to_quil(self) -> str:

Attempt to convert the instruction to a valid Quil string. Raises an exception if the instruction can't be converted to valid Quil.

def to_quil_or_debug(self) -> str:

Convert the instruction to a Quil string. If any part of the instruction can't be converted to valid Quil, it will be printed in a human-readable debug format.

Add = Add
Subtract = Subtract
Divide = Divide
Multiply = Multiply
class BinaryLogic:
def to_quil(self) -> str:

Attempt to convert the instruction to a valid Quil string. Raises an exception if the instruction can't be converted to valid Quil.

def to_quil_or_debug(self) -> str:

Convert the instruction to a Quil string. If any part of the instruction can't be converted to valid Quil, it will be printed in a human-readable debug format.

class BinaryOperand:

A Quil binary operand.

Variants:

  • literal_integer: An integer literal.
  • memory_reference: A Quil MemoryReference.

Methods (for each variant):

  • is_*: Returns True if the operand is that variant, False otherwise.
  • as_*: Returns the inner data if it is the given variant, None otherwise.
  • to_*: Returns the inner data if it is the given variant, raises ValueError otherwise.
  • from_*: Creates a new BinaryOperand of the given variant from an instance of the inner type.
def from_literal_integer(inner: int) -> quil.instructions.BinaryOperand:
def inner(self) -> Union[int, quil.instructions.MemoryReference]:

Returns the inner value of the variant. Raises a RuntimeError if inner data doesn't exist.

def is_literal_integer(self) -> bool:
def as_literal_integer(self) -> Optional[int]:
def to_literal_integer(self) -> int:
def is_memory_reference(self) -> bool:
def as_memory_reference(self) -> Optional[quil.instructions.MemoryReference]:
def to_memory_reference(self) -> quil.instructions.MemoryReference:
def to_quil(self) -> str:

Attempt to convert the instruction to a valid Quil string. Raises an exception if the instruction can't be converted to valid Quil.

def to_quil_or_debug(self) -> str:

Convert the instruction to a Quil string. If any part of the instruction can't be converted to valid Quil, it will be printed in a human-readable debug format.

class BinaryOperands:
class BinaryOperator:

Create a collection of name/value pairs.

Example enumeration:

>>> class Color(Enum):
...     RED = 1
...     BLUE = 2
...     GREEN = 3

Access them by:

  • attribute access::
>>> Color.RED
<Color.RED: 1>
  • value lookup:
>>> Color(1)
<Color.RED: 1>
  • name lookup:
>>> Color['RED']
<Color.RED: 1>

Enumerations can be iterated over, and know how many members they have:

>>> len(Color)
3
>>> list(Color)
[<Color.RED: 1>, <Color.BLUE: 2>, <Color.GREEN: 3>]

Methods can be added to enumerations, and members can have their own attributes -- see the documentation for details.

def to_quil(self) -> str:

Attempt to convert the instruction to a valid Quil string. Raises an exception if the instruction can't be converted to valid Quil.

def to_quil_or_debug(self) -> str:

Convert the instruction to a Quil string. If any part of the instruction can't be converted to valid Quil, it will be printed in a human-readable debug format.

And = And
Ior = Ior
Xor = Xor
class Comparison:
def to_quil(self) -> str:

Attempt to convert the instruction to a valid Quil string. Raises an exception if the instruction can't be converted to valid Quil.

def to_quil_or_debug(self) -> str:

Convert the instruction to a Quil string. If any part of the instruction can't be converted to valid Quil, it will be printed in a human-readable debug format.

class ComparisonOperand:

A Quil binary operand.

Variants:

  • literal_integer: An integer literal.
  • literal_real: A floating point literal.
  • memory_reference: A Quil MemoryReference.

Methods (for each variant):

  • is_*: Returns True if the operand is that variant, False otherwise.
  • as_*: Returns the inner data if it is the given variant, None otherwise.
  • to_*: Returns the inner data if it is the given variant, raises ValueError otherwise.
  • from_*: Creates a new BinaryOperand of the given variant from an instance of the inner type.
def from_literal_integer(inner: int) -> quil.instructions.ComparisonOperand:
def from_literal_real(inner: float) -> quil.instructions.ComparisonOperand:
def inner(self) -> Union[int, float, quil.instructions.MemoryReference]:

Returns the inner value of the variant.

def is_literal_integer(self) -> bool:
def as_literal_integer(self) -> Optional[int]:
def to_literal_integer(self) -> int:
def is_literal_real(self) -> bool:
def as_literal_real(self) -> Optional[float]:
def to_literal_real(self) -> float:
def is_memory_reference(self) -> bool:
def as_memory_reference(self) -> Optional[quil.instructions.MemoryReference]:
def to_memory_reference(self) -> quil.instructions.MemoryReference:
def to_quil(self) -> str:

Attempt to convert the instruction to a valid Quil string. Raises an exception if the instruction can't be converted to valid Quil.

def to_quil_or_debug(self) -> str:

Convert the instruction to a Quil string. If any part of the instruction can't be converted to valid Quil, it will be printed in a human-readable debug format.

class ComparisonOperator:

Create a collection of name/value pairs.

Example enumeration:

>>> class Color(Enum):
...     RED = 1
...     BLUE = 2
...     GREEN = 3

Access them by:

  • attribute access::
>>> Color.RED
<Color.RED: 1>
  • value lookup:
>>> Color(1)
<Color.RED: 1>
  • name lookup:
>>> Color['RED']
<Color.RED: 1>

Enumerations can be iterated over, and know how many members they have:

>>> len(Color)
3
>>> list(Color)
[<Color.RED: 1>, <Color.BLUE: 2>, <Color.GREEN: 3>]

Methods can be added to enumerations, and members can have their own attributes -- see the documentation for details.

class Convert:
def to_quil(self) -> str:

Attempt to convert the instruction to a valid Quil string. Raises an exception if the instruction can't be converted to valid Quil.

def to_quil_or_debug(self) -> str:

Convert the instruction to a Quil string. If any part of the instruction can't be converted to valid Quil, it will be printed in a human-readable debug format.

class Exchange:
def to_quil(self) -> str:

Attempt to convert the instruction to a valid Quil string. Raises an exception if the instruction can't be converted to valid Quil.

def to_quil_or_debug(self) -> str:

Convert the instruction to a Quil string. If any part of the instruction can't be converted to valid Quil, it will be printed in a human-readable debug format.

class Move:
def to_quil(self) -> str:

Attempt to convert the instruction to a valid Quil string. Raises an exception if the instruction can't be converted to valid Quil.

def to_quil_or_debug(self) -> str:

Convert the instruction to a Quil string. If any part of the instruction can't be converted to valid Quil, it will be printed in a human-readable debug format.

class UnaryLogic:
def to_quil(self) -> str:

Attempt to convert the instruction to a valid Quil string. Raises an exception if the instruction can't be converted to valid Quil.

def to_quil_or_debug(self) -> str:

Convert the instruction to a Quil string. If any part of the instruction can't be converted to valid Quil, it will be printed in a human-readable debug format.

class UnaryOperator:

Create a collection of name/value pairs.

Example enumeration:

>>> class Color(Enum):
...     RED = 1
...     BLUE = 2
...     GREEN = 3

Access them by:

  • attribute access::
>>> Color.RED
<Color.RED: 1>
  • value lookup:
>>> Color(1)
<Color.RED: 1>
  • name lookup:
>>> Color['RED']
<Color.RED: 1>

Enumerations can be iterated over, and know how many members they have:

>>> len(Color)
3
>>> list(Color)
[<Color.RED: 1>, <Color.BLUE: 2>, <Color.GREEN: 3>]

Methods can be added to enumerations, and members can have their own attributes -- see the documentation for details.

def to_quil(self) -> str:

Attempt to convert the instruction to a valid Quil string. Raises an exception if the instruction can't be converted to valid Quil.

def to_quil_or_debug(self) -> str:

Convert the instruction to a Quil string. If any part of the instruction can't be converted to valid Quil, it will be printed in a human-readable debug format.

Neg = Neg
Not = Not
class Calibration:
def to_quil(self) -> str:

Attempt to convert the instruction to a valid Quil string. Raises an exception if the instruction can't be converted to valid Quil.

def to_quil_or_debug(self) -> str:

Convert the instruction to a Quil string. If any part of the instruction can't be converted to valid Quil, it will be printed in a human-readable debug format.

instructions: List[quil.instructions.Instruction]
parameters: List[quil.expression.Expression]
qubits: List[quil.instructions.Qubit]
name: str
class CircuitDefinition:
def to_quil(self) -> str:

Attempt to convert the instruction to a valid Quil string. Raises an exception if the instruction can't be converted to valid Quil.

def to_quil_or_debug(self) -> str:

Convert the instruction to a Quil string. If any part of the instruction can't be converted to valid Quil, it will be printed in a human-readable debug format.

qubit_variables: List[str]
name: str
parameters: List[str]
instructions: List[quil.instructions.Instruction]
class MeasureCalibrationDefinition:
def to_quil(self) -> str:

Attempt to convert the instruction to a valid Quil string. Raises an exception if the instruction can't be converted to valid Quil.

def to_quil_or_debug(self) -> str:

Convert the instruction to a Quil string. If any part of the instruction can't be converted to valid Quil, it will be printed in a human-readable debug format.

qubit: Optional[quil.instructions.Qubit]
instructions: List[quil.instructions.Instruction]
parameter: str
class Declaration:
def to_quil(self) -> str:

Attempt to convert the instruction to a valid Quil string. Raises an exception if the instruction can't be converted to valid Quil.

def to_quil_or_debug(self) -> str:

Convert the instruction to a Quil string. If any part of the instruction can't be converted to valid Quil, it will be printed in a human-readable debug format.

sharing: Optional[quil.instructions.Sharing]
name: str
class Load:
def to_quil(self) -> str:

Attempt to convert the instruction to a valid Quil string. Raises an exception if the instruction can't be converted to valid Quil.

def to_quil_or_debug(self) -> str:

Convert the instruction to a Quil string. If any part of the instruction can't be converted to valid Quil, it will be printed in a human-readable debug format.

source: str
class Offset:
def to_quil(self) -> str:

Attempt to convert the instruction to a valid Quil string. Raises an exception if the instruction can't be converted to valid Quil.

def to_quil_or_debug(self) -> str:

Convert the instruction to a Quil string. If any part of the instruction can't be converted to valid Quil, it will be printed in a human-readable debug format.

offset: int
class Sharing:
name: str
offsets: List[quil.instructions.Offset]
class Store:
def to_quil(self) -> str:

Attempt to convert the instruction to a valid Quil string. Raises an exception if the instruction can't be converted to valid Quil.

def to_quil_or_debug(self) -> str:

Convert the instruction to a Quil string. If any part of the instruction can't be converted to valid Quil, it will be printed in a human-readable debug format.

destination: str
class ScalarType:

Create a collection of name/value pairs.

Example enumeration:

>>> class Color(Enum):
...     RED = 1
...     BLUE = 2
...     GREEN = 3

Access them by:

  • attribute access::
>>> Color.RED
<Color.RED: 1>
  • value lookup:
>>> Color(1)
<Color.RED: 1>
  • name lookup:
>>> Color['RED']
<Color.RED: 1>

Enumerations can be iterated over, and know how many members they have:

>>> len(Color)
3
>>> list(Color)
[<Color.RED: 1>, <Color.BLUE: 2>, <Color.GREEN: 3>]

Methods can be added to enumerations, and members can have their own attributes -- see the documentation for details.

def to_quil(self) -> str:

Attempt to convert the instruction to a valid Quil string. Raises an exception if the instruction can't be converted to valid Quil.

def to_quil_or_debug(self) -> str:

Convert the instruction to a Quil string. If any part of the instruction can't be converted to valid Quil, it will be printed in a human-readable debug format.

Bit = Bit
Integer = Integer
Octet = Octet
Real = Real
class Vector:
def to_quil(self) -> str:

Attempt to convert the instruction to a valid Quil string. Raises an exception if the instruction can't be converted to valid Quil.

def to_quil_or_debug(self) -> str:

Convert the instruction to a Quil string. If any part of the instruction can't be converted to valid Quil, it will be printed in a human-readable debug format.

length: int
class Measurement:
def to_quil(self) -> str:

Attempt to convert the instruction to a valid Quil string. Raises an exception if the instruction can't be converted to valid Quil.

def to_quil_or_debug(self) -> str:

Convert the instruction to a Quil string. If any part of the instruction can't be converted to valid Quil, it will be printed in a human-readable debug format.

class Include:
def to_quil(self) -> str:

Attempt to convert the instruction to a valid Quil string. Raises an exception if the instruction can't be converted to valid Quil.

def to_quil_or_debug(self) -> str:

Convert the instruction to a Quil string. If any part of the instruction can't be converted to valid Quil, it will be printed in a human-readable debug format.

filename: str
class Pragma:
def to_quil(self) -> str:

Attempt to convert the instruction to a valid Quil string. Raises an exception if the instruction can't be converted to valid Quil.

def to_quil_or_debug(self) -> str:

Convert the instruction to a Quil string. If any part of the instruction can't be converted to valid Quil, it will be printed in a human-readable debug format.

data: Optional[str]
name: str
class PragmaArgument:

Variants:

  • identifier: A Pragma argument defined by a Quil identifier
  • integer: A Pragma argument defined by an integer

Methods (for each variant):

  • is_*: Returns True if the inner type is of that variant.
  • as_*: Returns the inner data if it is the given variant, None otherwise.
  • to_*: Returns the inner data if it is the given variant, raises ValueError otherwise.
  • from_*: Creates a new PragmaArgument using an instance of the inner type for the variant.
def from_identifier(inner: str) -> quil.instructions.PragmaArgument:
def from_integer(inner: int) -> quil.instructions.PragmaArgument:
def inner(self) -> Union[str, int]:

Returns the inner value of the variant. Raises a RuntimeError if inner data doesn't exist.

def is_identifier(self) -> bool:
def as_identifier(self) -> Optional[str]:
def to_identifier(self) -> str:
def is_integer(self) -> bool:
def as_integer(self) -> Optional[int]:
def to_integer(self) -> int:
def to_quil(self) -> str:

Attempt to convert the instruction to a valid Quil string. Raises an exception if the instruction can't be converted to valid Quil.

def to_quil_or_debug(self) -> str:

Convert the instruction to a Quil string. If any part of the instruction can't be converted to valid Quil, it will be printed in a human-readable debug format.

class AttributeValue:

A frame attribute value.

Variants:

  • string: A string attribute containing a str.
  • expression: An expression attribute containing an Expression.

Methods (for each variant):

  • is_*: Returns True if the AttributeValue is that variant, False otherwise.
  • as_*: Returns the inner data if it is the given variant, None otherwise.
  • to_*: Returns the inner data if it is the given variant, raises ValueError otherwise.
  • from_*: Creates a new AttributeValue of the given variant from an instance of the inner type.
def from_string(inner: str) -> quil.instructions.AttributeValue:
def inner(self) -> Union[str, quil.expression.Expression]:

Returns the inner value of the variant. Raises a RuntimeError if inner data doesn't exist.

def is_string(self) -> bool:
def as_string(self) -> Optional[str]:
def to_string(self) -> str:
def is_expression(self) -> bool:
def as_expression(self) -> Optional[quil.expression.Expression]:
def to_expression(self) -> quil.expression.Expression:
def to_quil(self) -> str:

Attempt to convert the instruction to a valid Quil string. Raises an exception if the instruction can't be converted to valid Quil.

def to_quil_or_debug(self) -> str:

Convert the instruction to a Quil string. If any part of the instruction can't be converted to valid Quil, it will be printed in a human-readable debug format.

class Capture:
def to_quil(self) -> str:

Attempt to convert the instruction to a valid Quil string. Raises an exception if the instruction can't be converted to valid Quil.

def to_quil_or_debug(self) -> str:

Convert the instruction to a Quil string. If any part of the instruction can't be converted to valid Quil, it will be printed in a human-readable debug format.

blocking: bool
class FrameDefinition:
def to_quil(self) -> str:

Attempt to convert the instruction to a valid Quil string. Raises an exception if the instruction can't be converted to valid Quil.

def to_quil_or_debug(self) -> str:

Convert the instruction to a Quil string. If any part of the instruction can't be converted to valid Quil, it will be printed in a human-readable debug format.

attributes: Dict[str, quil.instructions.AttributeValue]
class FrameIdentifier:
def to_quil(self) -> str:

Attempt to convert the instruction to a valid Quil string. Raises an exception if the instruction can't be converted to valid Quil.

def to_quil_or_debug(self) -> str:

Convert the instruction to a Quil string. If any part of the instruction can't be converted to valid Quil, it will be printed in a human-readable debug format.

name: str
qubits: List[quil.instructions.Qubit]
class Pulse:
def to_quil(self) -> str:

Attempt to convert the instruction to a valid Quil string. Raises an exception if the instruction can't be converted to valid Quil.

def to_quil_or_debug(self) -> str:

Convert the instruction to a Quil string. If any part of the instruction can't be converted to valid Quil, it will be printed in a human-readable debug format.

blocking: bool
class RawCapture:
def to_quil(self) -> str:

Attempt to convert the instruction to a valid Quil string. Raises an exception if the instruction can't be converted to valid Quil.

def to_quil_or_debug(self) -> str:

Convert the instruction to a Quil string. If any part of the instruction can't be converted to valid Quil, it will be printed in a human-readable debug format.

blocking: bool
class SetFrequency:
def to_quil(self) -> str:

Attempt to convert the instruction to a valid Quil string. Raises an exception if the instruction can't be converted to valid Quil.

def to_quil_or_debug(self) -> str:

Convert the instruction to a Quil string. If any part of the instruction can't be converted to valid Quil, it will be printed in a human-readable debug format.

class SetPhase:
def to_quil(self) -> str:

Attempt to convert the instruction to a valid Quil string. Raises an exception if the instruction can't be converted to valid Quil.

def to_quil_or_debug(self) -> str:

Convert the instruction to a Quil string. If any part of the instruction can't be converted to valid Quil, it will be printed in a human-readable debug format.

class SetScale:
def to_quil(self) -> str:

Attempt to convert the instruction to a valid Quil string. Raises an exception if the instruction can't be converted to valid Quil.

def to_quil_or_debug(self) -> str:

Convert the instruction to a Quil string. If any part of the instruction can't be converted to valid Quil, it will be printed in a human-readable debug format.

class ShiftFrequency:
def to_quil(self) -> str:

Attempt to convert the instruction to a valid Quil string. Raises an exception if the instruction can't be converted to valid Quil.

def to_quil_or_debug(self) -> str:

Convert the instruction to a Quil string. If any part of the instruction can't be converted to valid Quil, it will be printed in a human-readable debug format.

class ShiftPhase:
def to_quil(self) -> str:

Attempt to convert the instruction to a valid Quil string. Raises an exception if the instruction can't be converted to valid Quil.

def to_quil_or_debug(self) -> str:

Convert the instruction to a Quil string. If any part of the instruction can't be converted to valid Quil, it will be printed in a human-readable debug format.

class SwapPhases:
def to_quil(self) -> str:

Attempt to convert the instruction to a valid Quil string. Raises an exception if the instruction can't be converted to valid Quil.

def to_quil_or_debug(self) -> str:

Convert the instruction to a Quil string. If any part of the instruction can't be converted to valid Quil, it will be printed in a human-readable debug format.

class Gate:
def to_quil(self) -> str:

Attempt to convert the instruction to a valid Quil string. Raises an exception if the instruction can't be converted to valid Quil.

def to_quil_or_debug(self) -> str:

Convert the instruction to a Quil string. If any part of the instruction can't be converted to valid Quil, it will be printed in a human-readable debug format.

def dagger(self) -> Self:

Returns a copy of the gate with the DAGGER modifier added to it.

def controlled(self, control_qubit: quil.instructions.Qubit) -> Self:

Returns a copy of the gate with the CONTROLLED modifier added to it.

def forked( self, fork_qubit: quil.instructions.Qubit, alt_params: Sequence[quil.expression.Expression]) -> Self:

Returns a copy of the gate with the FORKED modifier added to it.

Raises a GateError if the number of provided alternate parameters don't equal the number of existing parameters.

def to_unitary_mut( self, n_qubits: int) -> numpy.ndarray[typing.Any, numpy.dtype[numpy.complex128]]:

Lift a Gate to the full n_qubits-qubit Hilbert space.

Returns a `GateError if any of the parameters of this gate are non-constant, if any of the qubits are variable, if the name of this gate is unknown, or if there are an unexpected number of parameters.

name: str
parameters: List[quil.expression.Expression]
qubits: List[quil.instructions.Qubit]
class GateDefinition:
def to_quil(self) -> str:

Attempt to convert the instruction to a valid Quil string. Raises an exception if the instruction can't be converted to valid Quil.

def to_quil_or_debug(self) -> str:

Convert the instruction to a Quil string. If any part of the instruction can't be converted to valid Quil, it will be printed in a human-readable debug format.

name: str
parameters: List[str]
class GateModifier:

Create a collection of name/value pairs.

Example enumeration:

>>> class Color(Enum):
...     RED = 1
...     BLUE = 2
...     GREEN = 3

Access them by:

  • attribute access::
>>> Color.RED
<Color.RED: 1>
  • value lookup:
>>> Color(1)
<Color.RED: 1>
  • name lookup:
>>> Color['RED']
<Color.RED: 1>

Enumerations can be iterated over, and know how many members they have:

>>> len(Color)
3
>>> list(Color)
[<Color.RED: 1>, <Color.BLUE: 2>, <Color.GREEN: 3>]

Methods can be added to enumerations, and members can have their own attributes -- see the documentation for details.

def to_quil(self) -> str:

Attempt to convert the instruction to a valid Quil string. Raises an exception if the instruction can't be converted to valid Quil.

def to_quil_or_debug(self) -> str:

Convert the instruction to a Quil string. If any part of the instruction can't be converted to valid Quil, it will be printed in a human-readable debug format.

Controlled = Controlled
Dagger = Dagger
Forked = Forked
class GateSpecification:

A specification for a gate definition.

Variants:

  • matrix: A gate specificied by a matrix of Expressions representing a unitary operation.
  • permutation: A gate specified by a vector of integers that defines a permutation.

Methods (for each variant):

  • is_*: Returns True if the inner type is of that variant.
  • as_*: Returns the inner data if it is the given variant, None otherwise.
  • to_*: Returns the inner data if it is the given variant, raises ValueError otherwise.
  • from_*: Creates a new GateSpecification using an instance of the inner type for the variant.
def from_matrix( inner: Sequence[Sequence[quil.expression.Expression]]) -> quil.instructions.GateSpecification:
def from_permutation(inner: Sequence[int]) -> quil.instructions.GateSpecification:
def inner( self) -> Union[List[List[quil.expression.Expression]], List[int], quil.instructions.PauliSum]:

Returns the inner value of the variant. Raises a RuntimeError if inner data doesn't exist.

def is_matrix(self) -> bool:
def as_matrix(self) -> Optional[List[List[quil.expression.Expression]]]:
def to_matrix(self) -> List[List[quil.expression.Expression]]:
def is_permutation(self) -> bool:
def as_permutation(self) -> Optional[List[int]]:
def to_permutation(self) -> List[int]:
def is_pauli_sum(self) -> bool:
def as_pauli_sum(self) -> Optional[quil.instructions.PauliSum]:
def to_pauli_sum(self) -> quil.instructions.PauliSum:
def to_quil(self) -> str:

Attempt to convert the instruction to a valid Quil string. Raises an exception if the instruction can't be converted to valid Quil.

def to_quil_or_debug(self) -> str:

Convert the instruction to a Quil string. If any part of the instruction can't be converted to valid Quil, it will be printed in a human-readable debug format.

class PauliGate:

Create a collection of name/value pairs.

Example enumeration:

>>> class Color(Enum):
...     RED = 1
...     BLUE = 2
...     GREEN = 3

Access them by:

  • attribute access::
>>> Color.RED
<Color.RED: 1>
  • value lookup:
>>> Color(1)
<Color.RED: 1>
  • name lookup:
>>> Color['RED']
<Color.RED: 1>

Enumerations can be iterated over, and know how many members they have:

>>> len(Color)
3
>>> list(Color)
[<Color.RED: 1>, <Color.BLUE: 2>, <Color.GREEN: 3>]

Methods can be added to enumerations, and members can have their own attributes -- see the documentation for details.

def parse(input: str) -> quil.instructions.PauliGate:

Parses a PauliGate from a string. Raises a ParseEnumError if the string isn't a valid Pauli word.

I = I
X = X
Y = Y
Z = Z
class PauliTerm:
arguments: List[Tuple[quil.instructions.PauliGate, str]]
class PauliSum:
arguments: List[str]
class Jump:
def to_quil(self) -> str:

Attempt to convert the instruction to a valid Quil string. Raises an exception if the instruction can't be converted to valid Quil.

def to_quil_or_debug(self) -> str:

Convert the instruction to a Quil string. If any part of the instruction can't be converted to valid Quil, it will be printed in a human-readable debug format.

class JumpWhen:
def to_quil(self) -> str:

Attempt to convert the instruction to a valid Quil string. Raises an exception if the instruction can't be converted to valid Quil.

def to_quil_or_debug(self) -> str:

Convert the instruction to a Quil string. If any part of the instruction can't be converted to valid Quil, it will be printed in a human-readable debug format.

class JumpUnless:
def to_quil(self) -> str:

Attempt to convert the instruction to a valid Quil string. Raises an exception if the instruction can't be converted to valid Quil.

def to_quil_or_debug(self) -> str:

Convert the instruction to a Quil string. If any part of the instruction can't be converted to valid Quil, it will be printed in a human-readable debug format.

class Label:
def to_quil(self) -> str:

Attempt to convert the instruction to a valid Quil string. Raises an exception if the instruction can't be converted to valid Quil.

def to_quil_or_debug(self) -> str:

Convert the instruction to a Quil string. If any part of the instruction can't be converted to valid Quil, it will be printed in a human-readable debug format.

class Target:

Represents a Quil target.

Variants:

  • fixed: A fixed target defined by a Quil identifier
  • placeholder: A placeholder target that can be assigned a new name at a later time.

Methods (for each variant):

  • is_*: Returns True if the inner type is of that variant.
  • as_*: Returns the inner data if it is the given variant, None otherwise.
  • to_*: Returns the inner data if it is the given variant, raises ValueError otherwise.
  • from_*: Creates a new PragmaArgument using an instance of the inner type for the variant.
def from_fixed(inner: str) -> quil.instructions.Target:
def inner(self) -> Union[str, quil.instructions.TargetPlaceholder]:
def is_fixed(self) -> bool:
def as_fixed(self) -> Optional[str]:
def to_fixed(self) -> str:
def is_placeholder(self) -> bool:
def as_placeholder(self) -> Optional[quil.instructions.TargetPlaceholder]:
def to_placeholder(self) -> quil.instructions.TargetPlaceholder:
def to_quil(self) -> str:

Attempt to convert the instruction to a valid Quil string. Raises an exception if the instruction can't be converted to valid Quil.

def to_quil_or_debug(self) -> str:

Convert the instruction to a Quil string. If any part of the instruction can't be converted to valid Quil, it will be printed in a human-readable debug format.

class TargetPlaceholder:

A placeholder target that must be assigned a fixed name before creating a program with valid quil.

See quil.program.Program#resolve_placeholders for more information.

base_label: str
class MemoryReference:
def to_quil(self) -> str:

Attempt to convert the instruction to a valid Quil string. Raises an exception if the instruction can't be converted to valid Quil.

def to_quil_or_debug(self) -> str:

Convert the instruction to a Quil string. If any part of the instruction can't be converted to valid Quil, it will be printed in a human-readable debug format.

def parse(input: str) -> quil.instructions.MemoryReference:

Parses a MemoryReference from a string. Raises a ParseMemoryReference error if the string isn't a valid Quil memory reference.

name: str
index: int
class Qubit:

A Qubit

Variants:

  • fixed: A qubit represented as a fixed integer index.
  • variable: A qubit represented by a name.

Methods (for each variant):

  • is_*: Returns True if the inner type is of that variant.
  • as_*: Returns the inner data if it is the given variant, None otherwise.
  • to_*: Returns the inner data if it is the given variant, raises ValueError otherwise.
  • from_*: Creates a new Qubit using an instance of the inner type for the variant.
def from_fixed(inner: int) -> quil.instructions.Qubit:
def from_variable(inner: str) -> quil.instructions.Qubit:
def inner(self) -> Union[int, str]:

Returns the inner value of the variant. Raises a RuntimeError if inner data doesn't exist.

def is_fixed(self) -> bool:
def as_fixed(self) -> Optional[int]:
def to_fixed(self) -> int:
def is_variable(self) -> bool:
def as_variable(self) -> Optional[str]:
def to_variable(self) -> str:
def is_placeholder(self) -> bool:
def as_placeholder(self) -> Optional[quil.instructions.QubitPlaceholder]:
def to_placeholder(self) -> quil.instructions.QubitPlaceholder:
def to_quil(self) -> str:

Attempt to convert the instruction to a valid Quil string. Raises an exception if the instruction can't be converted to valid Quil.

def to_quil_or_debug(self) -> str:

Convert the instruction to a Quil string. If any part of the instruction can't be converted to valid Quil, it will be printed in a human-readable debug format.

class QubitPlaceholder:

A qubit that can be used as a placeholder. Must be resolved before converting a program to valid Quil. See quil.program.Program#resolve_placeholders.

class Reset:
def to_quil(self) -> str:

Attempt to convert the instruction to a valid Quil string. Raises an exception if the instruction can't be converted to valid Quil.

def to_quil_or_debug(self) -> str:

Convert the instruction to a Quil string. If any part of the instruction can't be converted to valid Quil, it will be printed in a human-readable debug format.

qubit: Optional[quil.instructions.Qubit]
class Delay:
def to_quil(self) -> str:

Attempt to convert the instruction to a valid Quil string. Raises an exception if the instruction can't be converted to valid Quil.

def to_quil_or_debug(self) -> str:

Convert the instruction to a Quil string. If any part of the instruction can't be converted to valid Quil, it will be printed in a human-readable debug format.

frame_names: List[str]
qubits: List[quil.instructions.Qubit]
class Fence:
def to_quil(self) -> str:

Attempt to convert the instruction to a valid Quil string. Raises an exception if the instruction can't be converted to valid Quil.

def to_quil_or_debug(self) -> str:

Convert the instruction to a Quil string. If any part of the instruction can't be converted to valid Quil, it will be printed in a human-readable debug format.

qubits: List[quil.instructions.Qubit]
class Waveform:
parameters: List[str]
class WaveformDefinition:
def to_quil(self) -> str:

Attempt to convert the instruction to a valid Quil string. Raises an exception if the instruction can't be converted to valid Quil.

def to_quil_or_debug(self) -> str:

Convert the instruction to a Quil string. If any part of the instruction can't be converted to valid Quil, it will be printed in a human-readable debug format.

name: str
class WaveformInvocation:
def to_quil(self) -> str:

Attempt to convert the instruction to a valid Quil string. Raises an exception if the instruction can't be converted to valid Quil.

def to_quil_or_debug(self) -> str:

Convert the instruction to a Quil string. If any part of the instruction can't be converted to valid Quil, it will be printed in a human-readable debug format.

name: str
parameters: Dict[str, quil.expression.Expression]
class GateError(builtins.ValueError):

An error that may occur when performing operations on a Gate

Inherited Members
builtins.ValueError
ValueError
builtins.BaseException
with_traceback
add_note
args
class ParseMemoryReferenceError(builtins.ValueError):

Errors that may occur while parsing a MemoryReference

Inherited Members
builtins.ValueError
ValueError
builtins.BaseException
with_traceback
add_note
args