Abstract backend
Backend(name, supports_ad, support_bp, supports_adjoint, is_remote, with_measurements, native_endianness, engine, with_noise, config)
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:
|
supports_adjoint |
Does the backend support native adjoint differentation.
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:
|
native_endianness |
The native endianness of the backend
TYPE:
|
engine |
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 |
---|---|
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 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 |
---|---|
ConvertedObservable
|
A converted observable |
ConvertedObservable
|
|
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 |
---|---|
ArrayLike
|
A list of Counter objects where each key represents a bitstring |
ArrayLike
|
and its value the number of times it has been sampled from the given wave function. |
Source code in qadence/backend.py
run_dm(circuit, noise, param_values={}, state=None, endianness=Endianness.BIG)
abstractmethod
Run a circuit and return the resulting the density matrix.
TODO: Temporary method for the purposes of noise model implementation. To be removed in a later refactoring.
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 density matrix.
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, 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.