Abstract backend
Backend
dataclass
Bases: ABC
The abstract class that defines the interface for the backends
ATTRIBUTE | DESCRIPTION |
---|---|
name |
backend unique string identifier
TYPE:
|
supports_ad |
whether or not the backend has a native autograd
TYPE:
|
supports_bp |
whether or not the backend has a native backprop
TYPE:
|
is_remote |
whether computations are executed locally or remotely on this backend, useful when using cloud platforms where credentials are needed for example.
TYPE:
|
with_measurements |
whether it supports counts or not
TYPE:
|
with_noise |
whether to add realistic noise or not
TYPE:
|
circuit(circuit)
abstractmethod
Converts an abstract QuantumCircuit
to the native backend representation.
PARAMETER | DESCRIPTION |
---|---|
circuit |
A circuit, for example:
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
ConvertedCircuit
|
A converted circuit |
ConvertedCircuit
|
and the converted (or backend native) circuit via |
Source code in qadence/backend.py
convert(circuit, observable=None)
Convert an abstract circuit (and optionally and observable) to their native representation. Additionally this function constructs an embedding function which maps from user-facing parameters to device parameters (read more on parameter embedding here).
Source code in qadence/backend.py
expectation(circuit, observable, param_values={}, state=None, protocol=None, endianness=Endianness.BIG)
abstractmethod
Compute the expectation value of the circuit
with the given observable
.
PARAMETER | DESCRIPTION |
---|---|
circuit |
A converted circuit as returned by
TYPE:
|
param_values |
Already embedded parameters of the circuit. See
TYPE:
|
state |
Initial state.
TYPE:
|
endianness |
Endianness of the resulting bitstrings.
TYPE:
|
Source code in qadence/backend.py
observable(observable, n_qubits)
abstractmethod
Converts an abstract observable (which is just an AbstractBlock
) to the native backend
representation.
PARAMETER | DESCRIPTION |
---|---|
observable |
An observable.
TYPE:
|
n_qubits |
Number of qubits the observable covers. This is typically
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
ConvertedObservable
|
A converted observable |
ConvertedObservable
|
|
Source code in qadence/backend.py
run(circuit, param_values={}, state=None, endianness=Endianness.BIG)
abstractmethod
Run a circuit and return the resulting wave function.
PARAMETER | DESCRIPTION |
---|---|
circuit |
A converted circuit as returned by
TYPE:
|
param_values |
Already embedded parameters of the circuit. See
TYPE:
|
state |
Initial state.
TYPE:
|
endianness |
Endianness of the resulting samples.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Tensor
|
A list of Counter objects where each key represents a bitstring |
Tensor
|
and its value the number of times it has been sampled from the given wave function. |
Source code in qadence/backend.py
sample(circuit, param_values={}, n_shots=1000, state=None, endianness=Endianness.BIG)
abstractmethod
Sample bit strings.
PARAMETER | DESCRIPTION |
---|---|
circuit |
A converted circuit as returned by
TYPE:
|
param_values |
Already embedded parameters of the circuit. See
TYPE:
|
n_shots |
Number of shots to sample.
TYPE:
|
state |
Initial state.
TYPE:
|
endianness |
Endianness of the resulting bitstrings.
TYPE:
|
Source code in qadence/backend.py
BackendConfiguration
dataclass
available_options()
Return as a string the available fields with types of the configuration
RETURNS | DESCRIPTION |
---|---|
str
|
a string with all the available fields, one per line
TYPE:
|
Source code in qadence/backend.py
get_param_name(blk)
Return parameter names for the current backend. Depending on which backend is in use this function returns either UUIDs or expressions of parameters.