Skip to content
Open
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
41 changes: 41 additions & 0 deletions team-solutions/the-rydbergs/1.1.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
from bloqade import move
from math import pi

def main_builder(off_st: int, off_gt: int):
@move.vmove
def kernel():
q = move.NewQubitRegister(3)

indices = [off_st + 0, off_st + 1, off_st + 2]
qubits = [q[0], q[1], q[2]]
state = move.Init(qubits=qubits, indices=indices)

state.gate[[off_gt + 0,off_gt + 1,off_gt + 2]] = move.Move(state.storage[[off_st + 0,off_st + 1,off_st + 2]])

state = move.core.GlobalCZ(state)

state = move.LocalXY(atom_state=state, x_exponent=0.5 * pi, axis_phase_exponent=0.5 * pi, indices=[off_gt + 1])
state = move.GlobalRz(atom_state=state, phi = 0.5*pi)

state.storage[[off_st + 0]] = move.Move(state.gate[[off_gt + 0]])

state = move.GlobalCZ(state)

state = move.LocalXY(atom_state=state, x_exponent=0.5 * pi, axis_phase_exponent=0.5 * pi, indices=[off_gt + 1])
state = move.GlobalRz(atom_state=state, phi = 0.5*pi)

move.Execute(state)
return kernel

from iquhack_scoring import MoveScorer

# off_st = 20, off_gt = 6
# scores = []
# for off_st in range(21, 26):
# row_scores = []
# for off_gt in range(0, 18, 2):
# score = MoveScorer(main_builder(off_st, off_gt)).score()
# row_scores.append(score)
# scores.append(row_scores)

print(MoveScorer(main_builder(23, 8)).score())
69 changes: 69 additions & 0 deletions team-solutions/the-rydbergs/1.2.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
from bloqade import move
from math import pi

def main_builder(off_st: int, off_gt: int):
@move.vmove
def kernel():
q = move.NewQubitRegister(3)
qubits = [q[0], q[1], q[2]]
indices = [off_st + 0, off_st + 1, off_st + 2]

state = move.Init(qubits=qubits, indices=indices)

# 1
state.gate[[off_gt + 0, off_gt + 1, off_gt + 3]] = move.Move(state.storage[[off_st + 0, off_st + 1, off_st + 2]])
state = move.LocalXY(atom_state=state, x_exponent=-1.0*pi, axis_phase_exponent=1.0*pi, indices = [off_gt + 1])
state = move.LocalXY(atom_state=state, x_exponent=pi, axis_phase_exponent=0.0*pi, indices = [off_gt + 1])
# 2
state = move.GlobalCZ(atom_state=state)
# 3
state = move.LocalXY(atom_state=state, x_exponent=-0.75*pi, axis_phase_exponent=1.0*pi, indices = [off_gt + 1])
state = move.LocalXY(atom_state=state, x_exponent=pi, axis_phase_exponent=0.0*pi, indices = [off_gt + 1])
# 4
state.gate[[off_gt + 2]] = move.Move(state.gate[[off_gt + 1]])
state = move.GlobalCZ(atom_state=state)
# 5
state = move.LocalXY(atom_state=state, x_exponent=-0.75*pi, axis_phase_exponent=0.0*pi, indices = [off_gt + 2])
state = move.LocalXY(atom_state=state, x_exponent=pi, axis_phase_exponent=1.0*pi, indices = [off_gt + 2])
# 6
state.gate[[off_gt + 1]] = move.Move(state.gate[[off_gt + 2]])
state = move.GlobalCZ(atom_state=state)
# 7
state = move.LocalXY(atom_state=state, x_exponent=-0.5*pi, axis_phase_exponent=0.75*pi, indices = [off_gt + 0])
state = move.LocalXY(atom_state=state, x_exponent=-0.75*pi, axis_phase_exponent=1.0*pi, indices = [off_gt + 1])
state = move.LocalXY(atom_state=state, x_exponent=1.00*pi, axis_phase_exponent=0.125*pi, indices = [off_gt + 0])
state = move.LocalXY(atom_state=state, x_exponent=pi, axis_phase_exponent=0.0*pi, indices = [off_gt + 1])
# 8
state.gate[[off_gt + 2]] = move.Move(state.gate[[off_gt + 1]])
state = move.GlobalCZ(atom_state=state)
# 9
state.gate[[off_gt + 1]] = move.Move(state.gate[[off_gt + 3]])
state = move.GlobalCZ(atom_state=state)
# 10
state = move.LocalXY(atom_state=state, x_exponent=-0.75*pi, axis_phase_exponent=0.0*pi, indices = [off_gt + 2])
state = move.LocalXY(atom_state=state, x_exponent=1.0*pi, axis_phase_exponent=1.0*pi, indices = [off_gt + 2])

state = move.LocalRz(atom_state=state, phi = 0.25*pi, indices = [off_gt + 1])
state = move.LocalXY(atom_state=state, x_exponent=-0.75*pi, axis_phase_exponent=1.0*pi, indices = [off_gt + 0])
state = move.LocalXY(atom_state=state, x_exponent=1.0*pi, axis_phase_exponent=0.0*pi, indices = [off_gt + 0])
# 11
state = move.GlobalCZ(atom_state=state)
# 12
state = move.LocalXY(atom_state=state, x_exponent=0.5*pi, axis_phase_exponent=-0.5*pi, indices = [off_gt + 0])
state = move.LocalXY(atom_state=state, x_exponent=pi, axis_phase_exponent=0.0*pi, indices = [off_gt + 0])

move.Execute(state)
return kernel

from iquhack_scoring import MoveScorer

# scores = []
# for off_st in range(22, 25):
# row_scores = []
# for off_gt in range(0, 17, 2):
# score = MoveScorer(main_builder(off_st, off_gt)).score()
# row_scores.append(score)
# scores.append(row_scores)
# print('\n'.join(['\t'.join([str(score['overall']) for score in row]) for row in scores]))

print(MoveScorer(main_builder(23, 8)).score())
76 changes: 76 additions & 0 deletions team-solutions/the-rydbergs/2.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
from iquhack_scoring import MoveScorer
from bloqade import move
from math import pi
from kirin.passes import aggressive

@move.vmove()
def local_double_xy_rotation(state:move.core.AtomState, a, b, c, d, indices) -> move.core.AtomState:
state = move.LocalXY(atom_state=state,x_exponent=a,axis_phase_exponent=b,indices = indices)
state = move.LocalXY(atom_state=state,x_exponent=c,axis_phase_exponent=d,indices = indices)

return state

@move.vmove()
def local_z_rotation(state:move.core.AtomState, a, indices)-> move.core.AtomState:
state = move.LocalRz(atom_state=state,phi=a,indices=indices)

@move.vmove()
def circ2():
q = move.NewQubitRegister(3)
qubits = [q[0], q[1], q[2]]
indices = [2, 1, 0]

state = move.Init(qubits=qubits, indices=indices)

state.gate[[0, 1]] = move.Move(state.storage[[0, 1]])

state = local_double_xy_rotation(state, -1.0*pi, 2.97, 1.0*pi, -0.955, [1])
state = local_double_xy_rotation(state, -1.26, 0.0, 1.0*pi, 0.5*pi, [0])

state = move.core.GlobalCZ(state)

state = move.LocalXY(atom_state=state,x_exponent=1.0*pi,axis_phase_exponent=0.25*pi,indices = [1])
state = local_double_xy_rotation(state, -0.75*pi, 0.0, 1.0*pi, -0.25*pi, [])

state = move.core.GlobalCZ(state)

state = local_double_xy_rotation(state, -0.25*pi, 0.0, 1.0*pi, -0.5*pi, [0])
state = local_double_xy_rotation(state, -2.44, 0.5*pi, 1.0*pi, -0.25*pi, [1])

state.storage[[1]] = move.Move(state.gate[[1]])

state.gate[[1]] = move.Move(state.storage[[2]])
# state.gate[[]]

state = move.core.GlobalCZ(state)

state = local_double_xy_rotation(state, -0.875*pi, 1.0*pi, 1.0*pi, 0.0, [1])

state = move.core.GlobalCZ(state)

# state = local_double_xy_rotation(state, 0.5*pi, 0.5*pi, 1.0*pi, 0.0, [1])

state.storage[[2]] = move.Move(state.gate[[1]])
state.gate[[1]] = move.Move(state.storage[[1]])

state = move.core.GlobalCZ(state)

state = local_double_xy_rotation(state, -0.75*pi, 1.0*pi, 1.0*pi, 0.0, [1])

state = move.core.GlobalCZ(state)

state.gate[[0]] = move.Move(state.storage[[1]])

state = move.GlobalXY(atom_state=state,x_exponent=0.5*pi,axis_phase_exponent=-0.5*pi)

state = move.GlobalXY(atom_state=state,x_exponent=1.0*pi,axis_phase_exponent=0.0*pi)

move.Execute(state)

aggressive.Fold(move.vmove)(circ2)

analysis = MoveScorer(circ2)
print(analysis.score())

# ani.save("log_depth_GHZ.mp4")
# plt.show()
167 changes: 167 additions & 0 deletions team-solutions/the-rydbergs/3.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,167 @@
from bloqade import move
from math import pi


def main_builder(off_st: int, off_gt: int):
@move.vmove
def kernel():
q = move.NewQubitRegister(4)
qubits = [q[0], q[1], q[2], q[3]]
indices = [off_st + 0, off_st + 1, off_st + 2, off_st + 3]

state = move.Init(qubits=qubits, indices=indices)

state = move.GlobalXY(atom_state=state,x_exponent=-0.5*pi,axis_phase_exponent=1.81)
state = move.GlobalXY(atom_state=state,x_exponent=1.0*pi,axis_phase_exponent=0.122)

state.gate[[off_gt + 0]] = move.Move(state.storage[[off_st + 0]])

state = move.LocalXY(atom_state=state, x_exponent=-0.5*pi, axis_phase_exponent=1.81*pi, indices = [off_gt + 0])
state = move.LocalXY(atom_state=state, x_exponent=1.0*pi, axis_phase_exponent=0.122*pi, indices = [off_gt + 0])

state.gate[[off_gt + 1]] = move.Move(state.storage[[off_st + 1]])

state = move.core.GlobalCZ(state)

state = move.LocalXY(atom_state=state, x_exponent=-2.9, axis_phase_exponent=1.0*pi, indices=[off_gt + 1])
state = move.LocalXY(atom_state=state, x_exponent=1.0*pi, axis_phase_exponent=0.0, indices=[off_gt + 1])

state = move.core.GlobalCZ(state)
state = move.LocalXY(atom_state=state, x_exponent=0.5*pi, axis_phase_exponent=-0.5*pi, indices=[off_gt + 1])

state.storage[[off_st + 1]] = move.Move(state.gate[[off_gt + 1]])
state.gate[[off_gt + 1]] = move.Move(state.storage[[off_st + 2]])

state = move.core.GlobalCZ(state)

state = move.LocalXY(atom_state=state, x_exponent=-2.9, axis_phase_exponent=1.0*pi, indices=[off_gt + 1])
state = move.LocalXY(atom_state=state, x_exponent=1.0*pi, axis_phase_exponent=0.0, indices=[off_gt + 1])

state = move.core.GlobalCZ(state)

state.gate[[off_gt + 2]] = move.Move(state.storage[[off_st + 1]])
state = move.LocalXY(atom_state=state, x_exponent=pi, axis_phase_exponent=0.0, indices=[off_gt + 2])
state = move.LocalXY(atom_state=state, x_exponent=-2.9, axis_phase_exponent=0.0, indices=[off_gt + 1])

state.storage[[off_st + 2]] = move.Move(state.gate[[off_gt + 1]])
state.storage[[off_st + 1]] = move.Move(state.gate[[off_gt + 2]])
state.gate[[off_gt + 1]] = move.Move(state.storage[[off_st + 3]])

state = move.core.GlobalCZ(state)

state = move.LocalXY(atom_state=state, x_exponent=0.555, axis_phase_exponent=0.0, indices=[off_gt + 0])
state = move.LocalXY(atom_state=state, x_exponent=-2.9, axis_phase_exponent=0.0, indices=[off_gt + 1])

state.storage[[off_st + 0]] = move.Move(state.gate[[off_gt + 0]])
state.storage[[off_st + 3]] = move.Move(state.gate[[off_gt + 1]])
state.gate[[off_gt + 0]] = move.Move(state.storage[[off_st + 1]])
state.gate[[off_gt + 1]] = move.Move(state.storage[[off_st + 2]])

state = move.LocalXY(atom_state=state, x_exponent=1.0*pi, axis_phase_exponent=0.0, indices=[off_gt + 1])
state = move.core.GlobalCZ(state)
state = move.LocalXY(atom_state=state, x_exponent=0.5*pi, axis_phase_exponent=-0.5*pi, indices = [off_gt + 1])
state.storage[[off_st + 2]] = move.Move(state.gate[[off_gt + 1]])
state.gate[[off_gt + 1]] = move.Move(state.storage[[off_st + 3]])
state = move.core.GlobalCZ(state)
state.gate[[off_gt + 2]] = move.Move(state.storage[[off_st + 2]])
state = move.LocalXY(atom_state=state, x_exponent=1.0*pi, axis_phase_exponent=0.0, indices = [off_gt + 2])
state.storage[[off_st + 2]] = move.Move(state.gate[[off_gt + 2]])
state = move.LocalXY(atom_state=state, x_exponent=-2.9, axis_phase_exponent=1.0*pi, indices=[off_gt + 1])
state = move.LocalXY(atom_state=state, x_exponent=1.0*pi, axis_phase_exponent=0.0, indices=[off_gt + 1])
state = move.core.GlobalCZ(state)
state = move.LocalXY(atom_state=state, x_exponent=-1.8, axis_phase_exponent=1.96, indices=[off_gt + 0])
state = move.LocalXY(atom_state=state, x_exponent=-2.9, axis_phase_exponent=0.0, indices=[off_gt + 1])
state = move.LocalXY(atom_state=state, x_exponent=1.0*pi, axis_phase_exponent=-0.06, indices=[off_gt + 0])
state = move.LocalXY(atom_state=state, x_exponent=1.0*pi, axis_phase_exponent=1.0*pi, indices=[off_gt + 1])
state.storage[[off_st + 3]] = move.Move(state.gate[[off_gt + 1]])
state.gate[[off_gt + 1]] = move.Move(state.storage[[off_st + 0]])
state = move.core.GlobalCZ(state)
state.storage[[off_st + 0]] = move.Move(state.gate[[off_gt + 1]])
state.storage[[off_st + 1]] = move.Move(state.gate[[off_gt + 0]])
state.gate[[off_gt + 0]] = move.Move(state.storage[[off_st + 2]])
state.gate[[off_gt + 1]] = move.Move(state.storage[[off_st + 3]])
state = move.core.GlobalCZ(state)
state = move.LocalXY(atom_state=state, x_exponent=-2.9, axis_phase_exponent=1.0*pi, indices=[off_gt + 1])
state = move.LocalXY(atom_state=state, x_exponent=1.0*pi, axis_phase_exponent=0.0, indices=[off_gt + 1])
state = move.core.GlobalCZ(state)
state.storage[[off_st + 2]] = move.Move(state.gate[[off_gt + 0]])
state.storage[[off_st + 3]] = move.Move(state.gate[[off_gt + 1]])
state.gate[[off_gt + 0]] = move.Move(state.storage[[off_st + 0]])
state.gate[[off_gt + 1]] = move.Move(state.storage[[off_st + 1]])
state = move.LocalXY(atom_state=state, x_exponent=-2.69, axis_phase_exponent=1.0*pi, indices=[off_gt + 1])
state = move.LocalXY(atom_state=state, x_exponent=1.0*pi, axis_phase_exponent=0.0, indices=[off_gt + 1])
state = move.core.GlobalCZ(state)
state = move.LocalXY(atom_state=state, x_exponent=0.5*pi, axis_phase_exponent=-0.5*pi, indices=[off_gt + 1])
state = move.LocalXY(atom_state=state, x_exponent=1.0*pi, axis_phase_exponent=0.0, indices=[off_gt + 1])
state.storage[[off_st + 1]] = move.Move(state.gate[[off_gt + 1]])
state.gate[[off_gt + 1]] = move.Move(state.storage[[off_st + 2]])
state = move.LocalXY(atom_state=state, x_exponent=-1.8, axis_phase_exponent=1.962, indices=[off_gt + 1])
state = move.LocalXY(atom_state=state, x_exponent=1.0*pi, axis_phase_exponent=-0.06, indices=[off_gt + 1])
state = move.core.GlobalCZ(state)
state = move.LocalXY(atom_state=state, x_exponent=-2.69, axis_phase_exponent=1.0*pi, indices=[off_gt + 1])
state = move.LocalXY(atom_state=state, x_exponent=1.0*pi, axis_phase_exponent=0.0, indices=[off_gt + 1])
state = move.core.GlobalCZ(state)
state = move.LocalXY(atom_state=state, x_exponent=-2.69, axis_phase_exponent=0.0, indices=[off_gt + 1])
state.storage[[off_st + 2]] = move.Move(state.gate[[off_gt + 1]])
state.gate[[off_gt + 1]] = move.Move(state.storage[[off_st + 3]])
state = move.LocalXY(atom_state=state, x_exponent=-2.69, axis_phase_exponent=0.555, indices=[off_gt + 1])
state = move.LocalXY(atom_state=state, x_exponent=1.0*pi, axis_phase_exponent=2.86, indices=[off_gt + 1])
state = move.core.GlobalCZ(state)
state.storage[[off_st + 3]] = move.Move(state.gate[[off_gt + 1]])
state.gate[[off_gt + 1]] = move.Move(state.storage[[off_st + 2]])
state = move.LocalXY(atom_state=state, x_exponent=1.0*pi, axis_phase_exponent=1.0*pi, indices=[off_gt + 1])
state.storage[[off_st + 0]] = move.Move(state.gate[[off_gt + 0]])
state.gate[[off_gt + 0]] = move.Move(state.storage[[off_st + 1]])
state = move.core.GlobalCZ(state)
state = move.LocalXY(atom_state=state, x_exponent=-2.69, axis_phase_exponent=1.0*pi, indices=[off_gt + 1])
state.storage[[off_st + 1]] = move.Move(state.gate[[off_gt + 0]])
state.storage[[off_st + 2]] = move.Move(state.gate[[off_gt + 1]])
state.gate[[off_gt + 0]] = move.Move(state.storage[[off_st + 0]])
state.gate[[off_gt + 1]] = move.Move(state.storage[[off_st + 3]])
state = move.core.GlobalCZ(state)
state = move.LocalXY(atom_state=state, x_exponent=0.293, axis_phase_exponent=0.0, indices=[off_gt + 0])
state = move.LocalXY(atom_state=state, x_exponent=-2.69, axis_phase_exponent=0.0, indices=[off_gt + 1])
state.gate[[off_gt + 2]] = move.Move(state.storage[[off_st + 2]])
state = move.LocalXY(atom_state=state, x_exponent=1.0*pi, axis_phase_exponent=0.0, indices=[off_gt + 2])
state.storage[[off_st + 0]] = move.Move(state.gate[[off_gt + 0]])
state = move.LocalXY(atom_state=state, x_exponent=1.0*pi, axis_phase_exponent=1.0*pi, indices=[off_gt + 1])
state.storage[[off_st + 3]] = move.Move(state.gate[[off_gt + 1]])
state.gate[[off_gt + 1]] = move.Move(state.storage[[off_st + 1]])
state = move.core.GlobalCZ(state)
state = move.LocalXY(atom_state=state, x_exponent=0.5*pi, axis_phase_exponent=-0.5*pi, indices=[off_gt + 2])
state.storage[[off_st + 2]] = move.Move(state.gate[[off_gt + 2]])
state.gate[[off_gt + 2]] = move.Move(state.storage[[off_st + 3]])
state = move.core.GlobalCZ(state)
state.gate[[off_gt + 0]] = move.Move(state.storage[[off_st + 2]])
state = move.LocalXY(atom_state=state, x_exponent=1.0*pi, axis_phase_exponent=0.0, indices=[off_gt + 0])
state.storage[[off_st + 2]] = move.Move(state.gate[[off_gt + 0]])
state = move.LocalXY(atom_state=state, x_exponent=-2.69, axis_phase_exponent=1.0*pi, indices=[off_gt + 2])
state = move.LocalXY(atom_state=state, x_exponent=1.0*pi, axis_phase_exponent=0.0, indices=[off_gt + 2])
state = move.core.GlobalCZ(state)
state = move.LocalXY(atom_state=state, x_exponent=0.293, axis_phase_exponent=0.0, indices=[off_gt + 1])
state.storage[[off_st + 1]] = move.Move(state.gate[[off_gt + 1]])
state.gate[[off_gt + 1]] = move.Move(state.storage[[off_st + 2]])
state = move.LocalXY(atom_state=state, x_exponent=-2.69, axis_phase_exponent=0.0, indices=[off_gt + 2])
state = move.LocalXY(atom_state=state, x_exponent=1.0*pi, axis_phase_exponent=1.0*pi, indices=[off_gt + 2])
state = move.core.GlobalCZ(state)
state = move.LocalXY(atom_state=state, x_exponent=-2.69, axis_phase_exponent=1.0*pi, indices=[off_gt + 2])
state = move.LocalXY(atom_state=state, x_exponent=1.0*pi, axis_phase_exponent=0.0, indices=[off_gt + 2])
state = move.core.GlobalCZ(state)
state = move.LocalXY(atom_state=state, x_exponent=0.293, axis_phase_exponent=0.0, indices=[off_gt + 1])
state = move.LocalXY(atom_state=state, x_exponent=-0.5*pi, axis_phase_exponent=2.13, indices=[off_gt + 2])
state = move.LocalXY(atom_state=state, x_exponent=1.0*pi, axis_phase_exponent=-0.278, indices=[off_gt + 2])

move.Execute(state)
return kernel

from iquhack_scoring import MoveScorer

# scores = []
# for off_st in range(20, 23):
# row_scores = []
# for off_gt in range(0, 18, 2):
# score = MoveScorer(main_builder(off_st, off_gt)).score()
# row_scores.append(score)
# scores.append(row_scores)

print(MoveScorer(main_builder(21, 8)).score())
Loading