1414)
1515
1616
17- def create_ghz_circuit (qubits ):
17+ def create_ghz_circuit (qubits , measurements : bool = False ):
1818 n = len (qubits )
1919 circuit = cirq .Circuit ()
2020
@@ -24,26 +24,41 @@ def create_ghz_circuit(qubits):
2424 # Step 2: CNOT chain from qubit i to i+1
2525 for i in range (n - 1 ):
2626 circuit .append (cirq .CNOT (qubits [i ], qubits [i + 1 ]))
27+ if measurements :
28+ circuit .append (cirq .measure (qubits [i ]))
29+ circuit .append (cirq .reset (qubits [i ]))
30+
31+ if measurements :
32+ circuit .append (cirq .measure (qubits [- 1 ]))
33+ circuit .append (cirq .reset (qubits [- 1 ]))
2734
2835 return circuit
2936
3037
3138@pytest .mark .parametrize (
32- "model,qubits" ,
39+ "model,qubits,measurements " ,
3340 [
34- (GeminiOneZoneNoiseModel (), None ),
41+ (GeminiOneZoneNoiseModel (), None ,False ),
42+ (
43+ GeminiOneZoneNoiseModelConflictGraphMoves (),
44+ cirq .GridQubit .rect (rows = 1 , cols = 2 ),
45+ False
46+ ),
47+ (GeminiTwoZoneNoiseModel (), None , False ),
48+ (GeminiOneZoneNoiseModel (), None , True ),
3549 (
3650 GeminiOneZoneNoiseModelConflictGraphMoves (),
3751 cirq .GridQubit .rect (rows = 1 , cols = 2 ),
52+ True
3853 ),
39- (GeminiTwoZoneNoiseModel (), None ),
54+ (GeminiTwoZoneNoiseModel (), None , True ),
4055 ],
4156)
42- def test_simple_model (model : cirq .NoiseModel , qubits ):
57+ def test_simple_model (model : cirq .NoiseModel , qubits , measurements : bool ):
4358 if qubits is None :
4459 qubits = cirq .LineQubit .range (2 )
4560
46- circuit = create_ghz_circuit (qubits )
61+ circuit = create_ghz_circuit (qubits , measurements = measurements )
4762
4863 with pytest .raises (ValueError ):
4964 # make sure only native gate set is supported
@@ -74,13 +89,25 @@ def test_simple_model(model: cirq.NoiseModel, qubits):
7489 for i in range (4 ):
7590 pops_bloqade [i ] += abs (ket [i ]) ** 2 / nshots
7691
77- for pops in (pops_bloqade , pops_cirq ):
78- assert math .isclose (pops [0 ], 0.5 , abs_tol = 1e-1 )
79- assert math .isclose (pops [3 ], 0.5 , abs_tol = 1e-1 )
80- assert math .isclose (pops [1 ], 0.0 , abs_tol = 1e-1 )
81- assert math .isclose (pops [2 ], 0.0 , abs_tol = 1e-1 )
82-
83- assert pops [0 ] < 0.5001
84- assert pops [3 ] < 0.5001
85- assert pops [1 ] >= 0.0
86- assert pops [2 ] >= 0.0
92+ if measurements is True :
93+ for pops in (pops_bloqade , pops_cirq ):
94+ assert math .isclose (pops [0 ], 1.0 , abs_tol = 1e-1 )
95+ assert math .isclose (pops [3 ], 0.0 , abs_tol = 1e-1 )
96+ assert math .isclose (pops [1 ], 0.0 , abs_tol = 1e-1 )
97+ assert math .isclose (pops [2 ], 0.0 , abs_tol = 1e-1 )
98+
99+ assert pops [0 ] > 0.99
100+ assert pops [3 ] >= 0.0
101+ assert pops [1 ] >= 0.0
102+ assert pops [2 ] >= 0.0
103+ else :
104+ for pops in (pops_bloqade , pops_cirq ):
105+ assert math .isclose (pops [0 ], 0.5 , abs_tol = 1e-1 )
106+ assert math .isclose (pops [3 ], 0.5 , abs_tol = 1e-1 )
107+ assert math .isclose (pops [1 ], 0.0 , abs_tol = 1e-1 )
108+ assert math .isclose (pops [2 ], 0.0 , abs_tol = 1e-1 )
109+
110+ assert pops [0 ] < 0.5001
111+ assert pops [3 ] < 0.5001
112+ assert pops [1 ] >= 0.0
113+ assert pops [2 ] >= 0.0
0 commit comments