Skip to content

Commit

Permalink
Add cal_descriptor helper
Browse files Browse the repository at this point in the history
And use it in most of the basic sequences.
  • Loading branch information
blakejohnson committed Aug 2, 2016
1 parent 0e9c60b commit 248750d
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 20 deletions.
16 changes: 11 additions & 5 deletions QGL/BasicSequences/CR.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from ..Compiler import compile_to_hardware
from ..ChannelLibrary import EdgeFactory
from ..PulseSequencePlotter import plot_pulse_files
from .helpers import create_cal_seqs, time_descriptor
from .helpers import create_cal_seqs, time_descriptor, cal_descriptor


def PiRabi(controlQ,
Expand Down Expand Up @@ -38,7 +38,8 @@ def PiRabi(controlQ,
create_cal_seqs([targetQ,controlQ], calRepeats, measChans=(targetQ,controlQ))

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

if showPlot:
Expand Down Expand Up @@ -72,7 +73,8 @@ 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))
axis_descriptor=time_descriptor(lengths),
cal_descriptor=cal_descriptor((controlQ, targetQ), calRepeats, len(lengths)+1))
print(fileNames)

if showPlot:
Expand Down Expand Up @@ -111,7 +113,9 @@ def EchoCRPhase(controlQ,
'points': list(phases)
}

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

if showPlot:
Expand Down Expand Up @@ -150,7 +154,9 @@ def EchoCRAmp(controlQ,
'points': list(amps)
}

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

if showPlot:
Expand Down
8 changes: 5 additions & 3 deletions QGL/BasicSequences/Decoupling.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from ..PulsePrimitives import *
from ..Compiler import compile_to_hardware
from ..PulseSequencePlotter import plot_pulse_files
from .helpers import create_cal_seqs, time_descriptor
from .helpers import create_cal_seqs, time_descriptor, cal_descriptor


def HahnEcho(qubit, pulseSpacings, periods=0, calRepeats=2, showPlot=False):
Expand Down Expand Up @@ -29,7 +29,8 @@ 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))
axis_descriptor=time_descriptor(2 * pulseSpacings),
cal_descriptor=cal_descriptor((qubit,), calRepeats, len(pulseSpacings)+1))
print(fileNames)

if showPlot:
Expand Down Expand Up @@ -65,7 +66,8 @@ 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))
axis_descriptor=time_descriptor(pulseSpacing * numPulses),
cal_descriptor=cal_descriptor((qubit,), calRepeats, len(numPulses)+1))
print(fileNames)

if showPlot:
Expand Down
9 changes: 6 additions & 3 deletions QGL/BasicSequences/Rabi.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from ..Compiler import compile_to_hardware
from ..PulseSequencePlotter import plot_pulse_files
import QGL.PulseShapes
from .helpers import create_cal_seqs, time_descriptor
from .helpers import create_cal_seqs, time_descriptor, cal_descriptor
from functools import reduce


Expand Down Expand Up @@ -114,7 +114,9 @@ def RabiAmp_NQubits(qubits,
'points': list(amps)
}

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

if showPlot:
Expand Down Expand Up @@ -208,7 +210,8 @@ def Swap(qubit, mqubit, delays, showPlot=False):
measChans=(mqubit, qubit))

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

if showPlot:
Expand Down
18 changes: 9 additions & 9 deletions QGL/BasicSequences/T1T2.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from ..Compiler import compile_to_hardware
from ..PulseSequencePlotter import plot_pulse_files
from scipy.constants import pi
from .helpers import create_cal_seqs, time_descriptor
from .helpers import create_cal_seqs, time_descriptor, cal_descriptor


def InversionRecovery(qubit,
Expand Down Expand Up @@ -31,10 +31,10 @@ def InversionRecovery(qubit,
#Tack on the calibration scalings
seqs += create_cal_seqs((qubit, ), calRepeats)

fileNames = compile_to_hardware(seqs, 'T1' +
('_' + qubit.label) * suffix + '/T1' +
('_' + qubit.label) * suffix,
axis_descriptor=time_descriptor(delays))
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))
print(fileNames)

if showPlot:
Expand Down Expand Up @@ -73,10 +73,10 @@ def Ramsey(qubit,
#Tack on the calibration scalings
seqs += create_cal_seqs((qubit, ), calRepeats)

fileNames = compile_to_hardware(seqs, 'Ramsey' +
('_' + qubit.label) * suffix + '/Ramsey' +
('_' + qubit.label) * suffix,
axis_descriptor=time_descriptor(pulseSpacings))
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))
print(fileNames)

if showPlot:
Expand Down
6 changes: 6 additions & 0 deletions QGL/BasicSequences/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@ 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):
states = ['0', '1']
state_set = [reduce(operator.add, s) for s in product(states, repeat=len(qubits))]
descriptor = {state: startIdx + (ct * numRepeats) for ct, state in enumerate(state_set)}
return descriptor

def time_descriptor(times, desired_units="us"):
if desired_units == "s":
scale = 1
Expand Down

0 comments on commit 248750d

Please sign in to comment.