Qadence 2 platforms abstract interfaces
AbstractInterface
Bases: ABC
, Generic[ArrayType, SequenceType, ParameterType, RunResultType, SampleResultType, ExpectationResultType]
An abstract base class that defines interface essential methods.
It should be inherited by any class that needs to implement a backend, for instance
pyqtorch
and fresnel1
(pulser
using qutip
emulator). It is not only used by
the package itself, but users who want to implement or test new backends should
also make use of it.
info
abstractmethod
property
Gives any relevant information about the interface data, such as device
,
register
, etc.
:return: dictionary with the relevant information.
sequence
abstractmethod
property
Outputs the backends-native sequence.
:return: The defined backends-native sequence.
draw(values)
abstractmethod
May draw the current sequence with the given values.
PARAMETER | DESCRIPTION |
---|---|
values
|
the values to be drawn
TYPE:
|
expectation(values=None, observable=None, **kwargs)
abstractmethod
Computes the expectation value for observable(s) given the parameters (values), and extra arguments.
:param values: dictionary of user-input parameters
:param observable: list of observables
:param kwargs: any extra argument that are backends specific can be included in the
child method
:return: any result type according to what is expected by the backends expectation
method
Source code in qadence2_platforms/abstracts.py
parameters()
abstractmethod
Get the parameters from the backend as an iterable.
RETURNS | DESCRIPTION |
---|---|
Iterable[Any]
|
Parameters as an iterable. |
run(values=None, **kwargs)
abstractmethod
Gets the results from the expression computation given the parameters (values), and extra arguments.
:param values: dictionary of user-input parameters
:param kwargs: any extra argument that are backends specific can be included in the
child method.
:return: any result type according to what is expected by the backends run
method
Source code in qadence2_platforms/abstracts.py
sample(values=None, shots=None, **kwargs)
abstractmethod
Samples the computed result given the expression, the parameters (values), number of shots, and extra arguments.
:param values: dictionary of user-input parameters
:param shots: number of shots
:param kwargs: any extra argument that are backends specific can be included in the
child method
:return: any result type according to what is expected by the backends sample
method
Source code in qadence2_platforms/abstracts.py
set_parameters(params)
abstractmethod
Sets valid parameters for the backends to use it during simulation/execution step.
:param params: the fixed parameters to be used by the backends.
Source code in qadence2_platforms/abstracts.py
OnEnum
Bases: Enum
Enum class to be used whenever an Interface class method (such as run
) needs to
specify where to run the code: on emulator or qpu.
RunEnum
Bases: Enum
Enum class to be used whenever an Interface class method need to specify
how to execute the expression: through run
, sample
, or expectation
.