pub struct BackendWrapper {
    pub internal: Backend,
}
Expand description

AQT backend

provides functions to run circuits and measurements on AQT devices.

Fields§

§internal: Backend

Internal storage of roqoqo_aqt::Backend

Implementations§

source§

impl BackendWrapper

source

pub fn new(device: &PyAny, access_token: Option<String>) -> PyResult<Self>

Create a new AQT Backend.

Args: device (Device): AQT Device providing information about the endpoint running Circuits. access_token (Optionalstr): Optional access token to AQT endpoints. When None access token is read from $AQT_ACCESS_TOKEN environmental variable

Raises: TypeError: Device Parameter is not AqtDevice RuntimeError: No access token found

source

pub fn to_aqt_json(&self, circuit: &PyAny) -> PyResult<String>

Create an AQT json represenstaion of a Circuit.

Args: circuit (Circuit): The circuit that is translated to a AQT json.

Returns: str: The output registers written by the evaluated circuits.

Raises: TypeError: Circuit argument cannot be converted to qoqo Circuit RuntimeError: Translating Circuit failed

source

pub fn __copy__(&self) -> BackendWrapper

Return a copy of the Backend (copy here produces a deepcopy).

Returns: Backend: A deep copy of self.

source

pub fn __deepcopy__(&self, _memodict: Py<PyAny>) -> BackendWrapper

Return a deep copy of the Backend.

Returns: Backend: A deep copy of self.

source

pub fn to_bincode(&self) -> PyResult<Py<PyByteArray>>

Return the bincode representation of the Backend using the bincode crate.

Returns: ByteArray: The serialized Backend (in bincode form).

Raises: ValueError: Cannot serialize Backend to bytes.

source

pub fn from_bincode(input: &PyAny) -> PyResult<BackendWrapper>

Convert the bincode representation of the Backend to a Backend using the bincode crate.

Args: input (ByteArray): The serialized Backend (in bincode form).

Returns: Backend: The deserialized Backend.

Raises: TypeError: Input cannot be converted to byte array. ValueError: Input cannot be deserialized to Backend.

source

pub fn run_circuit( &self, circuit: &PyAny ) -> PyResult<(HashMap<String, BitOutputRegister>, HashMap<String, FloatOutputRegister>, HashMap<String, ComplexOutputRegister>)>

Run a circuit with the AQT backend.

A circuit is passed to the backend and executed. During execution values are written to and read from classical registers (Listbool, List[float], List[complex]). To produce sufficient statistics for evaluating expectation values, circuits have to be run multiple times. The results of each repetition are concatenated in OutputRegisters (List[Listbool], List[List[float]], List[List[complex]]).

Args: circuit (Circuit): The circuit that is run on the backend.

Returns: Tuple[Dict[str, List[Listbool]], Dict[str, List[List[float]]]], Dict[str, List[List[complex]]]]: The output registers written by the evaluated circuits.

Raises: TypeError: Circuit argument cannot be converted to qoqo Circuit RuntimeError: Running Circuit failed

source

pub fn run_measurement_registers( &self, measurement: &PyAny ) -> PyResult<(HashMap<String, BitOutputRegister>, HashMap<String, FloatOutputRegister>, HashMap<String, ComplexOutputRegister>)>

Run all circuits corresponding to one measurement with the AQT backend.

An expectation value measurement in general involves several circuits. Each circuit is passes to the backend and executed separately. A circuit is passed to the backend and executed. During execution values are written to and read from classical registers (Listbool, List[float], List[complex]). To produce sufficient statistics for evaluating expectation values, circuits have to be run multiple times. The results of each repetition are concatenated in OutputRegisters (List[Listbool], List[List[float]], List[List[complex]]).

Args: measurement (Measurement): The measurement that is run on the backend.

Returns: Tuple[Dict[str, List[Listbool]], Dict[str, List[List[float]]]], Dict[str, List[List[complex]]]]: The output registers written by the evaluated circuits.

Raises: TypeError: Circuit argument cannot be converted to qoqo Circuit RuntimeError: Running Circuit failed

source

pub fn run_measurement( &self, measurement: &PyAny ) -> PyResult<Option<HashMap<String, f64>>>

Evaluates expectation values of a measurement with the backend.

Args: measurement (Measurement): The measurement that is run on the backend.

Returns: Optional[Dict[str, float]]: The dictionary of expectation values.

Raises: TypeError: Measurement evaluate function could not be used RuntimeError: Internal error measurement.evaluation returned unknown type

Trait Implementations§

source§

impl Clone for BackendWrapper

source§

fn clone(&self) -> BackendWrapper

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for BackendWrapper

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl IntoPy<Py<PyAny>> for BackendWrapper

source§

fn into_py(self, py: Python<'_>) -> PyObject

Performs the conversion.
source§

impl PartialEq for BackendWrapper

source§

fn eq(&self, other: &BackendWrapper) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl PyClass for BackendWrapper

§

type Frozen = False

Whether the pyclass is frozen. Read more
source§

impl PyClassImpl for BackendWrapper

source§

const IS_BASETYPE: bool = false

#[pyclass(subclass)]
source§

const IS_SUBCLASS: bool = false

#[pyclass(extends=…)]
source§

const IS_MAPPING: bool = false

#[pyclass(mapping)]
source§

const IS_SEQUENCE: bool = false

#[pyclass(sequence)]
§

type BaseType = PyAny

Base class
§

type ThreadChecker = SendablePyClass<BackendWrapper>

This handles following two situations: Read more
§

type Inventory = Pyo3MethodsInventoryForBackendWrapper

§

type PyClassMutability = <<PyAny as PyClassBaseType>::PyClassMutability as PyClassMutability>::MutableChild

Immutable or mutable
§

type Dict = PyClassDummySlot

Specify this class has #[pyclass(dict)] or not.
§

type WeakRef = PyClassDummySlot

Specify this class has #[pyclass(weakref)] or not.
§

type BaseNativeType = PyAny

The closest native ancestor. This is PyAny by default, and when you declare #[pyclass(extends=PyDict)], it’s PyDict.
source§

fn items_iter() -> PyClassItemsIter

source§

fn doc(py: Python<'_>) -> PyResult<&'static CStr>

Rendered class doc
source§

fn lazy_type_object() -> &'static LazyTypeObject<Self>

source§

fn dict_offset() -> Option<isize>

source§

fn weaklist_offset() -> Option<isize>

source§

impl PyClassNewTextSignature<BackendWrapper> for PyClassImplCollector<BackendWrapper>

source§

fn new_text_signature(self) -> Option<&'static str>

source§

impl<'a, 'py> PyFunctionArgument<'a, 'py> for &'a BackendWrapper

§

type Holder = Option<PyRef<'py, BackendWrapper>>

source§

fn extract(obj: &'py PyAny, holder: &'a mut Self::Holder) -> PyResult<Self>

source§

impl<'a, 'py> PyFunctionArgument<'a, 'py> for &'a mut BackendWrapper

§

type Holder = Option<PyRefMut<'py, BackendWrapper>>

source§

fn extract(obj: &'py PyAny, holder: &'a mut Self::Holder) -> PyResult<Self>

source§

impl PyTypeInfo for BackendWrapper

§

type AsRefTarget = PyCell<BackendWrapper>

Utility type to make Py::as_ref work.
source§

const NAME: &'static str = "Backend"

Class name.
source§

const MODULE: Option<&'static str> = _

Module name, if any.
source§

fn type_object_raw(py: Python<'_>) -> *mut PyTypeObject

Returns the PyTypeObject instance for this type.
source§

fn type_object(py: Python<'_>) -> &PyType

Returns the safe abstraction over the type object.
source§

fn is_type_of(object: &PyAny) -> bool

Checks if object is an instance of this type or a subclass of this type.
source§

fn is_exact_type_of(object: &PyAny) -> bool

Checks if object is an instance of this type.
source§

impl Eq for BackendWrapper

source§

impl StructuralPartialEq for BackendWrapper

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> DynClone for T
where T: Clone,

source§

fn __clone_box(&self, _: Private) -> *mut ()

source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<'a, T> FromPyObject<'a> for T
where T: PyClass + Clone,

source§

fn extract(obj: &'a PyAny) -> Result<T, PyErr>

Extracts Self from the source PyObject.
source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> PyErrArguments for T
where T: IntoPy<Py<PyAny>> + Send + Sync,

source§

fn arguments(self, py: Python<'_>) -> Py<PyAny>

Arguments for exception
source§

impl<T> Same for T

§

type Output = T

Should always be Self
source§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

source§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
source§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
source§

fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
source§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

source§

fn vzip(self) -> V

source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

impl<T> Scalar for T
where T: 'static + Clone + PartialEq + Debug,

source§

impl<T> Ungil for T
where T: Send,