diff --git a/src/qibo/backends/numpy.py b/src/qibo/backends/numpy.py index 67de27b2f3..d99fc873d0 100644 --- a/src/qibo/backends/numpy.py +++ b/src/qibo/backends/numpy.py @@ -440,7 +440,11 @@ def execute_circuit_repeated(self, circuit, initial_state=None, nshots=None): if not circuit.density_matrix: samples = [] - probabilities = np.zeros(2**nqubits, dtype=float) + target_qubits = [ + measurement.target_qubits for measurement in circuit.measurements + ] + target_qubits = sum(target_qubits, tuple()) + probabilities = np.zeros(2 ** len(target_qubits), dtype=float) probabilities = self.cast(probabilities, dtype=probabilities.dtype) for _ in range(nshots):