Skip to content

Commit

Permalink
Pack cal description into the axis_descriptor.
Browse files Browse the repository at this point in the history
  • Loading branch information
blakejohnson committed Aug 9, 2016
1 parent 4d1fa25 commit 5f43e1b
Show file tree
Hide file tree
Showing 6 changed files with 81 additions and 56 deletions.
46 changes: 28 additions & 18 deletions QGL/BasicSequences/CR.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,10 @@ def PiRabi(controlQ,
create_cal_seqs([targetQ,controlQ], calRepeats, measChans=(targetQ,controlQ))

fileNames = compile_to_hardware(seqs, 'PiRabi/PiRabi',
axis_descriptor=time_descriptor(lengths),
cal_descriptor=cal_descriptor((controlQ, targetQ), calRepeats, len(lengths)+1))
axis_descriptor=[
time_descriptor(lengths),
cal_descriptor((controlQ, targetQ), calRepeats)
])
print(fileNames)

if showPlot:
Expand Down Expand Up @@ -73,8 +75,10 @@ def EchoCRLen(controlQ,
for l in lengths] + create_cal_seqs((targetQ,controlQ), calRepeats, measChans=(targetQ,controlQ))

fileNames = compile_to_hardware(seqs, 'EchoCR/EchoCR',
axis_descriptor=time_descriptor(lengths),
cal_descriptor=cal_descriptor((controlQ, targetQ), calRepeats, len(lengths)+1))
axis_descriptor=[
time_descriptor(lengths),
cal_descriptor((controlQ, targetQ), calRepeats)
])
print(fileNames)

if showPlot:
Expand Down Expand Up @@ -107,15 +111,18 @@ def EchoCRPhase(controlQ,
for ph in phases]+[[X(controlQ)] + echoCR(controlQ, targetQ, length=length, phase= ph, riseFall = riseFall) + [X90(targetQ)*X(controlQ), MEAS(targetQ)*MEAS(controlQ)]\
for ph in phases]+create_cal_seqs((targetQ,controlQ), calRepeats, measChans=(targetQ,controlQ))

axis_descriptor = [{
'name': 'phase',
'unit': 'radians',
'points': list(phases)
}]
axis_descriptor = [
{
'name': 'phase',
'unit': 'radians',
'points': list(phases),
'partition': 1
},
cal_descriptor((controlQ, targetQ), calRepeats)
]

fileNames = compile_to_hardware(seqs, 'EchoCR/EchoCR',
axis_descriptor=axis_descriptor,
cal_descriptor=cal_descriptor((controlQ, targetQ), calRepeats, len(phases)+1))
axis_descriptor=axis_descriptor)
print(fileNames)

if showPlot:
Expand Down Expand Up @@ -148,15 +155,18 @@ def EchoCRAmp(controlQ,
for a in amps]+ [[X(controlQ)] + echoCR(controlQ, targetQ, length=length, phase= phase, riseFall=riseFall,amp=a) + [X(controlQ), MEAS(targetQ)*MEAS(controlQ)]\
for a in amps] + create_cal_seqs((targetQ,controlQ), calRepeats, measChans=(targetQ,controlQ))

axis_descriptor = [{
'name': 'amplitude',
'unit': None,
'points': list(amps)
}]
axis_descriptor = [
{
'name': 'amplitude',
'unit': None,
'points': list(amps),
'partition': 1
},
cal_descriptor((controlQ, targetQ), calRepeats)
]

fileNames = compile_to_hardware(seqs, 'EchoCR/EchoCR',
axis_descriptor=axis_descriptor,
cal_descriptor=cal_descriptor((controlQ, targetQ), calRepeats, len(amps)+1))
axis_descriptor=axis_descriptor)
print(fileNames)

if showPlot:
Expand Down
12 changes: 8 additions & 4 deletions QGL/BasicSequences/Decoupling.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,10 @@ def HahnEcho(qubit, pulseSpacings, periods=0, calRepeats=2, showPlot=False):
seqs += create_cal_seqs((qubit, ), calRepeats)

fileNames = compile_to_hardware(seqs, 'Echo/Echo',
axis_descriptor=time_descriptor(2 * pulseSpacings),
cal_descriptor=cal_descriptor((qubit,), calRepeats, len(pulseSpacings)+1))
axis_descriptor=[
time_descriptor(2 * pulseSpacings),
cal_descriptor((qubit,), calRepeats)
])
print(fileNames)

if showPlot:
Expand Down Expand Up @@ -66,8 +68,10 @@ def CPMG(qubit, numPulses, pulseSpacing, calRepeats=2, showPlot=False):
seqs += create_cal_seqs((qubit, ), calRepeats)

fileNames = compile_to_hardware(seqs, 'CPMG/CPMG',
axis_descriptor=time_descriptor(pulseSpacing * numPulses),
cal_descriptor=cal_descriptor((qubit,), calRepeats, len(numPulses)+1))
axis_descriptor=[
time_descriptor(pulseSpacing * numPulses),
cal_descriptor((qubit,), calRepeats)
])
print(fileNames)

if showPlot:
Expand Down
36 changes: 22 additions & 14 deletions QGL/BasicSequences/Rabi.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ def RabiAmp(qubit, amps, phase=0, showPlot=False):
axis_descriptor = [{
'name': 'amplitude',
'unit': None,
'points': list(amps)
'points': list(amps),
'partition': 1
}]

fileNames = compile_to_hardware(seqs, 'Rabi/Rabi', axis_descriptor=axis_descriptor)
Expand Down Expand Up @@ -66,7 +67,7 @@ def RabiWidth(qubit,
shapeFun=shapeFun), MEAS(qubit)] for l in widths]

fileNames = compile_to_hardware(seqs, 'Rabi/Rabi',
axis_descriptor=time_descriptor(widths))
axis_descriptor=[time_descriptor(widths)])
print(fileNames)

if showPlot:
Expand Down Expand Up @@ -108,15 +109,18 @@ def RabiAmp_NQubits(qubits,
if docals:
seqs += create_cal_seqs(qubits, calRepeats, measChans=measChans)

axis_descriptor = [{
'name': 'amplitude',
'unit': None,
'points': list(amps)
}]
axis_descriptor = [
{
'name': 'amplitude',
'unit': None,
'points': list(amps),
'partition': 1
},
cal_descriptor(qubits, calRepeats)
]

fileNames = compile_to_hardware(seqs, 'Rabi/Rabi',
axis_descriptor=axis_descriptor,
cal_descriptor=cal_descriptor(qubits, calRepeats, len(amps)+1))
axis_descriptor=axis_descriptor)
print(fileNames)

if showPlot:
Expand Down Expand Up @@ -145,7 +149,8 @@ def RabiAmpPi(qubit, mqubit, amps, phase=0, showPlot=False):
axis_descriptor = [{
'name': 'amplitude',
'unit': None,
'points': list(amps)
'points': list(amps),
'partition': 1
}]

fileNames = compile_to_hardware(seqs, 'Rabi/Rabi', axis_descriptor=axis_descriptor)
Expand All @@ -164,8 +169,9 @@ def SingleShot(qubit, showPlot=False):

axis_descriptor = {
'name': 'state',
'unit': None,
'points': [0, 1]
'unit': 'state',
'points': ["0", "1"],
'partition': 1
}

filenames = compile_to_hardware(seqs, 'SingleShot/SingleShot')
Expand Down Expand Up @@ -210,8 +216,10 @@ def Swap(qubit, mqubit, delays, showPlot=False):
measChans=(mqubit, qubit))

fileNames = compile_to_hardware(seqs, 'Rabi/Rabi',
time_descriptor=time_descriptor(delays),
cal_descriptor=cal_descriptor((mqubit, qubit), 2, len(delays)+1))
axis_descriptor=[
time_descriptor(delays),
cal_descriptor((mqubit, qubit), 2)
])
print(fileNames)

if showPlot:
Expand Down
12 changes: 8 additions & 4 deletions QGL/BasicSequences/T1T2.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,10 @@ def InversionRecovery(qubit,

fileNames = compile_to_hardware(seqs,
'T1' + ('_' + qubit.label) * suffix + '/T1' + ('_' + qubit.label) * suffix,
axis_descriptor=time_descriptor(delays),
cal_descriptor=cal_descriptor((qubit,), calRepeats, len(delays)+1))
axis_descriptor=[
time_descriptor(delays),
cal_descriptor((qubit,), calRepeats)
])
print(fileNames)

if showPlot:
Expand Down Expand Up @@ -75,8 +77,10 @@ def Ramsey(qubit,

fileNames = compile_to_hardware(seqs,
'Ramsey' + ('_' + qubit.label) * suffix + '/Ramsey' + ('_' + qubit.label) * suffix,
axis_descriptor=time_descriptor(pulseSpacings),
cal_descriptor=cal_descriptor((qubit,), calRepeats, len(pulseSpacings)+1))
axis_descriptor=[
time_descriptor(pulseSpacings),
cal_descriptor((qubit,), calRepeats)
])
print(fileNames)

if showPlot:
Expand Down
21 changes: 13 additions & 8 deletions QGL/BasicSequences/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,18 @@ def create_cal_seqs(qubits, numRepeats, measChans=None, waitcmp=False):
return [[seq, measBlock, qwait('CMP')] if waitcmp else [seq, measBlock]
for seq in calSeqs]

def cal_descriptor(qubits, numRepeats, startIdx):
def cal_descriptor(qubits, numRepeats):
states = ['0', '1']
# generate state set in same order as we do above in create_cal_seqs()
state_set = [reduce(operator.add, s) for s in product(states, repeat=len(qubits))]
descriptor = {}
cal_range = range(startIdx, startIdx + numRepeats*len(state_set))
for ct, state in enumerate(state_set):
descriptor[state] = list(cal_range[ct*numRepeats : (ct+1)*numRepeats])
descriptor = {
'name': 'calibration',
'unit': 'state',
'partition': 2,
'points': []
}
for state in state_set:
descriptor['points'] += [state] * numRepeats
return descriptor

def time_descriptor(times, desired_units="us"):
Expand All @@ -50,9 +54,10 @@ def time_descriptor(times, desired_units="us"):
scale = 1e6
elif desired_units == "ns":
scale = 1e9
axis_descriptor = [{
axis_descriptor = {
'name': 'time',
'unit': desired_units,
'points': list(scale * times)
}]
'points': list(scale * times),
'partition': 1
}
return axis_descriptor
10 changes: 2 additions & 8 deletions QGL/Compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,6 @@ def compile_to_hardware(seqs,
fileName,
suffix='',
axis_descriptor=None,
cal_descriptor=None,
qgl2=False,
addQGL2SlaveTrigger=False):
'''
Expand All @@ -300,8 +299,6 @@ def compile_to_hardware(seqs,
axes of the measurements that the sequence will yield. For instance,
if `seqs` generates a Ramsey experiment, axis_descriptor would describe
the time delays between pulses.
cal_descriptor (optional): a dictionary of labels and indices for calibration
experiments within `seqs`
qgl2 (optional): Launch compiler in QGL2 mode
'''
logger.debug("Compiling %d sequence(s)", len(seqs))
Expand Down Expand Up @@ -413,17 +410,14 @@ def compile_to_hardware(seqs,
axis_descriptor = [{
'name': 'segment',
'unit': None,
'points': list(range(1, 1 + num_measurements))
'points': list(range(1, 1 + num_measurements)),
'partition': 1
}]
if not cal_descriptor:
# contains a dictionary of states and a list of associated indices
cal_descriptor = {}
meta = {
'instruments': files,
'num_sequences': len(seqs),
'num_measurements': num_measurements,
'axis_descriptor': axis_descriptor,
'cal_descriptor': cal_descriptor
}
metafilepath = os.path.join(config.AWGDir, fileName + '-meta.json')
with open(metafilepath, 'w') as FID:
Expand Down

0 comments on commit 5f43e1b

Please sign in to comment.