def sample_schedule(self):
        """Generate a sample schedule that includes the most common elements of
           pulse schedules."""
        gp0 = pulse_lib.gaussian(duration=20, amp=1.0, sigma=1.0)
        gp1 = pulse_lib.gaussian(duration=20, amp=-1.0, sigma=2.0)
        gs0 = pulse_lib.gaussian_square(duration=20,
                                        amp=-1.0,
                                        sigma=2.0,
                                        risefall=3)

        fc_pi_2 = FrameChange(phase=1.57)
        acquire = Acquire(10)
        sched = Schedule()
        sched = sched.append(gp0(self.device.q[0].drive))
        sched = sched.insert(
            0,
            PersistentValue(value=0.2 + 0.4j)(self.device.q[0].controls[0]))
        sched = sched.insert(60,
                             FrameChange(phase=-1.57)(self.device.q[0].drive))
        sched = sched.insert(30, gp1(self.device.q[1].drive))
        sched = sched.insert(60, gp0(self.device.q[0].controls[0]))
        sched = sched.insert(60, gs0(self.device.q[0].measure))
        sched = sched.insert(90, fc_pi_2(self.device.q[0].drive))
        sched = sched.insert(
            90, acquire(self.device.q[1], self.device.mem[1],
                        self.device.c[1]))
        sched = sched + sched
        sched |= Snapshot("snapshot_1", "snap_type") << 60
        sched |= Snapshot("snapshot_2", "snap_type") << 120
        return sched
    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
    def sample_schedule(self):
        """Generate a sample schedule that includes the most common elements of
           pulse schedules."""
        gp0 = pulse_lib.gaussian(duration=20, amp=1.0, sigma=1.0)
        gp1 = pulse_lib.gaussian(duration=20, amp=-1.0, sigma=2.0)
        gs0 = pulse_lib.gaussian_square(duration=20,
                                        amp=-1.0,
                                        sigma=2.0,
                                        risefall=3)

        fc_pi_2 = FrameChange(phase=1.57)
        acquire = Acquire(10)
        delay = Delay(100)
        sched = Schedule()
        sched = sched.append(gp0(DriveChannel(0)))
        sched = sched.insert(
            0,
            pulse_lib.ConstantPulse(duration=60,
                                    amp=0.2 + 0.4j)(ControlChannel(0)))
        sched = sched.insert(60, FrameChange(phase=-1.57)(DriveChannel(0)))
        sched = sched.insert(60, SetFrequency(8.0, DriveChannel(0)))
        sched = sched.insert(30, gp1(DriveChannel(1)))
        sched = sched.insert(60, gp0(ControlChannel(0)))
        sched = sched.insert(60, gs0(MeasureChannel(0)))
        sched = sched.insert(90, fc_pi_2(DriveChannel(0)))
        sched = sched.insert(
            90, acquire(AcquireChannel(1), MemorySlot(1), RegisterSlot(1)))
        sched = sched.append(delay(DriveChannel(0)))
        sched = sched + sched
        sched |= Snapshot("snapshot_1", "snap_type") << 60
        sched |= Snapshot("snapshot_2", "snap_type") << 120
        return sched
Exemple #4
0
    def _valid_2q_schedule(self):
        """ Helper method to make a valid 2 qubit schedule
        Returns:
            schedule (pulse schedule): schedule for 2q experiment
        """
        rabi_pulse = pulse_lib.gaussian(duration=128,
                                        amp=0.5,
                                        sigma=16,
                                        name='rabi_pulse')
        meas_pulse = pulse_lib.gaussian_square(duration=1200,
                                               amp=0.025,
                                               sigma=4,
                                               risefall=25,
                                               name='meas_pulse')
        acq_cmd = pulse.Acquire(duration=10)

        # create measurement schedule
        measure_and_acquire = \
            meas_pulse(self.system.qubits[0].measure) | acq_cmd(self.system.acquires,
                       self.system.memoryslots)

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

        schedule += rabi_pulse(self.system.qubits[0].drive)
        schedule += measure_and_acquire << schedule.duration

        return schedule
 def test_gaussian_square(self):
     """Test discrete sampled gaussian square pulse."""
     amp = 0.5
     sigma = 0.1
     risefall = 2
     duration = 10
     center = duration/2
     width = duration-2*risefall
     center = duration/2
     times = np.arange(0, duration)
     gaussian_square_ref = continuous.gaussian_square(times, amp, center, width, sigma)
     gaussian_square_pulse = pulse_lib.gaussian_square(duration, amp, sigma, risefall)
     self.assertIsInstance(gaussian_square_pulse, SamplePulse)
     np.testing.assert_array_almost_equal(gaussian_square_pulse.samples, gaussian_square_ref)
 def test_gaussian_square_args(self):
     """Gaussian square allows the user to specify risefall or width. Test this."""
     amp = 0.5
     sigma = 0.1
     duration = 10
     # risefall and width consistent: no error
     pulse_lib.gaussian_square(duration, amp, sigma, 2, width=6)
     # supply width instead: no error
     pulse_lib.gaussian_square(duration, amp, sigma, width=6)
     with self.assertRaises(PulseError):
         pulse_lib.gaussian_square(duration,
                                   amp,
                                   sigma,
                                   width=2,
                                   risefall=2)
     with self.assertRaises(PulseError):
         pulse_lib.gaussian_square(duration, amp, sigma)
Exemple #7
0
def make_meas_pulse(dt, samples=1000, sigma=7, amp=.25):
    meas_samples_ns = samples
    meas_sigma_ns = sigma*int(10*dt)
    # The width of the gaussian part of the rise and fall
    meas_risefall_ns = 100
    # and the truncating parameter: how many samples to dedicate to the risefall

    meas_samples = get_closest_multiple_of_16(meas_samples_ns / dt)
    meas_sigma = get_closest_multiple_of_16(meas_sigma_ns / dt)       # The width of the gaussian part in units of dt
    meas_risefall = get_closest_multiple_of_16(meas_risefall_ns / dt) # The truncating parameter in units of dt

    meas_amp = amp
    # Measurement pulse samples
    meas_pulse = pulse_lib.gaussian_square(duration=meas_samples,
                                           sigma=meas_sigma,
                                           amp=meas_amp,
                                           risefall=meas_risefall,
                                           name='measurement_pulse')
    return meas_pulse
Exemple #8
0
            break
    assert meas_map_idx is not None, f"Couldn't find qubit {qubit} in the meas_map!"

    inst_sched_map = backend_defaults.instruction_schedule_map
    measure_schedule = inst_sched_map.get("measure", qubits=[qubit])
    drive_chan = pulse.DriveChannel(qubit)
    """

    rabi_programs_dic_I = {}
    for idx, pulse_amplitude in enumerate(pulse_amp_array):
        rabi_schedules_I = []
        for duration_pulse in pulse_times[idx]:
            drive_pulse = pulse_lib.gaussian_square(
                duration=duration_pulse,
                sigma=1,
                amp=pulse_amplitude,
                risefall=1,
                name=f"square_pulse_{duration_pulse}",
            )
            """
            schedule = pulse.Schedule(name=str(duration_pulse))
            schedule |= (
                    Play(drive_pulse, pulse.DriveChannel(qubit)) << schedule.duration
            )
            schedule += measure_schedule << schedule.duration
            rabi_schedules_I.append(schedule)
            
        rabi_experiment_program_I = assemble(
            rabi_schedules_I,
            backend=backend,
            meas_level=2,
Exemple #9
0
meas_amp = 0.2


# In[58]:


acq_cmd = pulse.Acquire(duration=meas_samples)


# In[59]:


meas_pulse = pulse_lib.gaussian_square(duration=meas_samples,
                                       sigma=meas_sigma,
                                       amp=meas_amp,
                                       risefall=meas_risefall,
                                       name='measurement_pulse')

measure_schedule = meas_pulse(meas_chan)<<measure_time
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]])


# In[64]:


measure_schedule.draw(plot_range=[0,25000],channels_to_plot=[drive_chan, meas_chan], label=True, scaling=1.0)


# In[65]:
            measurement_risefall_us = 0.1  # Truncating parameter: how many samples to dedicate to the risefall

            # Convert to machine format
            measurement_sigma = get_closest_multiple_of_16(
                measurement_sigma_us * 1e-6 / dt)
            measurement_risefall = get_closest_multiple_of_16(
                measurement_risefall_us * 1e-6 / dt)
            measurement_samples = get_closest_multiple_of_16(
                measurement_samples_us * 1e-6 / dt)
            print("DURATION:", measurement_samples_us, " a.u.")

            # Define measurement pulse
            measurement_pulse = pulse_lib.gaussian_square(
                duration=measurement_samples,
                sigma=measurement_sigma,
                amp=measurement_amp,
                risefall=measurement_risefall,
                name="measurement_pulse",
            )

            # Import backend configurations
            backend_config = backend.configuration()

            # Set measurement channels
            meas_chan = pulse.MeasureChannel(qubit)
            acq_chan = pulse.AcquireChannel(qubit)

            # Add a measurement stimulus on the measure channel pulse to trigger readout
            measure_schedule = pulse.Play(measurement_pulse, meas_chan)

            # Trigger data acquisition, and store measured values into respective memory slots
 def get_sample_pulse(self) -> SamplePulse:
     return gaussian_square(duration=self.duration, amp=self.amp,
                            width=self.width, sigma=self.sigma,
                            zero_ends=False)