qrisp.batched_measurement#
- batched_measurement(variables, backend, shots=None)[source]#
This functions facilitates the measurement of multiple QuantumVariables with a BatchedBackend.
- Parameters:
- variableslist[QuantumVariable]
A list of QuantumVariables.
- backendBatchedBackend
The backend to evaluate the compiled QuantumCircuits on.
- shotsint, optional
The amount of shots to perform. The default is given by the backend used.
- Returns:
- resultslist[dict]
The list of results.
Examples
We set up a BatchedBackend, which sequentially executes the QuantumCircuits on the Qrisp simulator.
from qrisp import * from qrisp.interface import BatchedBackend def run_func_batch(batch): # Parameters # ---------- # batch : list[tuple[QuantumCircuit, int]] # The circuit and shot batch indicating the backend queries. # Returns # ------- # results : list[dict[string, int]] # The list of results. results = [] for i in range(len(batch)): qc = batch[i][0] shots = batch[i][1] results.append(qc.run(shots = shots)) return results # Set up batched backend bb = BatchedBackend(run_func_batch) 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}]