Exemplo n.º 1
0
 def test_parametric_commands_in_sched(self):
     """Test that schedules can be built with parametric commands."""
     sched = Schedule(name='test_parametric')
     sched += Play(Gaussian(duration=25, sigma=4, amp=0.5j),
                   DriveChannel(0))
     sched += Play(Drag(duration=25, amp=0.2 + 0.3j, sigma=7.8, beta=4),
                   DriveChannel(1))
     sched += Play(Constant(duration=25, amp=1), DriveChannel(2))
     sched_duration = sched.duration
     sched += Play(
         GaussianSquare(duration=1500, amp=0.2, sigma=8, width=140),
         MeasureChannel(0)) << sched_duration
     self.assertEqual(sched.duration, 1525)
     self.assertTrue('sigma' in sched.instructions[0][1].pulse.parameters)
    def test_clbits_of_calibrated_measurements(self):
        """Test that calibrated measurements are only used when the classical bits also match."""
        q = QuantumRegister(2)
        c = ClassicalRegister(2)
        qc = QuantumCircuit(q, c)
        qc.measure(q[0], c[1])

        meas_sched = Play(Gaussian(1200, 0.2, 4), MeasureChannel(0))
        meas_sched |= Acquire(1200, AcquireChannel(0), MemorySlot(0))
        qc.add_calibration("measure", [0], meas_sched)

        sched = schedule(qc, self.backend)
        # Doesn't use the calibrated schedule because the classical memory slots do not match
        expected = Schedule(macros.measure([0], self.backend, qubit_mem_slots={0: 1}))
        self.assertEqual(sched.instructions, expected.instructions)
    def test_calibrated_measurements(self):
        """Test scheduling calibrated measurements."""
        q = QuantumRegister(2)
        c = ClassicalRegister(2)
        qc = QuantumCircuit(q, c)
        qc.append(U2Gate(0, 0), [q[0]])
        qc.measure(q[0], c[0])

        meas_sched = Play(Gaussian(1200, 0.2, 4), MeasureChannel(0))
        meas_sched |= Acquire(1200, AcquireChannel(0), MemorySlot(0))
        qc.add_calibration("measure", [0], meas_sched)

        sched = schedule(qc, self.backend)
        expected = Schedule(self.inst_map.get("u2", [0], 0, 0), (2, meas_sched))
        self.assertEqual(sched.instructions, expected.instructions)
Exemplo n.º 4
0
 def test_repr(self):
     """Test the repr methods for parametric pulses."""
     gaussian = Gaussian(duration=25, amp=0.7, sigma=4)
     self.assertEqual(repr(gaussian),
                      'Gaussian(duration=25, amp=(0.7+0j), sigma=4)')
     gaus_square = GaussianSquare(duration=20, sigma=30, amp=1.0, width=3)
     self.assertEqual(
         repr(gaus_square),
         'GaussianSquare(duration=20, amp=(1+0j), sigma=30, width=3)')
     drag = Drag(duration=5, amp=0.5, sigma=7, beta=1)
     self.assertEqual(repr(drag),
                      'Drag(duration=5, amp=(0.5+0j), sigma=7, beta=1)')
     const = ConstantPulse(duration=150, amp=0.1 + 0.4j)
     self.assertEqual(repr(const),
                      'ConstantPulse(duration=150, amp=(0.1+0.4j))')
    def test_subset_calibrated_measurements(self):
        """Test that measurement calibrations can be added and used for some qubits, even
        if the other qubits do not also have calibrated measurements."""
        qc = QuantumCircuit(3, 3)
        qc.measure(0, 0)
        qc.measure(1, 1)
        qc.measure(2, 2)
        meas_scheds = []
        for qubit in [0, 2]:
            meas = (Play(Gaussian(1200, 0.2, 4), MeasureChannel(qubit)) +
                    Acquire(1200, AcquireChannel(qubit), MemorySlot(qubit)))
            meas_scheds.append(meas)
            qc.add_calibration('measure', [qubit], meas)

        meas = macros.measure([1], FakeOpenPulse3Q())
        meas = meas.exclude(channels=[AcquireChannel(0), AcquireChannel(2)])
        sched = schedule(qc, FakeOpenPulse3Q())
        expected = Schedule(meas_scheds[0], meas_scheds[1], meas)
        self.assertEqual(sched.instructions, expected.instructions)
Exemplo n.º 6
0
def model_and_pi_schedule():
    """Return a simple model and schedule for pulse simulation"""

    # construct model
    model = duffing_system_model(dim_oscillators=2,
                                 oscillator_freqs=[5.0],
                                 anharm_freqs=[0],
                                 drive_strengths=[1.0],
                                 coupling_dict={},
                                 dt=1.0)

    # note: parameters set so that area under curve is 1/4
    gauss_pulse = Gaussian(duration=10,
                           amp=(1.0 / 4) / 2.506627719963857,
                           sigma=1)

    # construct schedule
    schedule = Schedule(name='test_sched')
    schedule |= Play(gauss_pulse, DriveChannel(0))
    schedule += Acquire(10, AcquireChannel(0),
                        MemorySlot(0)) << schedule.duration

    return model, schedule
Exemplo n.º 7
0
 def test_construction(self):
     """Test that parametric pulses can be constructed without error."""
     Gaussian(duration=25, sigma=4, amp=0.5j)
     GaussianSquare(duration=150, amp=0.2, sigma=8, width=140)
     ConstantPulse(duration=150, amp=0.1 + 0.4j)
     Drag(duration=25, amp=0.2 + 0.3j, sigma=7.8, beta=4)