Skip to content

Commit

Permalink
Push frame change to edges in Compiler
Browse files Browse the repository at this point in the history
This should make it more generic, but it's still restricted to CR gates
  • Loading branch information
dieris committed Mar 31, 2016
1 parent 17f0c8f commit 1f07a3a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
12 changes: 12 additions & 0 deletions QGL/Compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,8 @@ def compile_sequence(seq, channels=None):
if len(wires[chan]) > 0:
wires[chan][-1] = copy(wires[chan][-1])
wires[chan][-1].frameChange += block.pulses[chan].frameChange
if isinstance(chan, Channels.Qubit):
wires = propagate_node_frame_to_edges(wires, chan, block.pulses[chan].frameChange)
else:
warn("Dropping initial frame change")
continue
Expand All @@ -362,6 +364,16 @@ def compile_sequence(seq, channels=None):

return wires

def propagate_node_frame_to_edges(wires, chan, frameChange):
'''
Propagate frame change in node to relevant edges (for CR gates)
'''
for predecessor in ChannelLibrary.channelLib.connectivityG.predecessors(chan):
edge = ChannelLibrary.channelLib.connectivityG.edge[predecessor][chan]['channel']
wires[edge][-1] = copy(wires[edge][-1])
wires[edge][-1].frameChange += frameChange
return wires

def find_unique_channels(seq):
channels = set([])
for step in flatten(seq):
Expand Down
7 changes: 1 addition & 6 deletions QGL/PulsePrimitives.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,7 @@ def Ytheta(qubit, amp=0, label='Ytheta', **kwargs):

def Ztheta(qubit, angle=0, label='Ztheta', **kwargs):
# special cased because it can be done with a frame update
Zprod = TAPulse(label, qubit, length=0, amp=0, phase=0, frameChange=-angle)
#shift the reference for all CR gates with qubit as the target
for predecessor in ChannelLibrary.channelLib.connectivityG.predecessors(qubit):
CRchan = ChannelLibrary.channelLib.connectivityG.edge[predecessor][qubit]['channel']
Zprod = Zprod*TAPulse(label, CRchan, length=0, amp=0, phase=0, frameChange=-angle)
return Zprod
return TAPulse(label, qubit, length=0, amp=0, phase=0, frameChange=-angle)

#Setup the default 90/180 rotations
# @_memoize
Expand Down

0 comments on commit 1f07a3a

Please sign in to comment.