Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generalizing Mermin to n qubits and adding theta angles for plot #1005

Draft
wants to merge 4 commits into
base: mermin
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 23 additions & 19 deletions src/qibocal/protocols/two_qubit_interaction/mermin/circuits.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from qibo import Circuit, gates


def create_mermin_circuit(qubits, native=True):
def create_mermin_circuit(qubits, native=True, theta=None):
"""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>
Expand All @@ -11,30 +11,34 @@ def create_mermin_circuit(qubits, native=True):
3 -> |10>+|01>
Native defaults to only using GPI2 and GPI gates.
"""
if not theta:
theta = ((n - 1) * 0.25 * np.pi) % (2 * np.pi)
# TODO: implement condition better
# if qubits[1] != 2:
# raise ValueError('The center qubit should be in qubits[1]!')
c = Circuit(len(qubits))
p = [0, 0, 0]
if native:
c.add(gates.GPI2(qubits[1], np.pi / 2))
c.add(gates.GPI2(qubits[0], np.pi / 2))
c.add(gates.CZ(qubits[1], qubits[0]))
c.add(gates.GPI2(qubits[0], -np.pi / 2))
c.add(gates.GPI2(qubits[2], np.pi / 2))
c.add(gates.CZ(qubits[1], qubits[2]))
c.add(gates.GPI2(qubits[2], -np.pi / 2))
p[0] -= np.pi / 2
# TODO: not hardcode connections
# Centermost qubit is qubits[0]
for i in range(len(qubits)):
c.add(gates.GPI2(qubits[i], np.pi / 2))
for i in range(1, len(qubits)):
c.add(gates.CZ(qubits[0], qubits[i]))
for i in range(1, len(qubits)):
c.add(gates.GPI2(qubits[i], -np.pi / 2))
p[0] -= theta

else:
c.add(gates.H(qubits[1]))
c.add(gates.H(qubits[0]))
c.add(gates.CZ(qubits[1], qubits[0]))
c.add(gates.H(qubits[0]))
c.add(gates.H(qubits[2]))
c.add(gates.CZ(qubits[1], qubits[2]))
c.add(gates.H(qubits[2]))
c.add(gates.S(0))
# TODO: not hardcode connections
# Centermost qubit is qubits[0]
for i in range(len(qubits)):
c.add(gates.H(qubits[i]))
for i in range(1, len(qubits)):
c.add(gates.CZ(qubits[0], qubits[i]))
for i in range(1, len(qubits)):
c.add(gates.H(qubits[i]))
c.add(gates.U1(0, theta))
return c, p


Expand All @@ -44,7 +48,7 @@ def create_mermin_circuits(qubits, readout_basis, native=True, rerr=None):
rerr adds a readout bitflip error to the simulation.
"""

mermin_circuits = []
mermin_circuits = {}

for basis in readout_basis:
c, p = create_mermin_circuit(qubits, native)
Expand All @@ -64,6 +68,6 @@ def create_mermin_circuits(qubits, readout_basis, native=True, rerr=None):
for qubit in qubits:
c.add(gates.M(qubit))
# c.add(gates.M(qubit, p0=rerr[0], p1=rerr[1]))
mermin_circuits.append(c)
mermin_circuits[basis] = c

return mermin_circuits
Loading
Loading