Ejemplo n.º 1
0
def concurrently(a: qreg, b: qreg):
    with concur:
        X90(a)
        Y90(b)
    with concur:
        X90(a)
        Y90(b)
Ejemplo n.º 2
0
def classical_break():
    q1 = QRegister("q1")

    for ct in range(3):
        X(q1)
        if ct >= 1:
            X90(q1)
            break
            X90(q1)
        Y90(q1)
Ejemplo n.º 3
0
def classical_continue():
    q1 = QRegister("q1")

    for ct in range(3):
        X(q1)
        if ct >= 1:
            X90(q1)
            continue
            X90(q1)
        Y90(q1)
Ejemplo n.º 4
0
def main():
    q1 = QubitFactory("1")
    q2 = QubitFactory("2")
    with concur:
        reset(q1)
        reset(q2)
    with concur:
        X90(q1)
        X90(q2)
    with concur:
        MEAS(q1)
        MEAS(q2)
Ejemplo n.º 5
0
def flipflop_seqs(dragParam, maxNumFFs, qubit: qreg):
    """ Helper function to create a list of sequences with a specified drag parameter. """
    # QGL2 qubits are read only.
    # So instead, supply the dragScaling as an explicit kwarg to all pulses
    # qubit.pulse_params['dragScaling'] = dragParam
    for rep in range(maxNumFFs):
        init(qubit)
        X90(qubit, dragScaling=dragParam)
        # FIXME: Original used [X90] + [X90, X90m]... is this right?
        for _ in range(rep):
            X90(qubit, dragScaling=dragParam)
            X90m(qubit, dragScaling=dragParam)
        Y90(qubit, dragScaling=dragParam)
        MEAS(qubit)
Ejemplo n.º 6
0
def flipflop_seqs(dragScaling, maxNumFFs, qubit: qreg):
    """ Helper function to create a list of sequences with a specified drag parameter. """
    # QGL2 qubits are read only.
    # So instead, supply the dragScaling as an explicit kwarg to all pulses
    # qubit.pulse_params['dragScaling'] = dragScaling

    for rep in range(maxNumFFs):
        init(qubit)
        X90(qubit, dragScaling=dragScaling)
        for _ in range(rep):
            X90(qubit, dragScaling=dragScaling)
            X90m(qubit, dragScaling=dragScaling)
        Y90(qubit, dragScaling=dragScaling)
        MEAS(qubit)
Ejemplo n.º 7
0
def test_loops(a: qbit, b: qbit):

    with concur:
        while True:
            v1 = MEAS(a)
            if v1:
                break
            X90(a, 1.0, 2.0)
            X90(a, 1.0, 2.0)

        while True:
            v2 = MEAS(b)
            if v2:
                break
            Y90(b)
Ejemplo n.º 8
0
def main():

    q1 = QubitFactory('q1')
    q2 = QubitFactory('q2')

    X90(q1)
    Y90(q2)
Ejemplo n.º 9
0
def EchoCRPhase(controlQ: qreg, targetQ: qreg, phases, riseFall=40e-9, amp=1, length=100e-9, calRepeats=2, canc_amp=0, canc_phase=np.pi/2):
    """
    Variable phase CX experiment, with echo pulse sandwiched between two CR opposite-phase pulses.

    Parameters
    ----------
    controlQ : logical channel for the control qubit (LogicalChannel)
    targetQ : logical channel for the cross-resonance pulse (LogicalChannel)
    phases : pulse phases of the CR pulse to sweep over (iterable)
    riseFall : rise/fall time of the CR pulse (s)
    amp : amplitude of the CR pulse
    length : duration of each of the two flat parts of the CR pulse (s)
    calRepeats : number of repetitions of readout calibrations for each 2-qubit state
    """
    # Original:
    # seqs = [[Id(controlQ)] + echoCR(controlQ, targetQ, length=length, phase=ph, riseFall=riseFall) + [X90(targetQ)*Id(controlQ), MEAS(targetQ)*MEAS(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))

    cNt = QRegister(controlQ, targetQ)

    # Sequence 1
    for ph in phases:
        init(cNt)
        Id(controlQ)
        echoCR(controlQ, targetQ, length=length, phase=ph,
               riseFall=riseFall, canc_amp=canc_amp, canc_phase=canc_phase)
        Barrier(cNt)
        X90(targetQ)
        Id(controlQ)
        measConcurrently(cNt)

    # Sequence 2
    for ph in phases:
        init(cNt)
        X(controlQ)
        echoCR(controlQ, targetQ, length=length, phase=ph,
               riseFall=riseFall, canc_amp=canc_amp, canc_phase=canc_phase)
        Barrier(cNt)
        X90(targetQ)
        X(controlQ)
        measConcurrently(cNt)

    # Then do calRepeats calibration sequences
    create_cal_seqs(cNt, calRepeats)
Ejemplo n.º 10
0
def main():

    q1 = QubitFactory('q1')
    q2 = QubitFactory('q2')
    q3 = QubitFactory('q3')

    X90(q1)
    Y90(q2)
    Utheta(q3)
Ejemplo n.º 11
0
def runtime_break():
    q1 = QRegister("q1")

    for ct in range(3):
        m = MEAS(q1)
        if m:
            X90(q1)
            # this should produce an error
            break
Ejemplo n.º 12
0
def SingleQubitRB_DiAC(qubit, seqs, compiled=True, purity=False, add_cals=True):
    """Single qubit randomized benchmarking using diatomic Clifford pulses.

    Parameters
    ----------
    qubit : logical channel to implement sequence (LogicalChannel)
    seqFile : file containing sequence strings
    compiled : if True, compile Z90(m)-X90-Z90(m) to Y90(m) pulses
    purity : measure <Z>,<X>,<Y> of final state, to measure purity. See J.J.
        Wallman et al., New J. Phys. 17, 113020 (2015)
    """
    op = [Id, Y90m, X90]
    for ct in range(3 if purity else 1):
        for seq in seqs:
            init(qubit)
            for c in seq:
                DiAC(qubit, c, compiled)
            # append tomography pulse to measure purity
            if ct == 0:
                op[ct](qubit, length=0)
            else:
                op[ct](qubit)
            # append measurement
            MEAS(qubit)

#    axis_descriptor = [{
#        'name': 'length',
#        'unit': None,
#        'points': list(map(len, seqs)),
#        'partition': 1
#    }]

    # Tack on the calibration sequences
    if add_cals:
        for _ in range(2):
            init(qubit)
            Id(qubit)
            MEAS(qubit)
        for _ in range(2):
            init(qubit)
            X90(qubit)
            X90(qubit)
            MEAS(qubit)
Ejemplo n.º 13
0
def CPMG(qubit: qreg, numPulses, pulseSpacing, calRepeats=2):
    """
    CPMG pulse train with fixed pulse spacing. Note this pulse spacing is centre to centre,
    i.e. it accounts for the pulse width

    Parameters
    ----------
    qubit : logical channel to implement sequence (LogicalChannel) 
    numPulses : number of 180 pulses; should be even (iterable)
    pulseSpacing : spacing between the 180's (seconds)
    calRepeats : how many times to repeat calibration scalings (default 2)
    """

    # Original:
    # # First setup the t-180-t block
    # CPMGBlock = [Id(qubit, (pulseSpacing-qubit.pulse_params['length'])/2),
    #              Y(qubit), Id(qubit, (pulseSpacing-qubit.pulse_params['length'])/2)]

    # seqs = [[X90(qubit)] + CPMGBlock*rep + [X90(qubit), MEAS(qubit)] for rep in numPulses]

    # # Tack on the calibration scalings
    # seqs += create_cal_seqs((qubit,), calRepeats)

    # fileNames = compile_to_hardware(seqs, 'CPMG/CPMG')
    # print(fileNames)

    # if showPlot:
    #     plot_pulse_files(fileNames)

    # Create numPulses sequences
    for rep in numPulses:
        init(qubit)
        X90(qubit)
        # Repeat the t-180-t block rep times
        for _ in range(rep):
            pulseCentered(qubit, Id, pulseSpacing)
            Y(qubit)
            pulseCentered(qubit, Id, pulseSpacing)
        X90(qubit)
        MEAS(qubit)

    # Tack on calibration
    create_cal_seqs(qubit, calRepeats)
Ejemplo n.º 14
0
def spam_seqs(angle, q: qreg, maxSpamBlocks=10):
    for rep in range(maxSpamBlocks):
        init(q)
        Y90(q)
        for _ in range(rep):
            X(q)
            U(q, phase=pi / 2 + angle)
            X(q)
            U(q, phase=pi / 2 + angle)
        X90(q)
        MEAS(q)
Ejemplo n.º 15
0
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)
Ejemplo n.º 16
0
def doRamsey(q:qreg, delays, TPPIFreq, calRepeats):
    # Create the phases for the TPPI
    phases = 2*pi*TPPIFreq*delays

    # Create the basic Ramsey sequence
    for d,phase in zip(delays, phases):
        init(q)
        X90(q)
        Id(q, length=d)
        U90(q, phase=phase)
        MEAS(q)

    # Tack on calibration
    create_cal_seqs(q, calRepeats)
Ejemplo n.º 17
0
def Ramsey(qubit: qreg, pulseSpacings, TPPIFreq=0, calRepeats=2):
    """
    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)
    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
    for d,phase in zip(pulseSpacings, phases):
        init(qubit)
        X90(qubit)
        Id(qubit, length=d)
        U90(qubit, phase=phase)
        MEAS(qubit)

    # Tack on calibration
    create_cal_seqs(qubit, calRepeats)
Ejemplo n.º 18
0
def HahnEcho(qubit: qreg, pulseSpacings, periods=0, calRepeats=2):
    """
    A single pulse Hahn echo with variable phase of second pi/2 pulse. 

    Parameters
    ----------
    qubit : logical channel to implement sequence (LogicalChannel) 
    pulseSpacings : pulse spacings to sweep over; the t in 90-t-180-t-180 (iterable)
    periods: number of artificial oscillations
    calRepeats : how many times to repeat calibration scalings (default 2)
    """

    # Original:
    # seqs=[];
    # for k in range(len(pulseSpacings)):
    #     seqs.append([X90(qubit), Id(qubit, pulseSpacings[k]), Y(qubit), Id(qubit,pulseSpacings[k]), \
    #                  U90(qubit,phase=2*pi*periods/len(pulseSpacings)*k), MEAS(qubit)])

    # # Tack on the calibration scalings
    # seqs += create_cal_seqs((qubit,), calRepeats)

    # fileNames = compile_to_hardware(seqs, 'Echo/Echo')
    # print(fileNames)

    # if showPlot:
    #     plot_pulse_files(fileNames)

    for k in range(len(pulseSpacings)):
        init(qubit)
        X90(qubit)
        # FIXME 9/28/16: Must name the length arg (issue #45)
        Id(qubit, length=pulseSpacings[k])
        Y(qubit)
        Id(qubit, length=pulseSpacings[k])
        U90(qubit, phase=2 * pi * periods / len(pulseSpacings) * k)
        MEAS(qubit)

    create_cal_seqs(qubit, calRepeats)
Ejemplo n.º 19
0
def test_loops(a: qreg, b: qreg):

    x = QubitFactory("1")
    # Next line causes an error - qbit reassignment
    x = r
    # Next line is also an error - no d defined
    v1 = MEAS(d)

    with concur:
        while True:
            v1 = MEAS(d)
            # There's no qbit1 - another error
            X90(qbit1)
            if v1:
                break

        while True:
            v2 = MEAS(b)
            Y90(qbit2)
            if v2:
                break

    with concur:
        print('fred')
Ejemplo n.º 20
0
def loopy3(a: qreg, b: qreg):
    for _ in range(2):
        X90(a)
        Utheta(b)
Ejemplo n.º 21
0
def process(control: qreg, target: qreg):
    X90(control)
    Y90(target)
Ejemplo n.º 22
0
def func_c(a: qreg, x: classical):
    X90(a, kwarg1=x) + Y90(a, kwarg1=x)
Ejemplo n.º 23
0
def sequential(a: qreg, b: qreg):
    X90(a)
    Y90(b)
Ejemplo n.º 24
0
def func_b(a: qreg) -> pulse:
    X90(a)
    Y90(a)
Ejemplo n.º 25
0
def loopy2(a: qreg, b: qreg, c: qreg):
    for q in [a, b, c]:
        with concur:
            X90(q)
Ejemplo n.º 26
0
def func_a(q: qreg) -> pulse:

    for i in range(0, 3):
        X90(q)
Ejemplo n.º 27
0
def func_c(a: qreg, x: classical):
    Id(a) + X90(a, kwarg1=x)
Ejemplo n.º 28
0
def Hadamard(q: qreg):
    Y90(q)
    X90(q)
Ejemplo n.º 29
0
def third_level(a: qreg, b: qreg):
    with concur:
        X90(a)
        Y90(b)
Ejemplo n.º 30
0
def t1(q_a: qreg, q_b: qreg):
    with concur:
        X(q_a) + X90(q_a) + Y90(q_a)
        Y(q_b) + Y90(q_b) + X90(q_b)