示例#1
0
 def setUp(self) -> None:
     super().setUp()
     style = stylesheet.QiskitPulseStyle()
     self.formatter = style.formatter
     self.device = device_info.OpenPulseBackendInfo(
         name='test',
         dt=1,
         channel_frequency_map={
             pulse.DriveChannel(0): 5.0e9,
             pulse.DriveChannel(1): 5.1e9,
             pulse.MeasureChannel(0): 7.0e9,
             pulse.MeasureChannel(1): 7.1e9,
             pulse.ControlChannel(0): 5.0e9,
             pulse.ControlChannel(1): 5.1e9
         },
         qubit_channel_map={
             0: [
                 pulse.DriveChannel(0),
                 pulse.MeasureChannel(0),
                 pulse.AcquireChannel(0),
                 pulse.ControlChannel(0)
             ],
             1: [
                 pulse.DriveChannel(1),
                 pulse.MeasureChannel(1),
                 pulse.AcquireChannel(1),
                 pulse.ControlChannel(1)
             ]
         })
    def _schedule(self) -> Tuple[pulse.ScheduleBlock, Parameter]:
        """Create the spectroscopy schedule."""

        dt, granularity = self._dt, self._granularity

        duration = int(granularity *
                       (self.experiment_options.duration / dt // granularity))
        sigma = granularity * (self.experiment_options.sigma / dt //
                               granularity)
        width = granularity * (self.experiment_options.width / dt //
                               granularity)

        qubit = self.physical_qubits[0]

        freq_param = Parameter("frequency")

        with pulse.build(backend=self.backend,
                         name="spectroscopy") as schedule:
            pulse.shift_frequency(freq_param, pulse.MeasureChannel(qubit))
            pulse.play(
                pulse.GaussianSquare(
                    duration=duration,
                    amp=self.experiment_options.amp,
                    sigma=sigma,
                    width=width,
                ),
                pulse.MeasureChannel(qubit),
            )
            pulse.acquire(duration, qubit, pulse.MemorySlot(0))

        return schedule, freq_param
示例#3
0
    def test_disassemble_schedule_los(self):
        """Test disassembling schedule los."""
        d0 = pulse.DriveChannel(0)
        m0 = pulse.MeasureChannel(0)
        d1 = pulse.DriveChannel(1)
        m1 = pulse.MeasureChannel(1)

        sched0 = pulse.Schedule()
        sched1 = pulse.Schedule()

        schedule_los = [{
            d0: 4.5e9,
            d1: 5e9,
            m0: 6e9,
            m1: 7e9
        }, {
            d0: 5e9,
            d1: 4.5e9,
            m0: 7e9,
            m1: 6e9
        }]
        qobj = assemble([sched0, sched1],
                        backend=self.backend,
                        schedule_los=schedule_los)
        _, run_config_out, _ = disassemble(qobj)
        run_config_out = RunConfig(**run_config_out)

        self.assertEqual(run_config_out.schedule_los, schedule_los)
示例#4
0
    def test_delay_qubits(self):
        """Test delaying on multiple qubits to make sure we don't insert delays twice."""
        with pulse.build(self.backend) as schedule:
            pulse.delay_qubits(10, 0, 1)

        d0 = pulse.DriveChannel(0)
        d1 = pulse.DriveChannel(1)
        m0 = pulse.MeasureChannel(0)
        m1 = pulse.MeasureChannel(1)
        a0 = pulse.AcquireChannel(0)
        a1 = pulse.AcquireChannel(1)
        u0 = pulse.ControlChannel(0)
        u1 = pulse.ControlChannel(1)

        reference = pulse.Schedule()
        reference += instructions.Delay(10, d0)
        reference += instructions.Delay(10, d1)
        reference += instructions.Delay(10, m0)
        reference += instructions.Delay(10, m1)
        reference += instructions.Delay(10, a0)
        reference += instructions.Delay(10, a1)
        reference += instructions.Delay(10, u0)
        reference += instructions.Delay(10, u1)

        self.assertEqual(schedule, reference)
    def test_channel_index_sort_grouped_control(self):
        """Test channel_index_grouped_sort_u."""
        out_layout = layouts.channel_index_grouped_sort_u(
            self.channels, formatter=self.formatter, device=self.device)

        ref_channels = [
            [pulse.DriveChannel(0)],
            [pulse.DriveChannel(1)],
            [pulse.MeasureChannel(1)],
            [pulse.AcquireChannel(1)],
            [pulse.DriveChannel(2)],
            [pulse.MeasureChannel(2)],
            [pulse.AcquireChannel(2)],
            [pulse.ControlChannel(0)],
            [pulse.ControlChannel(2)],
            [pulse.ControlChannel(5)],
        ]

        ref_names = [
            "D0", "D1", "M1", "A1", "D2", "M2", "A2", "U0", "U2", "U5"
        ]

        ref = list(zip(ref_names, ref_channels))

        self.assertListEqual(list(out_layout), ref)
示例#6
0
 def setUp(self) -> None:
     super().setUp()
     self.channels = [
         pulse.DriveChannel(0),
         pulse.DriveChannel(1),
         pulse.DriveChannel(2),
         pulse.MeasureChannel(1),
         pulse.MeasureChannel(2),
         pulse.AcquireChannel(1),
         pulse.AcquireChannel(2),
         pulse.ControlChannel(0),
         pulse.ControlChannel(2),
         pulse.ControlChannel(5)
     ]
     self.formatter = {'control.show_acquire_channel': True}
     self.device = device_info.OpenPulseBackendInfo(
         name='test',
         dt=1,
         channel_frequency_map={
             pulse.DriveChannel(0): 5.0e9,
             pulse.DriveChannel(1): 5.1e9,
             pulse.DriveChannel(2): 5.2e9,
             pulse.MeasureChannel(1): 7.0e9,
             pulse.MeasureChannel(1): 7.1e9,
             pulse.MeasureChannel(2): 7.2e9,
             pulse.ControlChannel(0): 5.0e9,
             pulse.ControlChannel(1): 5.1e9,
             pulse.ControlChannel(2): 5.2e9,
             pulse.ControlChannel(3): 5.3e9,
             pulse.ControlChannel(4): 5.4e9,
             pulse.ControlChannel(5): 5.5e9
         },
         qubit_channel_map={
             0: [
                 pulse.DriveChannel(0),
                 pulse.MeasureChannel(0),
                 pulse.AcquireChannel(0),
                 pulse.ControlChannel(0)
             ],
             1: [
                 pulse.DriveChannel(1),
                 pulse.MeasureChannel(1),
                 pulse.AcquireChannel(1),
                 pulse.ControlChannel(1)
             ],
             2: [
                 pulse.DriveChannel(2),
                 pulse.MeasureChannel(2),
                 pulse.AcquireChannel(2),
                 pulse.ControlChannel(2),
                 pulse.ControlChannel(3),
                 pulse.ControlChannel(4)
             ],
             3: [
                 pulse.DriveChannel(3),
                 pulse.MeasureChannel(3),
                 pulse.AcquireChannel(3),
                 pulse.ControlChannel(5)
             ]
         })
示例#7
0
    def test_barrier_on_qubits(self):
        """Test barrier directive on qubits."""
        with pulse.build(self.backend) as schedule:
            pulse.barrier(0, 1)

        reference = pulse.Schedule()
        reference += directives.RelativeBarrier(pulse.DriveChannel(0),
                                                pulse.DriveChannel(1),
                                                pulse.MeasureChannel(0),
                                                pulse.MeasureChannel(1),
                                                pulse.ControlChannel(0),
                                                pulse.ControlChannel(1),
                                                pulse.AcquireChannel(0),
                                                pulse.AcquireChannel(1))
        self.assertEqual(schedule, reference)
示例#8
0
def _disassemble_pulse_schedule(qobj) -> PulseModule:
    run_config = qobj.config.to_dict()
    run_config.pop("pulse_library")

    qubit_lo_freq = run_config.get("qubit_lo_freq")
    if qubit_lo_freq:
        run_config["qubit_lo_freq"] = [freq * 1e9 for freq in qubit_lo_freq]

    meas_lo_freq = run_config.get("meas_lo_freq")
    if meas_lo_freq:
        run_config["meas_lo_freq"] = [freq * 1e9 for freq in meas_lo_freq]

    user_qobj_header = qobj.header.to_dict()

    # extract schedule lo settings
    schedule_los = []
    for program in qobj.experiments:
        program_los = {}
        if hasattr(program, "config"):
            if hasattr(program.config, "qubit_lo_freq"):
                for i, lo in enumerate(program.config.qubit_lo_freq):
                    program_los[pulse.DriveChannel(i)] = lo * 1e9

            if hasattr(program.config, "meas_lo_freq"):
                for i, lo in enumerate(program.config.meas_lo_freq):
                    program_los[pulse.MeasureChannel(i)] = lo * 1e9

        schedule_los.append(program_los)

    if any(schedule_los):
        run_config["schedule_los"] = schedule_los

    return PulseModule((_experiments_to_schedules(qobj), run_config, user_qobj_header))
    def _valid_2q_schedule(self):
        """Returns a valid 2 qubit schedule."""

        valid_pulse = pulse_lib.gaussian(duration=128,
                                         amp=0.5,
                                         sigma=16,
                                         name='valid_pulse')
        valid_meas_pulse = pulse_lib.gaussian_square(duration=1200,
                                                     amp=0.025,
                                                     sigma=4,
                                                     risefall=25,
                                                     name='valid_meas_pulse')
        acq_cmd = pulse.Acquire(duration=10)

        acquires = [pulse.AcquireChannel(0), pulse.AcquireChannel(1)]
        memoryslots = [pulse.MemorySlot(0), pulse.MemorySlot(1)]

        # create measurement schedule
        measure_and_acquire = \
            valid_meas_pulse(pulse.MeasureChannel(0)) | acq_cmd(acquires, memoryslots)

        # add commands to schedule
        schedule = pulse.Schedule(name='valid_exp')

        schedule += valid_pulse(pulse.DriveChannel(0))
        schedule += measure_and_acquire << schedule.duration

        return schedule
示例#10
0
    def test_channel_type_grouped_sort(self):
        """Test channel_type_grouped_sort."""
        out_layout = layouts.channel_type_grouped_sort(
            self.channels, formatter=self.formatter, device=self.device)

        ref_channels = [[pulse.DriveChannel(0)], [pulse.DriveChannel(1)],
                        [pulse.DriveChannel(2)], [pulse.ControlChannel(0)],
                        [pulse.ControlChannel(2)], [pulse.ControlChannel(5)],
                        [pulse.MeasureChannel(1)], [pulse.MeasureChannel(2)],
                        [pulse.AcquireChannel(1)], [pulse.AcquireChannel(2)]]
        ref_names = [
            'D0', 'D1', 'D2', 'U0', 'U2', 'U5', 'M1', 'M2', 'A1', 'A2'
        ]

        ref = list(zip(ref_names, ref_channels))

        self.assertListEqual(list(out_layout), ref)
    def setUp(self):
        self.schedule = pulse.Schedule(name='fake_experiment')
        self.schedule += pulse.FrameChange(0.)(pulse.DriveChannel(0))

        self.backend = FakeOpenPulse2Q()
        self.config = self.backend.configuration()
        self.defaults = self.backend.defaults()
        self.qubit_lo_freq = self.defaults.qubit_freq_est
        self.meas_lo_freq = self.defaults.meas_freq_est
        self.qubit_lo_range = self.config.qubit_lo_range
        self.meas_lo_range = self.config.meas_lo_range
        self.schedule_los = {pulse.DriveChannel(0): self.qubit_lo_freq[0],
                             pulse.DriveChannel(1): self.qubit_lo_freq[1],
                             pulse.MeasureChannel(0): self.meas_lo_freq[0],
                             pulse.MeasureChannel(1): self.meas_lo_freq[1]}
        self.meas_map = self.config.meas_map
        self.memory_slots = self.config.n_qubits
        self.rep_time = self.config.rep_times[0]
示例#12
0
    def test_channel_qubit_index_sort(self):
        """Test qubit_index_sort."""
        out_layout = layouts.qubit_index_sort(self.channels,
                                              formatter=self.formatter,
                                              device=self.device)

        ref_channels = [[pulse.DriveChannel(0), pulse.ControlChannel(0)],
                        [pulse.DriveChannel(1), pulse.MeasureChannel(1)],
                        [pulse.DriveChannel(2), pulse.MeasureChannel(2), pulse.ControlChannel(2)],
                        [pulse.ControlChannel(5)]]

        ref_names = [
            'Q0', 'Q1', 'Q2', 'Q3'
        ]

        ref = list(zip(ref_names, ref_channels))

        self.assertListEqual(list(out_layout), ref)
示例#13
0
    def test_execute_block(self):
        """Test executing a ScheduleBlock on a Pulse backend"""

        with pulse.build(name="test_block") as sched_block:
            pulse.play(pulse.Constant(160, 1.0), pulse.DriveChannel(0))
            pulse.acquire(50, pulse.MeasureChannel(0), pulse.MemorySlot(0))

        backend = FakeArmonk()
        test_result = backend.run(sched_block).result()
        self.assertDictEqual(test_result.get_counts(), {"0": 1024})
示例#14
0
    def setUp(self) -> None:
        super().setUp()

        self.style = stylesheet.QiskitPulseStyle()
        self.device = device_info.OpenPulseBackendInfo(
            name="test",
            dt=1,
            channel_frequency_map={
                pulse.DriveChannel(0): 5.0,
                pulse.MeasureChannel(0): 7.0,
                pulse.ControlChannel(0): 5.0,
            },
            qubit_channel_map={
                0: [
                    pulse.DriveChannel(0),
                    pulse.MeasureChannel(0),
                    pulse.AcquireChannel(0),
                    pulse.ControlChannel(0),
                ]
            },
        )

        # objects
        self.short_pulse = drawings.LineData(
            data_type=types.WaveformType.REAL,
            xvals=[0, 0, 1, 4, 5, 5],
            yvals=[0, 0.5, 0.5, 0.5, 0.5, 0],
            channels=[pulse.DriveChannel(0)],
        )
        self.long_pulse = drawings.LineData(
            data_type=types.WaveformType.REAL,
            xvals=[8, 8, 9, 19, 20, 20],
            yvals=[0, 0.3, 0.3, 0.3, 0.3, 0],
            channels=[pulse.DriveChannel(1)],
        )
        self.abstract_hline = drawings.LineData(
            data_type=types.LineType.BASELINE,
            xvals=[
                types.AbstractCoordinate.LEFT, types.AbstractCoordinate.RIGHT
            ],
            yvals=[0, 0],
            channels=[pulse.DriveChannel(0)],
        )
示例#15
0
    def test_qubit_channels(self):
        """Test getting the qubit channels of the active builder's backend."""
        with pulse.build(self.backend):
            qubit_channels = pulse.qubit_channels(0)

        self.assertEqual(qubit_channels,
                         {pulse.DriveChannel(0),
                          pulse.MeasureChannel(0),
                          pulse.AcquireChannel(0),
                          pulse.ControlChannel(0),
                          pulse.ControlChannel(1)})
示例#16
0
    def setUp(self) -> None:
        super().setUp()
        self.style = stylesheet.QiskitPulseStyle()
        self.device = device_info.OpenPulseBackendInfo(
            name="test",
            dt=1,
            channel_frequency_map={
                pulse.DriveChannel(0): 5.0,
                pulse.MeasureChannel(0): 7.0,
                pulse.ControlChannel(0): 5.0,
            },
            qubit_channel_map={
                0: [
                    pulse.DriveChannel(0),
                    pulse.MeasureChannel(0),
                    pulse.AcquireChannel(0),
                    pulse.ControlChannel(0),
                ]
            },
        )

        self.sched = pulse.Schedule()
        self.sched.insert(
            0,
            pulse.Play(pulse.Waveform([0.0, 0.1, 0.2, 0.3, 0.4, 0.5]),
                       pulse.DriveChannel(0)),
            inplace=True,
        )
        self.sched.insert(
            10,
            pulse.Play(pulse.Waveform([0.5, 0.4, 0.3, 0.2, 0.1, 0.0]),
                       pulse.DriveChannel(0)),
            inplace=True,
        )
        self.sched.insert(
            0,
            pulse.Play(pulse.Waveform([0.3, 0.3, 0.3, 0.3, 0.3, 0.3]),
                       pulse.DriveChannel(1)),
            inplace=True,
        )
    def create_from_backend(cls, backend: BaseBackend):
        """Initialize a class with backend information provided by provider.

        Args:
            backend: Backend object.

        Returns:
            OpenPulseBackendInfo: New configured instance.
        """
        configuration = backend.configuration()
        defaults = backend.defaults()

        # load name
        name = backend.name()

        # load cycle time
        dt = configuration.dt

        # load frequencies
        chan_freqs = dict()

        chan_freqs.update({
            pulse.DriveChannel(qind): freq
            for qind, freq in enumerate(defaults.qubit_freq_est)
        })
        chan_freqs.update({
            pulse.MeasureChannel(qind): freq
            for qind, freq in enumerate(defaults.meas_freq_est)
        })
        for qind, u_lo_mappers in enumerate(configuration.u_channel_lo):
            temp_val = .0 + .0j
            for u_lo_mapper in u_lo_mappers:
                temp_val += defaults.qubit_freq_est[
                    u_lo_mapper.q] * u_lo_mapper.scale
            chan_freqs[pulse.ControlChannel(qind)] = temp_val.real

        # load qubit channel mapping
        qubit_channel_map = defaultdict(list)
        for qind in range(configuration.n_qubits):
            qubit_channel_map[qind].append(configuration.drive(qubit=qind))
            qubit_channel_map[qind].append(configuration.measure(qubit=qind))
            for tind in range(configuration.n_qubits):
                try:
                    qubit_channel_map[qind].extend(
                        configuration.control(qubits=(qind, tind)))
                except BackendConfigurationError:
                    pass

        return OpenPulseBackendInfo(name=name,
                                    dt=dt,
                                    channel_frequency_map=chan_freqs,
                                    qubit_channel_map=qubit_channel_map)
示例#18
0
    def setUp(self):
        self.schedule = pulse.Schedule(name='fake_experiment')
        with self.assertWarns(DeprecationWarning):
            self.schedule += pulse.FrameChange(0.)(pulse.DriveChannel(0))

        self.backend = FakeOpenPulse2Q()
        self.config = self.backend.configuration()
        self.defaults = self.backend.defaults()
        self.qubit_lo_freq = list(self.defaults.qubit_freq_est)
        self.meas_lo_freq = list(self.defaults.meas_freq_est)
        self.qubit_lo_range = self.config.qubit_lo_range
        self.meas_lo_range = self.config.meas_lo_range
        self.schedule_los = {pulse.DriveChannel(0): self.qubit_lo_freq[0],
                             pulse.DriveChannel(1): self.qubit_lo_freq[1],
                             pulse.MeasureChannel(0): self.meas_lo_freq[0],
                             pulse.MeasureChannel(1): self.meas_lo_freq[1]}
        self.meas_map = self.config.meas_map
        self.memory_slots = self.config.n_qubits

        # default rep_time and rep_delay
        self.rep_time = self.config.rep_times[0]
        self.rep_delay = None
示例#19
0
    def test_delay_qubit(self):
        """Test delaying on a qubit macro."""
        with pulse.build(self.backend) as schedule:
            pulse.delay_qubits(10, 0)

        d0 = pulse.DriveChannel(0)
        m0 = pulse.MeasureChannel(0)
        a0 = pulse.AcquireChannel(0)
        u0 = pulse.ControlChannel(0)
        u1 = pulse.ControlChannel(1)

        reference = pulse.Schedule()
        reference += instructions.Delay(10, d0)
        reference += instructions.Delay(10, m0)
        reference += instructions.Delay(10, a0)
        reference += instructions.Delay(10, u0)
        reference += instructions.Delay(10, u1)

        self.assertEqual(schedule, reference)
示例#20
0
def freq_sweep_schedule(qbit, backend_config, drive_chan,
                        meas_samples=1000,):
    dt = backend_config.dt
    print(f"Sampling time: {dt} ns")

    drive_pulse = make_drive_pulse(dt)
    meas_pulse = make_meas_pulse(dt, samples=meas_samples)
    ### Construct the acquire pulse to trigger the acquisition
    # Acquire pulse samples
    acq_cmd = pulse.Acquire(duration=meas_samples)
    # Find out which group of qubits need to be acquired with this qubit
    meas_map_idx = None
    for i, measure_group in enumerate(backend_config.meas_map):
        if qbit in measure_group:
            meas_map_idx = i
            break
    assert meas_map_idx is not None, f"Couldn't find qubit {qbit} in the meas_map!"


    ### Collect the necessary channels
    #drive_chan = pulse.DriveChannel(qbit)
    meas_chan = pulse.MeasureChannel(qbit)
    #acq_chan = pulse.AcquireChannel(qbit)

    schedule = pulse.Schedule(name='Frequency sweep')
    schedule += drive_pulse(drive_chan)
    measure_schedule = meas_pulse(meas_chan)
    # Trigger data acquisition, and store measured values into respective memory slots
    measure_schedule += acq_cmd([pulse.AcquireChannel(i) for i 
                                 in backend_config.meas_map[meas_map_idx]],
                                [pulse.MemorySlot(i) for i 
                                 in backend_config.meas_map[meas_map_idx]])

    # shift the start time of the schedule by some duration
    schedule += measure_schedule << schedule.duration
    schedule += drive_pulse(drive_chan)<< schedule.duration - drive_pulse.duration
    schedule += measure_schedule << drive_pulse.duration

    return schedule
示例#21
0
GHz = 1.0e9  # Gigahertz
MHz = 1.0e6  # Megahertz
us = 1.0e-6  # Microseconds
ns = 1.0e-9  # Nanoseconds
scale_factor = 1e-14

NUM_SHOTS = 8192
qubit = 0
default_qubit_freq = backend_defaults.qubit_freq_est[
    qubit]  # Default qubit frequency in Hz.
print(
    f"Qubit {qubit} has an estimated frequency of {default_qubit_freq/ GHz} GHz."
)

drive_chan = pulse.DriveChannel(qubit)
meas_chan = pulse.MeasureChannel(qubit)
acq_chan = pulse.AcquireChannel(qubit)


def get_job_data(job, average):
    """Retrieve data from a job that has already run.
    Args:
        job (Job): The job whose data you want.
        average (bool): If True, gets the data assuming data is an average.
                        If False, gets the data assuming it is for single shots.
    Return:
        list: List containing job result data. 
    """
    job_results = job.result(timeout=120)  # timeout parameter set to 120 s
    result_data = []
    for i in range(len(job_results.results)):
示例#22
0
def cr_drive_experiments(drive_idx,
                         target_idx,
                         flip_drive_qubit = False,

                         #cr_drive_amps=np.linspace(0, 0.9, 16),
                         #cr_drive_samples=800,
                         #cr_drive_sigma=4,
                         #pi_drive_samples=128,
                         #pi_drive_sigma=16
                         #meas_amp = Dims/128*0.025/2
                         #meas_width = int(rows/128*1150/2)
                         cr_drive_amps=np.linspace(0, 0.9, meas_width**2),
                         cr_drive_samples=sum(label1[:] == label2[:]),
                         cr_drive_sigma=meas_sigma,
                         pi_drive_samples=sum((label1[:] ==1)*(label2[:] ==1)), #label1[:] ==1 and label2[:] ==1
                         pi_drive_sigma=cr_drive_sigma**2):
    """Generate schedules corresponding to CR drive experiments.

    Args:
        drive_idx (int): label of driven qubit
        target_idx (int): label of target qubit
        flip_drive_qubit (bool): whether or not to start the driven qubit in the ground or excited state
        cr_drive_amps (array): list of drive amplitudes to use
        cr_drive_samples (int): number samples for each CR drive signal
        cr_drive_sigma (float): standard deviation of CR Gaussian pulse
        pi_drive_samples (int): number samples for pi pulse on drive
        pi_drive_sigma (float): standard deviation of Gaussian pi pulse on drive

    Returns:
        list[Schedule]: A list of Schedule objects for each experiment
    """

    # Construct measurement commands to be used for all schedules
    #meas_amp = 0.025
    #meas_samples = 1200
    #meas_sigma = 4
    #meas_width = 1150
    meas_amp = 0.025
    meas_sigma = 4
    ni = int(np.ceil(cols/meas_sigma))
    print(ni)
    meas_samples = rows*ni
    meas_width = int(rows*ni*23/24)
    meas_pulse = GaussianSquare(duration=meas_samples, amp=meas_amp/np.linalg.norm(meas_amp),
                               sigma=meas_sigma, width=meas_width)

    acq_sched = pulse.Acquire(meas_samples, pulse.AcquireChannel(0), pulse.MemorySlot(0))
    acq_sched += pulse.Acquire(meas_samples, pulse.AcquireChannel(1), pulse.MemorySlot(1))

    # create measurement schedule
    measure_sched = (pulse.Play(meas_pulse, pulse.MeasureChannel(0)) |
                     pulse.Play(meas_pulse, pulse.MeasureChannel(1))|
                     acq_sched)

    # Create schedule
    schedules = []
    for ii, cr_drive_amp in enumerate(cr_drive_amps):

        # pulse for flipping drive qubit if desired
        pi_pulse = Gaussian(duration=pi_drive_samples, amp=pi_amps[drive_idx], sigma=pi_drive_sigma)

        # cr drive pulse
        cr_width = cr_drive_samples - 2*cr_drive_sigma*4
        cr_rabi_pulse = GaussianSquare(duration=cr_drive_samples,
                                       amp=cr_drive_amp/np.linalg.norm(cr_drive_amp),
                                       sigma=cr_drive_sigma,
                                       width=cr_width)

        # add commands to schedule
        schedule = pulse.Schedule(name='cr_rabi_exp_amp_%s' % cr_drive_amp)
        #schedule = pulse.Schedule(name='cr_rabi_exp_amp_%s' % cr_drive_amp/np.linalg.norm(cr_drive_amp))

        # flip drive qubit if desired
        if flip_drive_qubit:
            schedule += pulse.Play(pi_pulse, pulse.DriveChannel(drive_idx))

        # do cr drive
        # First, get the ControlChannel index for CR drive from drive to target
        cr_idx = two_qubit_model.control_channel_index((drive_idx, target_idx))
        schedule += pulse.Play(cr_rabi_pulse, pulse.ControlChannel(cr_idx))  << schedule.duration


        schedule += measure_sched << schedule.duration

        schedules.append(schedule)
    return schedules
示例#23
0
qubits = [0, 1]
# Construct a measurement schedule and add it to an InstructionScheduleMap
meas_amp = 0.025
meas_sigma = 4
ni = int(np.ceil(cols/meas_sigma))
print(ni)
meas_samples = rows*ni
meas_width = int(rows*ni*23/24)

meas_pulse = GaussianSquare(duration=meas_samples, amp=meas_amp,
                            sigma=meas_sigma, width=meas_width)

acq_sched = pulse.Acquire(meas_samples, pulse.AcquireChannel(0), pulse.MemorySlot(0))
acq_sched += pulse.Acquire(meas_samples, pulse.AcquireChannel(1), pulse.MemorySlot(1))

measure_sched = pulse.Play(meas_pulse, pulse.MeasureChannel(0)) | pulse.Play(meas_pulse, pulse.MeasureChannel(1)) | acq_sched

inst_map = pulse.InstructionScheduleMap()
inst_map.add('measure', qubits, measure_sched)

#Rabi schedules
#recall: Rabii oscillation
# The magnetic moment is thus {\displaystyle {\boldsymbol {\mu }}={\frac {\hbar }{2}}\gamma {\boldsymbol {\sigma }}}{\boldsymbol {\mu }}={\frac {\hbar }{2}}\gamma {\boldsymbol {\sigma }}. 
# The Hamiltonian of this system is then given by {H} =-{{\mu }}\cdot{B} =-{\frac {\hbar }{2}}\omega _{0}\sigma _{z}-{\frac {\hbar }{2}}\omega _{1}(\sigma _{x}\cos \omega t-\sigma _{y}\sin \omega t)}\mathbf {H} =-{\boldsymbol {\mu }}\cdot \mathbf {B} =-{\frac {\hbar }{2}}\omega _{0}\sigma _{z}-{\frac {\hbar }{2}}\omega _{1}(\sigma _{x}\cos \omega t-\sigma _{y}\sin \omega t) where {\displaystyle \omega _{0}=\gamma B_{0}}\omega _{0}=\gamma B_{0} and {\displaystyle \omega _{1}=\gamma B_{1}}\omega _{1}=\gamma B_{1}
# Now, let the qubit be in state {\displaystyle |0\rangle }{\displaystyle |0\rangle } at time {\displaystyle t=0}t=0. Then, at time {\displaystyle t}t, the probability of it being found in state {\displaystyle |1\rangle }|1\rangle  is given by {\displaystyle P_{0\to 1}(t)=\left({\frac {\omega _{1}}{\Omega }}\right)^{2}\sin ^{2}\left({\frac {\Omega t}{2}}\right)}{\displaystyle P_{0\to 1}(t)=\left({\frac {\omega _{1}}{\Omega }}\right)^{2}\sin ^{2}\left({\frac {\Omega t}{2}}\right)} where {\displaystyle \Omega ={\sqrt {(\omega -\omega _{0})^{2}+\omega _{1}^{2}}}}\Omega ={\sqrt {(\omega -\omega _{0})^{2}+\omega _{1}^{2}}}
# the qubit oscillates between the {\displaystyle |0\rangle }|0\rang and {\displaystyle |1\rangle }|1\rangle  states. 
# The maximum amplitude for oscillation is achieved at {\displaystyle \omega =\omega _{0}}\omega =\omega _{0}, which is the condition for resonance. 
# At resonance, the transition probability is given by {\displaystyle P_{0\to 1}(t)=\sin ^{2}\left({\frac {\omega _{1}t}{2}}\right)}{\displaystyle P_{0\to 1}(t)=\sin ^{2}\left({\frac {\omega _{1}t}{2}}\right)}

# pi pulse: 
# To go from state {\displaystyle |0\rangle }|0\rang to state {\displaystyle |1\rangle }|1\rangle  it is sufficient to adjust the time {\displaystyle t}t during which the rotating field acts such that {\displaystyle {\frac {\omega _{1}t}{2}}={\frac {\pi }{2}}}{\frac {\omega _{1}t}{2}}={\frac {\pi }{2}} or {\displaystyle t={\frac {\pi }{\omega _{1}}}}t={\frac {\pi }{\omega _{1}}}
示例#24
0
 def test_measure_channel(self):
     """Text context builder measure channel."""
     with pulse.build(self.backend):
         self.assertEqual(pulse.measure_channel(0), pulse.MeasureChannel(0))