@@ -31,14 +31,15 @@ def random_clifford_circuit_with_mid_measurement(num_qubits, depth):
3131 gate_name = np .random .choice (clifford_one_qubit_gates )
3232 getattr (c , gate_name )(j )
3333 operation_list .append ((gate_name , (j ,)))
34- measured_qubit = np .random .randint (0 , num_qubits - 1 )
35- sample , p = c .measure_reference (measured_qubit , with_prob = True )
36- # Check if there is a non-zero probability to measure "0" for post-selection
37- if (sample == "0" and not np .isclose (p , 0.0 )) or (
38- sample == "1" and not np .isclose (p , 1.0 )
39- ):
40- c .mid_measurement (measured_qubit , keep = 0 )
41- operation_list .append (("M" , (measured_qubit ,)))
34+ if np .random .uniform () < 0.2 :
35+ measured_qubit = np .random .randint (0 , num_qubits - 1 )
36+ sample , p = c .measure_reference (measured_qubit , with_prob = True )
37+ # Check if there is a non-zero probability to measure "0" for post-selection
38+ if (sample == "0" and not np .isclose (p , 0.0 )) or (
39+ sample == "1" and not np .isclose (p , 1.0 )
40+ ):
41+ c .mid_measurement (measured_qubit , keep = 0 )
42+ operation_list .append (("M" , (measured_qubit ,)))
4243 return c , operation_list
4344
4445
@@ -117,9 +118,9 @@ def simulate_stim_circuit_with_mid_measurement(stim_circuit):
117118
118119if __name__ == "__main__" :
119120 # Number of qubits
120- num_qubits = 10
121+ num_qubits = 12
121122 # Depth of the circuit
122- depth = 30
123+ depth = 24
123124 # index list that is traced out to calculate the entanglement entropy
124125 cut = [i for i in range (num_qubits // 3 )]
125126
0 commit comments