qcs_sdk.qpu

The QPU module contains the API for interacting with Rigetti Quantum Processing Units (QPUs).

🔨 This page is under construction and the documentation for some submodules is missing. In the meantime, you can find documentation in the the type hints.

class QPUResultData:

Encapsulates data returned from the QPU after executing a job.

QPUResultData contains "mappings", which map declared memory regions in a program (ie. "ro[0]") to that regions readout key in QPUResultData.readout_values. readout_values maps those readout keys to the values emitted for that region across all shots.

Read more about QPU readout data in the QCS Documentation

def to_raw_readout_data(self) -> qcs_sdk.qpu.RawQPUReadoutData:

Get a copy of this result data flattened into a RawQPUReadoutData. This reduces the contained data down to primitive types, offering a simpler structure at the cost of the type safety provided by ReadoutValues and MemoryValues.

memory_values: Dict[str, qcs_sdk.qpu.MemoryValues]

Get mapping of a memory region (ie. "ro") to the final contents of that memory region.

readout_values: Dict[str, qcs_sdk.qpu.ReadoutValues]

Get the mappings of a readout values identifier (ie. "q0") to a set of ReadoutValues

mappings: Dict[str, str]

Get the mappings of a memory region (ie. "ro[0]") to it's key name in QPUResultData.readout_values

class RawQPUReadoutData:

Encapsulates data returned from the QPU after executing a job. Compared to QPUResultData.readout_values, the readout values in this class are returned as lists of numbers instead of values wrapped by the ReadoutValues class.

memory_values: Dict[str, Union[List[int], List[float], NoneType]]

Get mapping of a memory region (ie. "ro") to the final contents of that memory region.

mappings: Dict[str, str]

Get the mappings of a memory region (ie. "ro[0]") to it's key name in readout_values

readout_values: Dict[str, Union[List[int], List[float], List[complex]]]

Get the mappings of a readout values identifier (ie. "q0") to a list of those readout values

class ReadoutValues:

A row of readout values from the QPU. Each row contains all the values emitted to a memory reference across all shots. There is a variant for each possible type the list of readout values could be.

Variants:

  • integer: Corresponds to the Quil BIT, OCTET, or INTEGER types.
  • real: Corresponds to the Quil REAL type.
  • complex: Corresponds to readout values containing complex numbers

Methods (each per variant):

- ``is_*``: if the underlying values are that type.
- ``as_*``: if the underlying values are that type, then those values, otherwise ``None``.
- ``to_*``: the underlying values as that type, raises `ValueError` if they are not.
- ``from_*``: wrap underlying values as this enum type.
ReadoutValues(values: Union[List[int], List[float], List[complex]])

Construct a new ReadoutValues from a list of values.

def from_integer(inner: Sequence[int]) -> qcs_sdk.qpu.ReadoutValues:
def from_real(inner: Sequence[float]) -> qcs_sdk.qpu.ReadoutValues:
def from_complex(inner: Sequence[complex]) -> qcs_sdk.qpu.ReadoutValues:
def inner(self) -> Union[List[int], List[float], List[complex]]:

Return the inner list of readout values.

def is_integer(self) -> bool:
def as_integer(self) -> Optional[List[int]]:
def to_integer(self) -> List[int]:
def is_real(self) -> bool:
def as_real(self) -> Optional[List[float]]:
def to_real(self) -> List[float]:
def is_complex(self) -> bool:
def as_complex(self) -> Optional[List[complex]]:
def to_complex(self) -> List[complex]:
class MemoryValues:

A row of data containing the contents of a memory region at the end of a job. There is a variant for each possible type the memory region could be.

Variants:

  • binary: Corresponds to the Quil BIT and OCTET types.
  • integer: Corresponds to the Quil INTEGER types.
  • real: Corresponds to the Quil REAL`` type.

Methods (each per variant):

  • is_*: if the underlying values are that type.
  • as_*: if the underlying values are that type, then those values, otherwise None.
  • to_*: the underlying values as that type, raises ValueError if they are not.
  • from_*: wrap underlying values as this enum type.
MemoryValues(values: Union[List[int], List[float]])

Construct a new ReadoutValues from a list of values.

def from_binary(inner: Sequence[int]) -> qcs_sdk.qpu.ReadoutValues:
def from_integer(inner: Sequence[int]) -> qcs_sdk.qpu.ReadoutValues:
def from_real(inner: Sequence[float]) -> qcs_sdk.qpu.ReadoutValues:
def inner(self) -> Union[List[int], List[float]]:

Return the inner list of readout values.

def is_binary(self) -> bool:
def as_binary(self) -> Optional[List[int]]:
def to_binary(self) -> List[int]:
def is_integer(self) -> bool:
def as_integer(self) -> Optional[List[int]]:
def to_integer(self) -> List[int]:
def is_real(self) -> bool:
def as_real(self) -> Optional[List[float]]:
def to_real(self) -> List[float]:
class ListQuantumProcessorsError(builtins.RuntimeError):

A request to list available Quantum Processors failed.

Inherited Members
builtins.RuntimeError
RuntimeError
builtins.BaseException
with_traceback
add_note
args
def list_quantum_processors( client: Optional[QCSClient] = None, timeout: Optional[float] = None) -> List[str]:

Returns all available Quantum Processor (QPU) IDs.

Parameters
  • client: The qcs_sdk.client.QCSClient to use. Creates one using environment configuration if unset - see https: //docs.rigetti.com/qcs/references/qcs-client-configuration
  • timeout: Maximum duration to wait for API calls to complete, in seconds.
Raises
  • ListQuantumProcessorsError: If the request to list available QPU IDs failed.
async def list_quantum_processors_async( client: Optional[QCSClient] = None, timeout: Optional[float] = None) -> List[str]:

Returns all available Quantum Processor IDs. (async analog of list_quantum_processors)

Parameters
  • client: The qcs_sdk.client.QCSClient to use. Creates one using environment configuration if unset - see https: //docs.rigetti.com/qcs/references/qcs-client-configuration
  • timeout: Maximum duration to wait for API calls to complete, in seconds.
Raises
  • ListQuantumProcessorsError: If the request to list available QPU IDs failed.