예제 #1
0
def anotherMulti2():
    qs = QRegister(3)
    qsub = QRegister(qs[0], qs[1])
    Id(qsub)
    X(qs[0:2])  # equivalent to calling with qsub argument
    Barrier(qs)
    MEAS(qsub)
    Barrier(qs)
    Y(qs[0])
    Y(qs[2])
예제 #2
0
def anotherMulti3():
    qs = QRegister(3)
    # create the QRegister with slicing
    qsub = QRegister(qs[0:2])
    Id(qsub)
    X(qsub)
    Barrier(qs)
    MEAS(qsub)
    Barrier(qs)
    Y(qs[0])
    Y(qs[2])
예제 #3
0
def measConcurrently(listNQubits: qreg) -> pulse:
    '''Concurrently measure given QRegister of qubits.
    Note: Includes a Barrier on the input qreg to force measurements
    to be concurrent; QGL1 does Pulse*Pulse == PulseBlock(pulses), which is equivalent.'''
    qr = QRegister(listNQubits)
    Barrier(qr)
    MEAS(qr)
예제 #4
0
def anotherMulti():
    qs = QRegister(2)
    Id(qs)
    X(qs)
    Barrier(qs)
    MEAS(qs)
    Y(qs)
예제 #5
0
def multiQbitTest2():
    qs = QRegister('q1', 'q2')

    Id(qs)
    X(qs)
    Barrier(qs)
    MEAS(qs)
예제 #6
0
def create_cal_seqs(qubits: qreg,
                    numRepeats,
                    measChans=None,
                    waitcmp=False,
                    delay=None):
    """
    Helper function to create a set of calibration sequences.

    Parameters
    ----------
    qubits : a QRegister of channels to calibrate
    numRepeats : number of times to repeat calibration sequences (int)
    measChans : QRegister of channels to measure; default is to use qubits
    waitcmp = True if the sequence contains branching; default False
    delay: optional time between state preparation and measurement (s)
    """
    # Allows supplying a tuple as is usually done in QGL1
    qubitreg = QRegister(qubits)

    # QGL2 will warn here:
    # warning: parameter [measChans] overwritten by assignment
    if measChans is None:
        measChans = qubitreg

    # Make all combinations for qubit calibration states for n qubits and repeat

    # Assuming numRepeats=2 and qubits are q1, q2
    # Produces 2 ^ #qubits * numRepeats sequences of Id, X, MEAS,
    # something like
    # [[Id(q1)*Id(q2), M(q1)*M(q2)], [Id(q1)*Id(q2), M(q1)*M(q2)],
    #  [Id(q1)*X(q2), M(q1)*M(q2)],  [Id(q1)*X(q2), M(q1)*M(q2)],
    #  [X(q1)*Id(q2), M(q1)*M(q2)],  [X(q1)*Id(q2), M(q1)*M(q2)],
    #  [X(q1)*X(q2), M(q1)*M(q2)],   [X(q1)*X(q2), M(q1)*M(q2)]]

    # Calibrate using Id and X pulses
    calSet = [Id, X]

    for pulseSet in product(calSet, repeat=len(qubitreg)):
        # Repeat each calibration numRepeats times
        for _ in range(numRepeats):
            init(qubitreg)
            for pulse, qubit in zip(pulseSet, qubitreg):
                pulse(qubit)
            if delay:
                # Add optional delay before measurement
                Id(qubitreg(0), length=delay)
            Barrier(measChans)
            MEAS(measChans)
            # If branching do wait
            if waitcmp:
                qwait(kind='CMP')
예제 #7
0
def measConcurrently(listNQubits: qreg) -> pulse:
    '''Concurrently measure given QRegister of qubits.'''
    qr = QRegister(listNQubits)
    Barrier(qr)
    MEAS(qr)