batched_measurement#
- batched_measurement(variables, backend, shots=None)[source]#
Measure multiple QuantumVariables in a single batched execution using a
BatchedBackend.All
get_measurementcalls are collected first (returning lazy results immediately), thendispatch()is called once to execute every circuit and populate all results together.Deprecated since version 0.8:
batched_measurementis deprecated. You can callget_measurement()on each variable with aBatchedBackend, then calldispatch()directly instead:bb = backend.batched() r1 = qv1.get_measurement(backend=bb) r2 = qv2.get_measurement(backend=bb) bb.dispatch()
- Parameters:
- variableslist[QuantumVariable]
A list of QuantumVariables to measure.
- backend
BatchedBackend A batched backend obtained via
Backend.batched().- shotsint, optional
Number of shots. Defaults to the backend’s
shotsoption.
- Returns:
- resultslist[DecodedMeasurementResult]
One decoded result per variable, in the same order as variables.
Examples
from qrisp import QuantumFloat, batched_measurement from qrisp.default_backend import QrispSimulatorBackend bb = QrispSimulatorBackend().batched() a = QuantumFloat(4) b = QuantumFloat(3) a[:] = 1 b[:] = 2 c = a + b d = QuantumFloat(4) e = QuantumFloat(3) d[:] = 2 e[:] = 3 f = d + e batched_measurement([c, f], backend=bb) # Yields: [{3: 1.0}, {5: 1.0}]