DifferentiableBackend
DifferentiableBackend(backend, diff_mode=DiffMode.AD, **psr_args)
Bases: Module
A class to abstract the operations done by the autodiff engine
PARAMETER | DESCRIPTION |
---|---|
backend |
An instance of the QuantumBackend type perform execution.
TYPE:
|
diff_mode |
A differentiable mode supported by the differentiation engine.
TYPE:
|
**psr_args |
Arguments that will be passed on to
TYPE:
|
Source code in qadence/backends/pytorch_wrapper.py
expectation(circuit, observable, param_values={}, state=None, protocol=None, endianness=Endianness.BIG)
Compute the expectation value of a given observable.
PARAMETER | DESCRIPTION |
---|---|
circuit |
A backend native quantum circuit to be executed.
TYPE:
|
observable |
A backend native observable to compute the expectation value from.
TYPE:
|
param_values |
A dict of values for symbolic substitution.
TYPE:
|
state |
An initial state.
TYPE:
|
protocol |
A shot-based measurement protocol.
TYPE:
|
endianness |
Endianness of the state.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Tensor
|
A tensor of expectation values. |
Source code in qadence/backends/pytorch_wrapper.py
run(circuit, param_values={}, state=None, endianness=Endianness.BIG)
Run on the underlying backend.
Source code in qadence/backends/pytorch_wrapper.py
sample(circuit, param_values, state=None, n_shots=1, endianness=Endianness.BIG)
Sample bitstring from the registered circuit.
PARAMETER | DESCRIPTION |
---|---|
circuit |
A backend native quantum circuit to be executed.
TYPE:
|
param_values |
The values of the parameters after embedding
TYPE:
|
n_shots |
The number of shots. Defaults to 1.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
list[Counter]
|
An iterable with all the sampled bitstrings |
Source code in qadence/backends/pytorch_wrapper.py
DifferentiableExpectation
dataclass
A handler for differentiating expectation estimation using various engines.
construct_rules(circuit, observable, psr_fn, **psr_args)
staticmethod
Create a mapping between parameters and PSR functions.
Source code in qadence/backends/pytorch_wrapper.py
PSRExpectation
Bases: Function
Overloads the PyTorch AD system to perform parameter shift rule on quantum circuits.