diff --git a/src/qibocal/protocols/two_qubit_interaction/chsh/circuits.py b/src/qibocal/protocols/two_qubit_interaction/chsh/circuits.py index ebad464e6..ba4859a68 100644 --- a/src/qibocal/protocols/two_qubit_interaction/chsh/circuits.py +++ b/src/qibocal/protocols/two_qubit_interaction/chsh/circuits.py @@ -7,7 +7,7 @@ from .utils import READOUT_BASIS -def create_bell_circuit(theta=np.pi / 4, bell_state=0): +def create_bell_circuit(bell_state=0): """Creates the circuit to generate the bell states and with a theta-measurement bell_state chooses the initial bell state for the test: 0 -> |00>+|11> @@ -32,7 +32,7 @@ def create_bell_circuit(theta=np.pi / 4, bell_state=0): return c -def create_bell_circuit_native(theta=np.pi / 4, bell_state=0): +def create_bell_circuit_native(bell_state=0): """Creates the circuit to generate the bell states and with a theta-measurement bell_state chooses the initial bell state for the test: 0 -> |00>+|11> @@ -43,30 +43,22 @@ def create_bell_circuit_native(theta=np.pi / 4, bell_state=0): """ c = Circuit(2) - p = [0, 0] c.add(gates.GPI2(0, np.pi / 2)) c.add(gates.GPI2(1, np.pi / 2)) c.add(gates.CZ(0, 1)) - c.add(gates.GPI2(1, np.pi / 2)) + c.add(gates.GPI2(1, -np.pi / 2)) - c.add(gates.GPI2(0, p[0])) if bell_state == 0: - p[0] += np.pi - elif bell_state == 1: - p[0] += 0 + c.add(gates.Z(0)) elif bell_state == 2: - p[0] += 0 - c.add(gates.GPI2(0, p[0])) - c.add(gates.GPI2(0, p[0])) + c.add(gates.GPI(0, 0)) elif bell_state == 3: - p[0] += np.pi - c.add(gates.GPI2(0, p[0])) - c.add(gates.GPI2(0, p[0])) + c.add(gates.Z(0)) + c.add(gates.GPI(0, 0)) - p[0] += theta - c.add(gates.GPI2(0, np.pi)) + c.add(gates.GPI2(0, 0)) - return c, p + return c def create_chsh_circuits( @@ -82,7 +74,7 @@ def create_chsh_circuits( create_bell = create_bell_circuit_native if native else create_bell_circuit chsh_circuits = {} for basis in readout_basis: - c = create_bell(theta, bell_state) + c = create_bell(bell_state) c.add(gates.RY(0, theta)) for i, base in enumerate(basis): if base == "X": diff --git a/src/qibocal/protocols/two_qubit_interaction/chsh/protocol.py b/src/qibocal/protocols/two_qubit_interaction/chsh/protocol.py index fe0913926..b78ba88d1 100644 --- a/src/qibocal/protocols/two_qubit_interaction/chsh/protocol.py +++ b/src/qibocal/protocols/two_qubit_interaction/chsh/protocol.py @@ -361,7 +361,8 @@ def _fit(data: CHSHData) -> CHSHResults: # mitigated_freq[format(j, f"0{2}b")].append(float(val)) # mitigated_freq_list.append(mitigated_freq) results[pair[0], pair[1], bell_state] = [ - compute_chsh(bell_pair_data, l) for l in range(len(data.thetas)) + compute_chsh(bell_pair_data, l, bell_state) + for l in range(len(data.thetas)) ] # if data.mitigation_matrix: diff --git a/src/qibocal/protocols/two_qubit_interaction/chsh/utils.py b/src/qibocal/protocols/two_qubit_interaction/chsh/utils.py index 9e98cb844..60f2e788c 100644 --- a/src/qibocal/protocols/two_qubit_interaction/chsh/utils.py +++ b/src/qibocal/protocols/two_qubit_interaction/chsh/utils.py @@ -3,7 +3,7 @@ READOUT_BASIS = ["ZZ", "ZX", "XZ", "XX"] -def compute_chsh(frequencies, i): +def compute_chsh(frequencies, i, bell_state): """Computes the chsh inequality out of the frequencies of the 4 circuits executed.""" zz = frequencies["ZZ"] @@ -17,5 +17,6 @@ def compute_chsh(frequencies, i): result_zx = zx["11"][i] + zx["00"][i] - zx["10"][i] - zx["01"][i] result_xz = xz["11"][i] + xz["00"][i] - xz["10"][i] - xz["01"][i] result_xx = xx["11"][i] + xx["00"][i] - xx["10"][i] - xx["01"][i] - - return (result_zz + result_xz - result_zx + result_xx) / nshots + if bell_state % 2 == 0: + return (result_zz + result_xz - result_zx + result_xx) / nshots + return (result_zz + result_xz + result_zx - result_xx) / nshots