Execution
expectation(x, observable, values={}, state=None, backend=BackendName.PYQTORCH, diff_mode=None, noise=None, endianness=Endianness.BIG, configuration=None)
Convenience wrapper for the QuantumModel.expectation
method.
PARAMETER | DESCRIPTION |
---|---|
x |
Circuit, block, or (register+block) to run.
TYPE:
|
observable |
Observable(s) w.r.t. which the expectation is computed.
TYPE:
|
values |
User-facing parameter dict.
TYPE:
|
state |
Initial state.
TYPE:
|
backend |
Name of the backend to run on.
TYPE:
|
diff_mode |
Which differentiation mode to use.
TYPE:
|
endianness |
The target device endianness.
TYPE:
|
configuration |
The backend configuration.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Tensor
|
A wavefunction |
from qadence import RX, Z, Register, QuantumCircuit, expectation
reg = Register(1)
block = RX(0, 0.5)
observable = Z(0)
circ = QuantumCircuit(reg, block)
# You can compute the expectation for a
# QuantumCircuit with a given observable.
expectation(circ, observable)
# You can also use only a block.
# In this case the register is constructed automatically to
# Register.line(block.n_qubits)
expectation(block, observable)
# Or a register and block
expectation(reg, block, observable)
Source code in qadence/execution.py
run(x, *args, values={}, state=None, backend=BackendName.PYQTORCH, endianness=Endianness.BIG, configuration=None)
Convenience wrapper for the QuantumModel.run
method.
This is a
functools.singledispatch
ed function so it can be called with a number of different arguments.
See the examples of the expectation
function. This function
works exactly the same.
PARAMETER | DESCRIPTION |
---|---|
x |
Circuit, block, or (register+block) to run.
TYPE:
|
values |
User-facing parameter dict.
TYPE:
|
state |
Initial state.
TYPE:
|
backend |
Name of the backend to run on.
TYPE:
|
endianness |
The target device endianness.
TYPE:
|
configuration |
The backend configuration.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Tensor
|
A wavefunction |
Source code in qadence/execution.py
sample(x, *args, values={}, state=None, n_shots=100, backend=BackendName.PYQTORCH, endianness=Endianness.BIG, noise=None, configuration=None)
Convenience wrapper for the QuantumModel.sample
method.
PARAMETER | DESCRIPTION |
---|---|
x |
Circuit, block, or (register+block) to run.
TYPE:
|
values |
User-facing parameter dict.
TYPE:
|
state |
Initial state.
TYPE:
|
n_shots |
Number of shots per element in the batch.
TYPE:
|
backend |
Name of the backend to run on.
TYPE:
|
endianness |
The target device endianness.
TYPE:
|
noise |
The noise model to use if any.
TYPE:
|
configuration |
The backend configuration.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
list[Counter]
|
A list of Counter instances with the sample results |