Abstract backend
Backend(name, supports_ad, support_bp, supports_adjoint, is_remote, with_measurements, native_endianness, engine, with_noise, config)
dataclass
Bases:
The abstract class that defines the interface for the backends.
ATTRIBUTE | DESCRIPTION |
---|---|
|
backend unique string identifier
TYPE:
|
|
whether or not the backend has a native autograd
TYPE:
|
|
whether or not the backend has a native backprop
TYPE:
|
|
Does the backend support native adjoint differentation.
TYPE:
|
|
whether computations are executed locally or remotely on this backend, useful when using cloud platforms where credentials are needed for example.
TYPE:
|
|
whether it supports counts or not
TYPE:
|
|
whether to add realistic noise or not
TYPE:
|
|
The native endianness of the backend
TYPE:
|
|
The underlying (native) automatic differentiation engine of the backend.
TYPE:
|
circuit(circuit)
abstractmethod
Converts an abstract QuantumCircuit
to the native backend representation.
PARAMETER | DESCRIPTION |
---|---|
circuit |
A circuit, for example:
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
|
A converted circuit |
|
and the converted (or backend native) circuit via |
Source code in qadence/backend.py
convert(circuit, observable=None)
Convert an abstract circuit and an optional 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, measurement=None, noise=None, mitigation=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:
|
measurement |
Optional measurement protocol. If None, use exact expectation value with a statevector simulator.
TYPE:
|
noise |
A noise model to use.
TYPE:
|
endianness |
Endianness of the resulting bit strings.
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 |
---|---|
|
A converted observable |
|
|
Source code in qadence/backend.py
run(circuit, param_values={}, state=None, endianness=Endianness.BIG, *args, **kwargs)
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 wavefunction.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
|
A list of Counter objects where each key represents a bitstring |
|
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, noise=None, mitigation=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:
|
noise |
A noise model to use.
TYPE:
|
mitigation |
An error mitigation protocol to apply.
TYPE:
|
endianness |
Endianness of the resulting bit strings.
TYPE:
|
Source code in qadence/backend.py
BackendConfiguration(_use_gate_params=True, use_sparse_observable=False, use_gradient_checkpointing=False, use_single_qubit_composition=False, transpilation_passes=None)
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.