# This file is automatically generated by pyo3_stub_gen
# ruff: noqa: E501, F401
import builtins
import collections.abc
import typing
from qcs_sdk import QcsSdkError, RegisterData, RegisterMap
from qcs_sdk.qvm.api import AddressRequest
from . import api
@typing.final
class QVMClient:
r"""
Client used to communicate with QVM.
"""
@property
def qvm_url(self) -> builtins.str:
r"""
Return the address of the client.
"""
def __new__(cls) -> QVMClient: ...
@staticmethod
def new_http(endpoint: builtins.str) -> QVMClient:
r"""
Construct a new QVM client which uses HTTP to communicate with a QVM service.
"""
@staticmethod
def new_libquil() -> QVMClient: ...
class QVMError(QcsSdkError):
r"""
Errors that can occur when running a Quil program on QVM.
"""
...
@typing.final
class QVMOptions:
r"""
Options avaialable for running programs on the QVM.
"""
@property
def timeout(self) -> typing.Optional[builtins.float]:
r"""
The timeout used for requests to the QVM. If set to None, there is no timeout.
"""
@timeout.setter
def timeout(self, value: typing.Optional[builtins.float]) -> None:
r"""
The timeout used for requests to the QVM. If set to None, there is no timeout.
"""
def __new__(cls, timeout_seconds: typing.Optional[builtins.float] = None) -> QVMOptions: ...
def __repr__(self) -> builtins.str:
r"""
Implements `__repr__` for Python in terms of the Rust
[`Debug`](std::fmt::Debug) implementation.
"""
@staticmethod
def default() -> QVMOptions:
r"""
Get the default set of ``QVMOptions`` used for QVM requests.
Settings:
timeout: 30.0 seconds
"""
@typing.final
class QVMResultData:
r"""
Encapsulates data returned after running a program on the QVM
"""
@property
def memory(self) -> builtins.dict[builtins.str, RegisterData]:
r"""
A map of register names (ie. "ro") to a `RegisterData` containing their values.
"""
def __getnewargs__(self) -> tuple[builtins.dict[builtins.str, RegisterData]]: ...
def __new__(cls, memory: typing.Mapping[builtins.str, RegisterData]) -> QVMResultData:
r"""
Build a ``QVMResultData`` from a mapping of register names to a ``RegisterData`` matrix.
"""
def __repr__(self) -> builtins.str:
r"""
Implements `__repr__` for Python in terms of the Rust
[`Debug`](std::fmt::Debug) implementation.
"""
@staticmethod
def from_memory_map(memory: typing.Mapping[builtins.str, RegisterData]) -> QVMResultData:
r"""
Build a [`QvmResultData`] from a mapping of register names to a [`RegisterData`]
"""
def to_raw_readout_data(self) -> RawQVMReadoutData:
r"""
Get a copy of this result data flattened into a ``RawQVMReadoutData``.
"""
def to_register_map(self) -> RegisterMap:
r"""
Convert into a [`RegisterMap`].
The [`RegisterMatrix`] for each register will be
constructed such that each row contains all the final values in the register for a single shot.
# Errors
Returns a [`RegisterMatrixConversionError`] if the inner execution data for any of the
registers would result in a jagged matrix.
This is often the case in programs that use mid-circuit measurement or dynamic control flow,
where measurements to the same memory reference might occur multiple times in a shot, or be
skipped conditionally. In these cases, building a rectangular [`RegisterMatrix`] would
necessitate making assumptions about the data that could skew the data in undesirable ways.
Instead, it's recommended to manually build a matrix from [`QpuResultData`] that accurately
selects the last value per-shot based on the program that was run.
"""
@typing.final
class RawQVMReadoutData:
r"""
Encapsulates raw data returned from the QVM after executing a program.
"""
@property
def memory(self) -> builtins.dict[builtins.str, list]:
r"""
The mapping of register names (ie. "ro") to a 2-d list containing the
values for that register.
"""
def __repr__(self) -> builtins.str:
r"""
Implements `__repr__` for Python in terms of the Rust
[`Debug`](std::fmt::Debug) implementation.
"""
def run(quil: builtins.str, shots: builtins.int, addresses: typing.Mapping[builtins.str, AddressRequest], params: typing.Mapping[builtins.str, typing.Sequence[builtins.float]], client: QVMClient, measurement_noise: typing.Optional[tuple[builtins.float, builtins.float, builtins.float]] = None, gate_noise: typing.Optional[tuple[builtins.float, builtins.float, builtins.float]] = None, rng_seed: typing.Optional[builtins.int] = None, options: typing.Optional[QVMOptions] = None) -> QVMResultData:
r"""
Runs the given program on the QVM.
:param quil: A quil program as a string.
:param shots: The number of times to run the program. Should be a value greater than zero.
:param addresses: A mapping of memory region names to an ``AddressRequest`` describing what data to get back for that memory region from the QVM at the end of execution.
:param params: A mapping of memory region names to their desired values.
:param client: An optional ``QCSClient`` to use. If unset, creates one using the environemnt configuration (see https://docs.rigetti.com/qcs/references/qcs-client-configuration).
:param options: An optional ``QVMOptions`` to use. If unset, uses ``QVMOptions.default()`` for the request.
:returns: A ``QVMResultData`` containing the final state of of memory for the requested readouts after the program finished running.
:raises QVMError: If one of the parameters is invalid, or if there was a problem communicating with the QVM server.
"""
def run_async(quil: builtins.str, shots: builtins.int, addresses: typing.Mapping[builtins.str, AddressRequest], params: typing.Mapping[builtins.str, typing.Sequence[builtins.float]], client: QVMClient, measurement_noise: typing.Optional[tuple[builtins.float, builtins.float, builtins.float]] = None, gate_noise: typing.Optional[tuple[builtins.float, builtins.float, builtins.float]] = None, rng_seed: typing.Optional[builtins.int] = None, options: typing.Optional[QVMOptions] = None) -> collections.abc.Awaitable[QVMResultData]:
r"""
Runs the given program on the QVM.
:param quil: A quil program as a string.
:param shots: The number of times to run the program. Should be a value greater than zero.
:param addresses: A mapping of memory region names to an ``AddressRequest`` describing what data to get back for that memory region from the QVM at the end of execution.
:param params: A mapping of memory region names to their desired values.
:param client: An optional ``QCSClient`` to use. If unset, creates one using the environemnt configuration (see https://docs.rigetti.com/qcs/references/qcs-client-configuration).
:param options: An optional ``QVMOptions`` to use. If unset, uses ``QVMOptions.default()`` for the request.
:returns: A ``QVMResultData`` containing the final state of of memory for the requested readouts after the program finished running.
:raises QVMError: If one of the parameters is invalid, or if there was a problem communicating with the QVM server.
"""