Skip to content

Commit

Permalink
Pulses now return lambdas
Browse files Browse the repository at this point in the history
  • Loading branch information
grahamrow committed Aug 16, 2017
1 parent 30168ef commit d4a2e38
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 8 deletions.
2 changes: 1 addition & 1 deletion QGL/ChannelLibrary.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ def load_from_library(self):
instr_dict = tmpLib['instruments']
qubit_dict = tmpLib['qubits']
filter_dict = tmpLib['filters']
trigger_dict = tmpLib['markers']
trigger_dict = {} #tmpLib['markers']
master_awgs = []

# Construct the channel library
Expand Down
5 changes: 5 additions & 0 deletions QGL/Compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,9 @@ def collect_specializations(seqs):
return funcs


def eval_deferred_pulses(seqs):
return [[pulse() for pulse in seq] for seq in seqs]

def compile_to_hardware(seqs,
fileName,
suffix='',
Expand All @@ -314,6 +317,8 @@ def compile_to_hardware(seqs,
'''
logger.debug("Compiling %d sequence(s)", len(seqs))

# Expand the

# save input code to file
save_code(seqs, fileName + suffix)

Expand Down
14 changes: 7 additions & 7 deletions QGL/PulsePrimitives.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def Id(channel, *args, **kwargs):
if len(args) > 0 and isinstance(args[0], (int, float)):
params['length'] = args[0]

return TAPulse("Id",
return lambda: TAPulse("Id",
channel,
params['length'],
0,
Expand Down Expand Up @@ -109,7 +109,7 @@ def Utheta(qubit,
else:
# linearly scale based upon the 'pi/2' amplitude
amp = (angle / pi/2) * qubit.pulse_params['pi2Amp']
return Pulse(label, qubit, params, amp, phase, 0.0, ignoredStrParams)
return lambda: Pulse(label, qubit, params, amp, phase, 0.0, ignoredStrParams)


# generic pulses around X, Y, and Z axes
Expand Down Expand Up @@ -137,7 +137,7 @@ def Ztheta(qubit,
ignoredStrParams=['amp', 'phase', 'length'],
**kwargs):
# special cased because it can be done with a frame update
return TAPulse(label,
return lambda: TAPulse(label,
qubit,
length=0,
amp=0,
Expand Down Expand Up @@ -333,7 +333,7 @@ def arb_axis_drag(qubit,
params['rotAngle'] = rotAngle
params['polarAngle'] = polarAngle
params['shape_fun'] = PulseShapes.arb_axis_drag
return Pulse(kwargs["label"] if "label" in kwargs else "ArbAxis", qubit,
return lambda: Pulse(kwargs["label"] if "label" in kwargs else "ArbAxis", qubit,
params, 1.0, aziAngle, frameChange)


Expand Down Expand Up @@ -742,7 +742,7 @@ def MEAS(qubit, **kwargs):
ignoredStrParams = ['phase', 'frameChange']
if 'amp' not in kwargs:
ignoredStrParams.append('amp')
return Pulse("MEAS", measChan, params, amp, 0.0, 0.0, ignoredStrParams)
return lambda: Pulse("MEAS", measChan, params, amp, 0.0, 0.0, ignoredStrParams)


#MEAS and ring-down time on one qubit, echo on every other
Expand Down Expand Up @@ -776,12 +776,12 @@ def MeasEcho(qM, qD, delay, piShift=None, phase=0):

# Gating/blanking pulse primitives
def BLANK(chan, length):
return TAPulse("BLANK", chan.gate_chan, length, 1, 0, 0)
return lambda: TAPulse("BLANK", chan.gate_chan, length, 1, 0, 0)

def TRIG(marker_chan, length):
'''TRIG(marker_chan, length) generates a trigger output of amplitude 1 on
a LogicalMarkerChannel.
'''
if not isinstance(marker_chan, Channels.LogicalMarkerChannel):
raise ValueError("TRIG pulses can only be generated on LogicalMarkerChannels.")
return TAPulse("TRIG", marker_chan, length, 1.0, 0., 0.)
return lambda: TAPulse("TRIG", marker_chan, length, 1.0, 0., 0.)

0 comments on commit d4a2e38

Please sign in to comment.