def test_SPAM(self): q = QubitFactory('q1') qr = QRegister('q1') angleSweep = np.linspace(0, pi / 2, 11) maxSpamBlocks = 10 expectedseq = [] def spam_seqs(angle, q, maxSpamBlocks): thisseq = [] for rep in range(maxSpamBlocks): thisseq += [qwait(channels=(q, )), Y90(q)] innerseq = [] for _ in range(rep): innerseq += [ X(q), U(q, phase=pi / 2 + angle), X(q), U(q, phase=pi / 2 + angle) ] thisseq += innerseq thisseq += [X90(q), MEAS(q)] return thisseq for angle in angleSweep: expectedseq += [qwait(channels=(q, )), Id(q), MEAS(q)] expectedseq += spam_seqs(angle, q, maxSpamBlocks) expectedseq += [qwait(channels=(q, )), X(q), MEAS(q)] resFunction = compile_function( "src/python/qgl2/basic_sequences/SPAM.py", "SPAM", (qr, angleSweep, maxSpamBlocks)) seqs = resFunction() seqs = testable_sequence(seqs) assertPulseSequenceEqual(self, seqs, expectedseq)
def test_RabiAmp_NQubits(self): q1 = QubitFactory('q1') q2 = QubitFactory('q2') qr = QRegister(q1, q2) amps = np.linspace(0, 5e-6, 11) p = 0 docals = False calRepeats = 2 expectedseq = [] for a in amps: expectedseq += [ qwait(channels=(q1, q2)), Utheta(q1, amp=a, phase=p), Utheta(q2, amp=a, phase=p), Barrier(q1, q2), MEAS(q1), MEAS(q2) ] if docals: # Add calibration cal_seqs = get_cal_seqs_2qubits(q1, q2, calRepeats) expectedseq += cal_seqs expectedseq = testable_sequence(expectedseq) resFunction = compile_function( "src/python/qgl2/basic_sequences/Rabi.py", "RabiAmp_NQubits", (qr, amps, p, None, docals, calRepeats)) seqs = resFunction() seqs = testable_sequence(seqs) assertPulseSequenceEqual(self, seqs, expectedseq)
def test_Swap(self): q = QubitFactory('q1') mq = QubitFactory('q2') qr = QRegister(q) mqr = QRegister(mq) delays = np.linspace(0, 5e-6, 11) expectedseq = [] for d in delays: expectedseq += [ qwait(channels=(q, mq)), X(q), X(mq), Id(mq, length=d), Barrier(q, mq), MEAS(q), MEAS(mq) ] # Add calibration cal_seqs = get_cal_seqs_2qubits(q, mq, 2) expectedseq += cal_seqs expectedseq = testable_sequence(expectedseq) resFunction = compile_function( "src/python/qgl2/basic_sequences/Rabi.py", "Swap", (qr, delays, mqr)) seqs = resFunction() seqs = testable_sequence(seqs) assertPulseSequenceEqual(self, seqs, expectedseq)
def test_FlipFlop(self): qubit = QubitFactory('q1') qr = QRegister('q1') dragParamSweep = np.linspace(0, 1, 11) maxNumFFs = 10 def addFFSeqs(dragParam, maxNumFFs, qubit): ffs = [] for rep in range(maxNumFFs): ffs += [ qwait(channels=(qubit, )), X90(qubit, dragScaling=dragParam) ] for _ in range(rep): ffs += [ X90(qubit, dragScaling=dragParam), X90m(qubit, dragScaling=dragParam) ] ffs += [Y90(qubit, dragScaling=dragParam), MEAS(qubit)] return ffs expectedseq = [] for dragParam in dragParamSweep: expectedseq += [qwait(channels=(qubit, )), Id(qubit), MEAS(qubit)] expectedseq += addFFSeqs(dragParam, maxNumFFs, qubit) expectedseq += [qwait(channels=(qubit, )), X(qubit), MEAS(qubit)] resFunction = compile_function( "src/python/qgl2/basic_sequences/FlipFlop.py", "FlipFlop", (qr, dragParamSweep, maxNumFFs)) seqs = resFunction() seqs = testable_sequence(seqs) assertPulseSequenceEqual(self, seqs, expectedseq)
def FlipFlop(qubit: qreg, dragParamSweep, maxNumFFs=10, showPlot=False): """ Flip-flop sequence (X90-X90m)**n to determine off-resonance or DRAG parameter optimization. Parameters ---------- qubit : logical channel to implement sequence (LogicalChannel) dragParamSweep : drag parameter values to sweep over (iterable) maxNumFFs : maximum number of flip-flop pairs to do showPlot : whether to plot (boolean) """ # Original: # def flipflop_seqs(dragScaling): # """ Helper function to create a list of sequences with a specified drag parameter. """ # qubit.pulse_params['dragScaling'] = dragScaling # return [[X90(qubit)] + [X90(qubit), X90m(qubit)]*rep + [Y90(qubit)] for rep in range(maxNumFFs)] # # Insert an identity at the start of every set to mark them off # originalScaling = qubit.pulse_params['dragScaling'] # seqs = list(chain.from_iterable([[[Id(qubit)]] + flipflop_seqs(dragParam) for dragParam in dragParamSweep])) # qubit.pulse_params['dragScaling'] = originalScaling # # Add a final pi for reference # seqs.append([X(qubit)]) # # Add the measurment block to every sequence # measBlock = MEAS(qubit) # for seq in seqs: # seq.append(measBlock) # fileNames = compile_to_hardware(seqs, 'FlipFlop/FlipFlop') # print(fileNames) # if showPlot: # plot_pulse_files(fileNames) # Insert an identity at the start of every set to mark them off # Want a result something like: # [['Id'], ['X9', 'Y9'], ['X9', 'X9', 'X9m', 'Y9'], ['X9', 'X9', 'X9m', 'X9', 'X9m', 'Y9'], ['Id'], ['X9', 'Y9'], ['X9', 'X9', 'X9m', 'Y9'], ['X9', 'X9', 'X9m', 'X9', 'X9m', 'Y9'], ['Id'], ['X9', 'Y9'], ['X9', 'X9', 'X9m', 'Y9'], ['X9', 'X9', 'X9m', 'X9', 'X9m', 'Y9']] originalScaling = qubit.pulse_params['dragScaling'] for dragParam in dragParamSweep: init(qubit) Id(qubit) MEAS(qubit) # FIXME: Need original dragScaling? # FIXME: In original this was [[Id]] + flipflop - is this # right? flipflop_seqs(dragParam, maxNumFFs, qubit) qubit.pulse_params['dragScaling'] = originalScaling # Add a final pi for reference init(qubit) X(qubit) MEAS(qubit)
def test_PiRabi(self): controlQ = QubitFactory('q1') targetQ = QubitFactory('q2') controlQR = QRegister(controlQ) targetQR = QRegister(targetQ) edge = EdgeFactory(controlQ, targetQ) lengths = np.linspace(0, 4e-6, 11) riseFall = 40e-9 amp = 1 phase = 0 calRepeats = 2 expected_seq = [] # Seq1 for l in lengths: expected_seq += [ qwait(channels=(controlQ, targetQ)), Id(controlQ), flat_top_gaussian(edge, riseFall, length=l, amp=amp, phase=phase), Barrier(controlQ, targetQ), MEAS(controlQ), MEAS(targetQ) ] # Seq2 for l in lengths: expected_seq += [ qwait(channels=(controlQ, targetQ)), X(controlQ), flat_top_gaussian(edge, riseFall, length=l, amp=amp, phase=phase), X(controlQ), Barrier(controlQ, targetQ), MEAS(controlQ), MEAS(targetQ) ] # Add calibration calseq = get_cal_seqs_2qubits(controlQ, targetQ, calRepeats) expected_seq += calseq expected_seq = testable_sequence(expected_seq) resFunction = compile_function( "src/python/qgl2/basic_sequences/CR.py", "PiRabi", (controlQR, targetQR, lengths, riseFall, amp, phase, calRepeats)) seqs = resFunction() seqs = testable_sequence(seqs) self.maxDiff = None assertPulseSequenceEqual(self, seqs, expected_seq)
def doSingleShot(qubit: qreg): """ 2-segment sequence with qubit prepared in |0> and |1>, useful for single-shot fidelity measurements and kernel calibration """ init(qubit) Id(qubit) MEAS(qubit) init(qubit) X(qubit) MEAS(qubit)
def test_Ramsey(self): q = QubitFactory('q1') qr = QRegister('q1') delays = np.arange(100e-9, 10e-6, 100e-9) TPPIFreq = 1e6 calRepeats = 2 expectedseq = [] # Create the phases for the TPPI phases = 2 * pi * TPPIFreq * delays # Create the basic Ramsey sequence for d, phase in zip(delays, phases): expectedseq += [ qwait(channels=(q, )), X90(q), Id(q, d), U90(q, phase=phase), MEAS(q) ] # Add calibration cal = get_cal_seqs_1qubit(q, calRepeats) expectedseq += cal expectedseq = testable_sequence(expectedseq) resFunction = compile_function( "src/python/qgl2/basic_sequences/T1T2.py", "Ramsey", (qr, delays, TPPIFreq, calRepeats)) seqs = resFunction() seqs = testable_sequence(seqs) assertPulseSequenceEqual(self, seqs, expectedseq)
def test_HahnEcho(self): q = QubitFactory('q1') qr = QRegister('q1') steps = 11 pulseSpacings = np.linspace(0, 5e-6, steps) periods = 0 calRepeats = 2 expectedseq = [] for k in range(len(pulseSpacings)): expectedseq += [ qwait(channels=(q, )), X90(q), Id(q, pulseSpacings[k]), Y(q), Id(q, pulseSpacings[k]), U90(q, phase=2 * pi * periods / len(pulseSpacings) * k), MEAS(q) ] # Add calibration cal = get_cal_seqs_1qubit(q, calRepeats) expectedseq += cal expectedseq = testable_sequence(expectedseq) resFunction = compile_function( "src/python/qgl2/basic_sequences/Decoupling.py", "HahnEcho", (qr, pulseSpacings, periods, calRepeats)) seqs = resFunction() seqs = testable_sequence(seqs) # import ipdb; ipdb.set_trace() assertPulseSequenceEqual(self, seqs, expectedseq)
def get_cal_seqs_1qubit(qubit, calRepeats=2): ''' Note: return may include 0 length Id pulses. EG: qwait Id(q1) MEAS(q1), qwait Id(q1) MEAS(q1), qwait X(q1) MEAS(q1), qwait X(q1) MEAS(q1) ''' calSeq = [] for pulse in [Id, X]: for _ in range(calRepeats): calSeq += [ qwait(channels=(qubit, )), pulse(qubit), Barrier(qubit), MEAS(qubit) ] return calSeq
def test_RabiAmpPi(self): q1 = QubitFactory('q1') q2 = QubitFactory('q2') qr1 = QRegister(q1) qr2 = QRegister(q2) amps = np.linspace(0, 1, 11) phase = 0 resFunction = compile_function( "src/python/qgl2/basic_sequences/Rabi.py", "RabiAmpPi", (qr1, qr2, amps, phase)) seqs = resFunction() seqs = testable_sequence(seqs) expectedseq = [] for amp in amps: expectedseq += [ qwait(channels=(q1, q2)), X(q2), Utheta(q1, amp=amp, phase=phase), X(q2), MEAS(q2) ] assertPulseSequenceEqual(self, seqs, expectedseq)
def get_cal_seqs_2qubits(q1, q2, calRepeats=2): ''' Prepare all computational 2-qubit basis states and measure them. ''' calseq = [] for pulseSet in [(Id, Id), (Id, X), (X, Id), (X, X)]: for _ in range(calRepeats): calseq += [ qwait(channels=(q1, q2)), pulseSet[0](q1), pulseSet[1](q2), Barrier(q1, q2), MEAS(q1), MEAS(q2) ] return calseq
def doPulsedSpec(qubit: qreg, specOn): init(qubit) if specOn: X(qubit) else: Id(qubit) MEAS(qubit)
def test_AllXY(self): # QGL1 uses QubitFactory, QGL2 uses QRegister q1 = QubitFactory('q1') qr = QRegister(q1) # Specify the QGL1 we expect QGL2 to generate # Note in this case we specify only a sample of the start expectedseq = [] # Expect a single sequence 4 * 2 * 21 pulses long # Expect it to start like this: expectedseq += [ qwait(channels=(q1, )), # aka init(q1) aka Wait(q1) Id(q1), Id(q1), MEAS(q1), qwait(channels=(q1, )), Id(q1), Id(q1), MEAS(q1) ] # To turn on verbose logging in compile_function # from pyqgl2.ast_util import NodeError # from pyqgl2.debugmsg import DebugMsg # NodeError.MUTE_ERR_LEVEL = NodeError.NODE_ERROR_NONE # DebugMsg.set_level(0) # Now compile the QGL2 to produce the function that would generate the expected sequence. # Supply the path to the QGL2, the main function in that file, and a list of the args to that function. # Can optionally supply saveOutput=True to save the qgl1.py # file, # and intermediate_output="path-to-output-file" to save # intermediate products resFunction = compile_function( "src/python/qgl2/basic_sequences/AllXY.py", "AllXY", (qr, )) # Run the QGL2. Note that the generated function takes no arguments itself seqs = resFunction() # Transform the returned sequences into the canonical form for comparing # to the explicit QGL1 version above. # EG, 'flatten' any embedded lists of sequences. seqs = testable_sequence(seqs) # Assert that the QGL1 is the same as the generated QGL2 self.assertEqual(len(seqs), 4 * 21 * 2) assertPulseSequenceEqual(self, seqs[:len(expectedseq)], expectedseq)
def SPAM(qubit: qreg, angleSweep, maxSpamBlocks=10, showPlot=False): """ X-Y sequence (X-Y-X-Y)**n to determine quadrature angles or mixer correction. Parameters ---------- qubit : logical channel to implement sequence (LogicalChannel) angleSweep : angle shift to sweep over maxSpamBlocks : maximum number of XYXY block to do showPlot : whether to plot (boolean) """ # Original: # def spam_seqs(angle): # """ Helper function to create a list of sequences increasing SPAM blocks with a given angle. """ # SPAMBlock = [X(qubit), U(qubit, phase=pi/2+angle), X(qubit), U(qubit, phase=pi/2+angle)] # return [[Y90(qubit)] + SPAMBlock*rep + [X90(qubit)] for rep in range(maxSpamBlocks)] # # Insert an identity at the start of every set to mark them off # seqs = list(chain.from_iterable([[[Id(qubit)]] + spam_seqs(angle) for angle in angleSweep])) # # Add a final pi for reference # seqs.append([X(qubit)]) # # Add the measurment block to every sequence # measBlock = MEAS(qubit) # for seq in seqs: # seq.append(measBlock) # fileNames = compile_to_hardware(seqs, 'SPAM/SPAM') # print(fileNames) # if showPlot: # plot_pulse_files(fileNames) # Insert an identity at the start of every set to mark them off for angle in angleSweep: init(qubit) Id(qubit) MEAS(qubit) spam_seqs(angle, qubit, maxSpamBlocks) # Add a final pi for reference init(qubit) X(qubit) MEAS(qubit)
def test_SingleShot(self): q1 = QubitFactory('q1') qr = QRegister(q1) resFunction = compile_function( "src/python/qgl2/basic_sequences/Rabi.py", "SingleShot", (qr, )) seqs = resFunction() seqs = testable_sequence(seqs) expectedseq = [ qwait(channels=(q1, )), Id(q1), MEAS(q1), qwait(channels=(q1, )), X(q1), MEAS(q1) ] assertPulseSequenceEqual(self, seqs, expectedseq)
def doRabiAmpPi(qubit: qreg, mqubit: qreg, amps, phase): for amp in amps: with concur: init(qubit) init(mqubit) X(mqubit) Utheta(qubit, amp=amp, phase=phase) X(mqubit) MEAS(mqubit)
def RabiAmp(): from QGL import QubitFactory from QGL.PulsePrimitives import MEAS from QGL.PulsePrimitives import Utheta from qgl2.qgl1_util import init_real as init QBIT_1 = QubitFactory('q1') from pyqgl2.eval import EvalTransformer _v = EvalTransformer.PRECOMPUTED_VALUES seq = [init(QBIT_1), Utheta(QBIT_1, amp=0.0, phase=0), MEAS(QBIT_1)] return seq
def SimultaneousRB_AC(qubits: qreg, seqs, showPlot=False): """ Simultaneous randomized benchmarking on multiple qubits using atomic Clifford pulses. Parameters ---------- qubits : iterable of logical channels to implement seqs on (list or tuple) seqs : a tuple of sequences created for each qubit in qubits showPlot : whether to plot (boolean) Example ------- >>> q1 = QubitFactory('q1') >>> q2 = QubitFactory('q2') >>> seqs1 = create_RB_seqs(1, [2, 4, 8, 16]) >>> seqs2 = create_RB_seqs(1, [2, 4, 8, 16]) >>> SimultaneousRB_AC((q1, q2), (seqs1, seqs2), showPlot=False) """ # Original: # seqsBis = [] # for seq in zip(*seqs): # seqsBis.append([reduce(operator.__mul__, [AC(q,c) for q,c in zip(qubits, # pulseNums)]) for pulseNums in zip(*seq)]) # # Add the measurement to all sequences # for seq in seqsBis: # seq.append(reduce(operator.mul, [MEAS(q) for q in qubits])) # # Tack on the calibration sequences # seqsBis += create_cal_seqs((qubits), 2) # fileNames = compile_to_hardware(seqsBis, 'RB/RB') # print(fileNames) # if showPlot: # plot_pulse_files(fileNames) for seq in zip(*seqs): # Start sequence with concur: for q in qubits: init(q) for pulseNums in zip(*seq): with concur: for q, c in zip(qubits, pulseNums): AC(q, c) # Measure at end of each sequence with concur: for q in qubits: MEAS(q) # FIXME: Not working in QGL2 yet # Tack on calibration create_cal_seqs((qubits), 2)
def TwoQubitRB(q1: qreg, q2: qreg, seqs, showPlot=False, suffix=""): """ Two qubit randomized benchmarking using 90 and 180 single qubit generators and ZX90 Parameters ---------- qubit : logical channel to implement sequence (LogicalChannel) seqs : list of lists of Clifford group integers showPlot : whether to plot (boolean) """ # Original: # seqsBis = [] # for seq in seqs: # seqsBis.append(reduce(operator.add, [clifford_seq(c, q1, q2) for c in seq])) # # Add the measurement to all sequences # for seq in seqsBis: # seq.append(MEAS(q1, q2)) # # Tack on the calibration sequences # seqsBis += create_cal_seqs((q1,q2), 2) # fileNames = compile_to_hardware(seqsBis, 'RB/RB', suffix=suffix) # print(fileNames) # if showPlot: # plot_pulse_files(fileNames) for seq in seqs: with concur: init(q1) init(q2) for c in seq: clifford_seq(c, q1, q2) with concur: MEAS(q1) MEAS(q2) # Tack on the calibration sequences create_cal_seqs((q1, q2), 2)
def Ramseyq1(qubit: qreg, pulseSpacings, TPPIFreq=0, showPlot=False, calRepeats=2, suffix=False): """ Variable pulse spacing Ramsey (pi/2 - tau - pi/2) with optional TPPI. Parameters ---------- qubit : logical channel to implement sequence (LogicalChannel) pulseSpacings : pulse spacings (iterable; seconds) TPPIFreq : frequency for TPPI phase updates of second Ramsey pulse (Hz) showPlot : whether to plot (boolean) calRepeats : how many repetitions of calibration pulses (int) """ # Original: # # Create the phases for the TPPI # phases = 2*pi*TPPIFreq*pulseSpacings # # Create the basic Ramsey sequence # seqs = [[X90(qubit), Id(qubit, d), U90(qubit, phase=phase), MEAS(qubit)] # for d,phase in zip(pulseSpacings, phases)] # # Tack on the calibration scalings # seqs += create_cal_seqs((qubit,), calRepeats) # fileNames = compile_to_hardware(seqs, 'Ramsey'+('_'+qubit.label)*suffix+'/Ramsey'+('_'+qubit.label)*suffix) # print(fileNames) # if showPlot: # plot_pulse_files(fileNames) # Create the phases for the TPPI phases = 2*pi*TPPIFreq*pulseSpacings # Creating sequences that look like this: # [['X90', 'Id', 'U90', 'M'], ['X90', 'Id', 'U90', 'M']] # Create the basic Ramsey sequence seqs = [] for d,phase in zip(pulseSpacings, phases): seq = [] seq.append(X90(qubit)) seq.append(Id(qubit, d)) seq.append(U90(qubit, phase=phase)) seq.append(MEAS(qubit)) seqs.append(seq) # Tack on calibration # seqs = addCalibration(seqs, (qubit,), calRepeats) # Calculate label label = 'Ramsey'+('_'+qubit.label)*suffix fullLabel = label + '/' + label
def doSwap(qubit: qreg, mqubit: qreg, delays): # Original: # seqs = [[X(qubit), X(mqubit), Id(mqubit, d), MEAS(mqubit)*MEAS(qubit)] for d in delays] + create_cal_seqs((mqubit,qubit), 2, measChans=(mqubit,qubit)) # fileNames = compile_to_hardware(seqs, 'Rabi/Rabi') # print(fileNames) # if showPlot: # plotWin = plot_pulse_files(fileNames) # return plotWin for d in delays: with concur: init(qubit) init(mqubit) X(qubit) X(mqubit) Id(mqubit, d) with concur: MEAS(mqubit) MEAS(qubit) create_cal_seqs((mqubit, qubit), 2)
def flipflop_seqs(dragScaling, maxNumFFs, qubit: qreg): """ Helper function to create a list of sequences with a specified drag parameter. """ # FIXME: cause qubit is a placeholder, can't access pulse_params # qubit.pulse_params['dragScaling'] = dragScaling for rep in range(maxNumFFs): init(qubit) X90(qubit, dragScaling=dragScaling) # FIXME: Original used [X90] + [X90, X90m]... is this right? for _ in range(rep): X90(qubit, dragScaling=dragScaling) X90m(qubi, dragScaling=dragScaling) Y90(qubit, dragScaling=dragScaling) MEAS(qubit) # FIXME: Need original dragScaling?
def doRabiAmp_NQubits(qubits: qreg, amps, phase, measChans: qreg, docals, calRepeats): for amp in amps: with concur: for q in qubits: init(q) Utheta(q, amp=amp, phase=phase) with concur: for m in measChans: MEAS(m) if docals: create_cal_seqs(qubits, calRepeats, measChans)
def testTwoQubitRB(q1, q2, rbseqs, add_cal=True): from QGL.Cliffords import clifford_seq from QGL.BasicSequences.helpers import create_cal_seqs from functools import reduce import operator seqsBis = [] for seq in rbseqs: seqsBis.append( reduce(operator.add, [clifford_seq(c, q2, q1) for c in seq])) #Add the measurement to all sequences for seq in seqsBis: # FIXME: Correct thing is doing these with * as below, # But that differs from QGL2 version # seq.append(MEAS(q1) * MEAS(q2)) seq.append(MEAS(q1)) seq.append(MEAS(q2)) #Tack on the calibration sequences if add_cal: seqsBis += create_cal_seqs((q1, q2), 2) return seqsBis
def doRamsey(): q = QubitFactory('q1') TPPIFreq=1e6 # FIXME: QGL2 doesn't deal well with the call to np.arange pulseS = [ 1.00000000e-07, 2.00000000e-07, 3.00000000e-07, 4.00000000e-07, 5.00000000e-07, 6.00000000e-07, 7.00000000e-07, 8.00000000e-07, 9.00000000e-07, 1.00000000e-06, 1.10000000e-06, 1.20000000e-06, 1.30000000e-06, 1.40000000e-06, 1.50000000e-06, 1.60000000e-06, 1.70000000e-06, 1.80000000e-06, 1.90000000e-06, 2.00000000e-06, 2.10000000e-06, 2.20000000e-06, 2.30000000e-06, 2.40000000e-06, 2.50000000e-06, 2.60000000e-06, 2.70000000e-06, 2.80000000e-06, 2.90000000e-06, 3.00000000e-06, 3.10000000e-06, 3.20000000e-06, 3.30000000e-06, 3.40000000e-06, 3.50000000e-06, 3.60000000e-06, 3.70000000e-06, 3.80000000e-06, 3.90000000e-06, 4.00000000e-06, 4.10000000e-06, 4.20000000e-06, 4.30000000e-06, 4.40000000e-06, 4.50000000e-06, 4.60000000e-06, 4.70000000e-06, 4.80000000e-06, 4.90000000e-06, 5.00000000e-06, 5.10000000e-06, 5.20000000e-06, 5.30000000e-06, 5.40000000e-06, 5.50000000e-06, 5.60000000e-06, 5.70000000e-06, 5.80000000e-06, 5.90000000e-06, 6.00000000e-06, 6.10000000e-06, 6.20000000e-06, 6.30000000e-06, 6.40000000e-06, 6.50000000e-06, 6.60000000e-06, 6.70000000e-06, 6.80000000e-06, 6.90000000e-06, 7.00000000e-06, 7.10000000e-06, 7.20000000e-06, 7.30000000e-06, 7.40000000e-06, 7.50000000e-06, 7.60000000e-06, 7.70000000e-06, 7.80000000e-06, 7.90000000e-06, 8.00000000e-06, 8.10000000e-06, 8.20000000e-06, 8.30000000e-06, 8.40000000e-06, 8.50000000e-06, 8.60000000e-06, 8.70000000e-06, 8.80000000e-06, 8.90000000e-06, 9.00000000e-06, 9.10000000e-06, 9.20000000e-06, 9.30000000e-06, 9.40000000e-06, 9.50000000e-06, 9.60000000e-06, 9.70000000e-06, 9.80000000e-06, 9.90000000e-06] #pulseSpacings=np.arange(100e-9, 10e-6, 100e-9) # Create the phases for the TPPI phases = 2*pi*TPPIFreq*pulseS # Create the basic Ramsey sequence # FIXME: QGL2 doesn't deal well with this call to zip for d,phase in zip(pulseS, phases): init(q) X90(q) Id(q, d) U90(q, phase=phase) MEAS(q) # Tack on calibration create_cal_seqs((q,), calRepeats)
def addFFSeqs(dragParam, maxNumFFs, qubit): ffs = [] for rep in range(maxNumFFs): ffs += [ qwait(channels=(qubit, )), X90(qubit, dragScaling=dragParam) ] for _ in range(rep): ffs += [ X90(qubit, dragScaling=dragParam), X90m(qubit, dragScaling=dragParam) ] ffs += [Y90(qubit, dragScaling=dragParam), MEAS(qubit)] return ffs
def spam_seqs(angle, qubit: qreg, maxSpamBlocks=10): """ Helper function to create a list of sequences increasing SPAM blocks with a given angle. """ #SPAMBlock = [X(qubit), U(qubit, phase=pi/2+angle), X(qubit), U(qubit, phase=pi/2+angle)] #return [[Y90(qubit)] + SPAMBlock*rep + [X90(qubit)] for rep in range(maxSpamBlocks)] for rep in range(maxSpamBlocks): init(qubit) Y90(qubit) for _ in range(rep): X(qubit) U(qubit, phase=pi/2+angle) X(qubit) U(qubit, phase=pi/2+angle) X90(qubit) MEAS(qubit)
def FlipFlopMin(): # FIXME: No args qubit = QubitFactory('q1') dragParamSweep = np.linspace(0, 5e-6, 11) # FIXME maxNumFFs = 10 # FIXME: cause qubit is a placeholder, can't access pulse_params # originalScaling = qubit.pulse_params['dragScaling'] for dragParam in dragParamSweep: init(qubit) Id(qubit) MEAS(qubit) # FIXME: Need original dragScaling? # FIXME: In original this was [[Id]] + flipflop - is this # right? flipflop_seqs(dragParam, maxNumFFs, qubit) # FIXME: cause qubit is a placeholder, can't access pulse_params # qubit.pulse_params['dragScaling'] = originalScaling # Add a final pi for reference init(qubit) X(qubit) MEAS(qubit)
def test_AllXY_alt2(self): q1 = QubitFactory('q1') qr = QRegister('q1') expectedseq = [] # Expect a single sequence 4 * 2 * 21 pulses long # Expect it to start like this: expectedseq += [ qwait(channels=(q1, )), Id(q1), Id(q1), MEAS(q1), qwait(channels=(q1, )), Id(q1), Id(q1), MEAS(q1) ] resFunction = compile_function("test/code/AllXY_alt.py", "doAllXY2", (qr, )) seqs = resFunction() seqs = testable_sequence(seqs) self.assertEqual(len(seqs), 4 * 21 * 2) assertPulseSequenceEqual(self, seqs[:len(expectedseq)], expectedseq)