7
7
from .utils import READOUT_BASIS
8
8
9
9
10
- def create_bell_circuit (nqubits , qubits , theta = np .pi / 4 , bell_state = 0 ):
10
+ def create_bell_circuit (theta = np .pi / 4 , bell_state = 0 ):
11
11
"""Creates the circuit to generate the bell states and with a theta-measurement
12
12
bell_state chooses the initial bell state for the test:
13
13
0 -> |00>+|11>
@@ -17,24 +17,24 @@ def create_bell_circuit(nqubits, qubits, theta=np.pi / 4, bell_state=0):
17
17
Native defaults to only using GPI2 and GPI gates.
18
18
"""
19
19
p = [0 , 0 ]
20
- c = Circuit (nqubits )
21
- c .add (gates .H (qubits [ 0 ] ))
22
- c .add (gates .H (qubits [ 1 ] ))
23
- c .add (gates .CZ (qubits [ 0 ], qubits [ 1 ] ))
24
- c .add (gates .H (qubits [ 1 ] ))
20
+ c = Circuit (2 )
21
+ c .add (gates .H (0 ))
22
+ c .add (gates .H (1 ))
23
+ c .add (gates .CZ (0 , 1 ))
24
+ c .add (gates .H (1 ))
25
25
if bell_state == 1 :
26
- c .add (gates .Z (qubits [ 0 ] ))
26
+ c .add (gates .Z (0 ))
27
27
elif bell_state == 2 :
28
- c .add (gates .Z (qubits [ 0 ] ))
29
- c .add (gates .X (qubits [ 0 ] ))
28
+ c .add (gates .Z (0 ))
29
+ c .add (gates .X (0 ))
30
30
elif bell_state == 3 :
31
- c .add (gates .X (qubits [ 0 ] ))
31
+ c .add (gates .X (0 ))
32
32
33
- c .add (gates .RY (qubits [ 0 ] , theta ))
33
+ c .add (gates .RY (0 , theta ))
34
34
return c , p
35
35
36
36
37
- def create_bell_circuit_native (nqubits , qubits , theta = np .pi / 4 , bell_state = 0 ):
37
+ def create_bell_circuit_native (theta = np .pi / 4 , bell_state = 0 ):
38
38
"""Creates the circuit to generate the bell states and with a theta-measurement
39
39
bell_state chooses the initial bell state for the test:
40
40
0 -> |00>+|11>
@@ -44,35 +44,33 @@ def create_bell_circuit_native(nqubits, qubits, theta=np.pi / 4, bell_state=0):
44
44
Native defaults to only using GPI2 and GPI gates.
45
45
"""
46
46
47
- c = Circuit (nqubits )
47
+ c = Circuit (2 )
48
48
p = [0 , 0 ]
49
- c .add (gates .GPI2 (qubits [ 0 ] , np .pi / 2 ))
50
- c .add (gates .GPI2 (qubits [ 1 ] , np .pi / 2 ))
51
- c .add (gates .CZ (qubits [ 0 ], qubits [ 1 ] ))
52
- c .add (gates .GPI2 (qubits [ 1 ] , - np .pi / 2 ))
49
+ c .add (gates .GPI2 (0 , np .pi / 2 ))
50
+ c .add (gates .GPI2 (1 , np .pi / 2 ))
51
+ c .add (gates .CZ (0 , 1 ))
52
+ c .add (gates .GPI2 (1 , - np .pi / 2 ))
53
53
if bell_state == 0 :
54
54
p [0 ] += np .pi
55
55
elif bell_state == 1 :
56
56
p [0 ] += 0
57
57
elif bell_state == 2 :
58
58
p [0 ] += 0
59
- c .add (gates .GPI2 (qubits [ 0 ] , p [0 ]))
60
- c .add (gates .GPI2 (qubits [ 0 ] , p [0 ]))
59
+ c .add (gates .GPI2 (0 , p [0 ]))
60
+ c .add (gates .GPI2 (0 , p [0 ]))
61
61
elif bell_state == 3 :
62
62
p [0 ] += np .pi
63
- c .add (gates .GPI2 (qubits [ 0 ] , p [0 ]))
64
- c .add (gates .GPI2 (qubits [ 0 ] , p [0 ]))
63
+ c .add (gates .GPI2 (0 , p [0 ]))
64
+ c .add (gates .GPI2 (0 , p [0 ]))
65
65
66
- c .add (gates .GPI2 (qubits [ 0 ] , p [0 ]))
66
+ c .add (gates .GPI2 (0 , p [0 ]))
67
67
p [0 ] += theta
68
- c .add (gates .GPI2 (qubits [ 0 ] , p [0 ] + np .pi ))
68
+ c .add (gates .GPI2 (0 , p [0 ] + np .pi ))
69
69
70
70
return c , p
71
71
72
72
73
73
def create_chsh_circuits (
74
- platform ,
75
- qubits ,
76
74
theta = np .pi / 4 ,
77
75
bell_state = 0 ,
78
76
native = True ,
@@ -84,15 +82,14 @@ def create_chsh_circuits(
84
82
"""
85
83
create_bell = create_bell_circuit_native if native else create_bell_circuit
86
84
chsh_circuits = {}
87
- nqubits = platform .nqubits if platform else max (qubits ) + 1
88
85
for basis in readout_basis :
89
- c , p = create_bell (nqubits , qubits , theta , bell_state )
86
+ c , p = create_bell (theta , bell_state )
90
87
for i , base in enumerate (basis ):
91
88
if base == "X" :
92
89
if native :
93
- c .add (gates .GPI2 (qubits [ i ] , p [i ] + np .pi / 2 ))
90
+ c .add (gates .GPI2 (i , p [i ] + np .pi / 2 ))
94
91
else :
95
- c .add (gates .H (qubits [ i ] ))
96
- c .add (gates .M (* qubits ))
92
+ c .add (gates .H (i ))
93
+ c .add (gates .M (0 , 1 ))
97
94
chsh_circuits [basis ] = c
98
95
return chsh_circuits
0 commit comments