示例#1
0
    def setUp(self):
        """Setup the tests."""
        super().setUp()
        library = FixedFrequencyTransmon()

        self.backend = FakeArmonk()
        self.cals = Calibrations.from_backend(self.backend, library)
    def test_update_calibrations(self):
        """Test that we can properly update an instance of Calibrations."""

        freq01 = FakeArmonk().defaults().qubit_freq_est[0]

        backend = MockIQBackend(
            experiment_helper=SpectroscopyHelper(freq_offset=5e6, line_width=2e6),
            iq_cluster_centers=[((-1.0, -1.0), (1.0, 1.0))],
            iq_cluster_width=[0.2],
        )
        backend._configuration.basis_gates = ["x"]
        backend._configuration.timing_constraints = {"granularity": 16}

        backend.defaults().qubit_freq_est = [freq01, freq01]

        library = FixedFrequencyTransmon(basis_gates=["x", "sx"])
        cals = Calibrations.from_backend(FakeArmonk(), libraries=[library])

        prev_freq = cals.get_parameter_value(cals.__drive_freq_parameter__, (0,))
        self.assertEqual(prev_freq, freq01)

        frequencies = np.linspace(freq01 - 10.0e6, freq01 + 10.0e6, 21)

        expdata = RoughFrequencyCal(0, cals, frequencies).run(backend)
        self.assertExperimentDone(expdata)

        # Check the updated frequency which should be shifted by 5MHz.
        post_freq = cals.get_parameter_value(cals.__drive_freq_parameter__, (0,))
        self.assertTrue(abs(post_freq - freq01 - 5e6) < 1e6)
    def setUp(self):
        """Setup the test."""
        super().setUp()

        library = FixedFrequencyTransmon()
        self.backend = MockIQBackend(FineDragHelper())
        self.cals = Calibrations.from_backend(self.backend, libraries=[library])
示例#4
0
    def setUp(self):
        """Setup the tests"""
        super().setUp()

        library = FixedFrequencyTransmon()

        self.backend = MockFineAmp(-np.pi * 0.07, np.pi, "xp")
        self.cals = Calibrations.from_backend(self.backend, library)
示例#5
0
 def test_experiment_config(self):
     """Test converting to and from config works"""
     cals = Calibrations.from_backend(FakeArmonk())
     frequencies = [1, 2, 3]
     exp = RoughFrequencyCal(0, cals, frequencies)
     loaded_exp = RoughFrequencyCal.from_config(exp.config())
     self.assertNotEqual(exp, loaded_exp)
     self.assertTrue(self.json_equiv(exp, loaded_exp))
示例#6
0
    def setUp(self):
        """Setup the tests"""
        super().setUp()

        library = FixedFrequencyTransmon()

        self.backend = DragBackend(gate_name="Drag(x)")
        self.cals = Calibrations.from_backend(self.backend, library)
        self.test_tol = 0.05
示例#7
0
    def setUp(self):
        """Setup the tests"""
        super().setUp()

        library = FixedFrequencyTransmon()

        self.backend = MockIQBackend(FineAmpHelper(-np.pi * 0.07, np.pi, "xp"))
        self.backend.configuration().basis_gates.append("sx")
        self.backend.configuration().basis_gates.append("x")
        self.cals = Calibrations.from_backend(self.backend, libraries=[library])
示例#8
0
    def setUp(self):
        """Setup the tests"""
        super().setUp()

        library = FixedFrequencyTransmon()

        self.backend = MockIQBackend(DragHelper(gate_name="Drag(x)"))
        self.cals = Calibrations.from_backend(self.backend,
                                              libraries=[library])
        self.test_tol = 0.05
    def setUp(self):
        """Setup for the test."""
        super().setUp()
        self.inst_map = pulse.InstructionScheduleMap()

        self.sx_duration = 160

        with pulse.build(name="sx") as sx_sched:
            pulse.play(pulse.Gaussian(self.sx_duration, 0.5, 40), pulse.DriveChannel(0))

        self.inst_map.add("sx", 0, sx_sched)

        self.cals = Calibrations.from_backend(FakeArmonk(), libraries=[FixedFrequencyTransmon()])
    def test_init(self):
        """Test that initialization."""

        qubit = 1
        cals = Calibrations.from_backend(FakeArmonk())
        frequencies = [1000, 2000, 3000]
        auto_update = False
        absolute = False

        freq = RoughFrequencyCal(
            qubit, cals, frequencies, auto_update=auto_update, absolute=absolute
        )

        self.assertEqual(freq.physical_qubits, (qubit,))
        self.assertEqual(freq._frequencies, frequencies)
        self.assertEqual(freq._absolute, False)
        self.assertEqual(freq.auto_update, False)
示例#11
0
    def setUp(self):
        """Setup the tests"""
        super().setUp()

        library = FixedFrequencyTransmon()

        self.backend = FakeArmonk()
        self.cals = Calibrations.from_backend(self.backend, library)

        # Add some pulses on the 1-2 transition.
        d0 = pulse.DriveChannel(0)
        with pulse.build(name="x12") as x12:
            with pulse.frequency_offset(-300e6, d0):
                pulse.play(pulse.Drag(160, Parameter("amp"), 40, 0.0), d0)

        with pulse.build(name="sx12") as sx12:
            with pulse.frequency_offset(-300e6, d0):
                pulse.play(pulse.Drag(160, Parameter("amp"), 40, 0.0), d0)

        self.cals.add_schedule(x12, 0)
        self.cals.add_schedule(sx12, 0)
        self.cals.add_parameter_value(0.4, "amp", 0, "x12")
        self.cals.add_parameter_value(0.2, "amp", 0, "sx12")
示例#12
0
    def test_update_calibrations(self):
        """Test that we can properly update an instance of Calibrations."""

        freq01 = FakeArmonk().defaults().qubit_freq_est[0]

        backend = SpectroscopyBackend(freq_offset=5e6, line_width=2e6)
        backend.defaults().qubit_freq_est = [freq01, freq01]

        library = FixedFrequencyTransmon(basis_gates=["x", "sx"])
        cals = Calibrations.from_backend(FakeArmonk(), library=library)

        prev_freq = cals.get_parameter_value(cals.__drive_freq_parameter__,
                                             (0, ))
        self.assertEqual(prev_freq, freq01)

        frequencies = np.linspace(freq01 - 10.0e6, freq01 + 10.0e6, 21)

        RoughFrequencyCal(0, cals,
                          frequencies).run(backend).block_for_results()

        # Check the updated frequency which should be shifted by 5MHz.
        post_freq = cals.get_parameter_value(cals.__drive_freq_parameter__,
                                             (0, ))
        self.assertTrue(abs(post_freq - freq01 - 5e6) < 1e6)