Ejemplo n.º 1
0
    def test_t2(self):
        """
        Run the simulator with thermal relaxation noise.
        Then verify that the calculated T2 matches the t2 parameter.
        """

        backend_result, xdata, qubits, t2_value = t2_circuit_execution()

        T2Fitter(backend_result, xdata, qubits,
                 fit_p0=[1, t2_value, -0.5],
                 fit_bounds=([0, 0, -1], [2, t2_value*1.2, 1]))
Ejemplo n.º 2
0
    def test_t2(self):
        """
        Run the simulator with dephasing noise.
        Then verify that the calculated T2 matches the dephasing parameter.
        """

        # 25 numbers ranging from 1 to 200, linearly spaced
        num_of_gates = (np.linspace(1, 300, 35)).astype(int)
        gate_time = 0.11
        num_of_qubits = 2
        qubit = 0

        circs, xdata = t2_circuits(num_of_gates, gate_time, num_of_qubits,
                                   qubit)

        expected_t2 = 20
        gamma = 1 - np.exp(-2 * gate_time / expected_t2)
        error = phase_damping_error(gamma)
        noise_model = NoiseModel()
        noise_model.add_all_qubit_quantum_error(error, 'id')
        # TODO: Include SPAM errors

        backend = qiskit.Aer.get_backend('qasm_simulator')
        shots = 300
        backend_result = qiskit.execute(circs,
                                        backend,
                                        shots=shots,
                                        backend_options={
                                            'max_parallel_experiments': 0
                                        },
                                        noise_model=noise_model).result()

        initial_t2 = expected_t2
        initial_a = 1
        initial_c = 0.5 * (-1)

        fit = T2Fitter(backend_result,
                       shots,
                       xdata,
                       num_of_qubits,
                       qubit,
                       fit_p0=[initial_a, initial_t2, initial_c],
                       fit_bounds=([0, 0, -1], [2, expected_t2 * 1.2, 1]))

        self.assertAlmostEqual(fit.time,
                               expected_t2,
                               delta=4,
                               msg='Calculated T2 is inaccurate')
        self.assertTrue(
            fit.time_err < 5,
            'Confidence in T2 calculation is too low: ' + str(fit.time_err))
Ejemplo n.º 3
0
    def test_t2(self):
        """
        Run the simulator with thermal relaxation noise.
        Then verify that the calculated T2 matches the t2 parameter.
        """

        num_of_gates = (np.linspace(1, 30, 30)).astype(int)
        gate_time = 0.11
        qubits = [0]
        n_echos = 5
        alt_phase_echo = True

        circs, xdata = t2_circuits(num_of_gates, gate_time, qubits,
                                   n_echos, alt_phase_echo)

        expected_t2 = 20
        error = thermal_relaxation_error(np.inf, expected_t2, gate_time, 0.5)
        noise_model = NoiseModel()
        noise_model.add_all_qubit_quantum_error(error, 'id')
        # TODO: Include SPAM errors

        backend = qiskit.Aer.get_backend('qasm_simulator')
        shots = 300
        backend_result = qiskit.execute(
            circs, backend,
            shots=shots,
            backend_options={'max_parallel_experiments': 0},
            noise_model=noise_model).result()

        initial_t2 = expected_t2
        initial_a = 1
        initial_c = 0.5*(-1)

        fit = T2Fitter(backend_result, xdata, qubits,
                       fit_p0=[initial_a, initial_t2, initial_c],
                       fit_bounds=([0, 0, -1], [2, expected_t2*1.2, 1]))

        self.assertAlmostEqual(fit.time(qid=0), expected_t2, delta=5,
                               msg='Calculated T2 is inaccurate')
        self.assertTrue(
            fit.time_err(qid=0) < 5,
            'Confidence in T2 calculation is too low: ' + str(fit.time_err))
Ejemplo n.º 4
0
    def test_t2(self):
        """
        Run the simulator with thermal relaxation noise.
        Then verify that the calculated T2 matches the t2 parameter.
        """

        num_of_gates = (np.linspace(1, 30, 10)).astype(int)
        gate_time = 0.11
        qubits = [0]
        n_echos = 5
        alt_phase_echo = True

        circs, xdata = t2_circuits(num_of_gates, gate_time, qubits, n_echos,
                                   alt_phase_echo)

        expected_t2 = 20
        error = thermal_relaxation_error(np.inf, expected_t2, gate_time, 0.5)
        noise_model = NoiseModel()
        noise_model.add_all_qubit_quantum_error(error, 'id')
        # TODO: Include SPAM errors

        backend = qiskit.Aer.get_backend('qasm_simulator')
        shots = 100
        backend_result = qiskit.execute(circs,
                                        backend,
                                        shots=shots,
                                        seed_simulator=SEED,
                                        backend_options={
                                            'max_parallel_experiments': 0
                                        },
                                        noise_model=noise_model,
                                        optimization_level=0).result()

        initial_t2 = expected_t2
        initial_a = 1
        initial_c = 0.5 * (-1)

        T2Fitter(backend_result,
                 xdata,
                 qubits,
                 fit_p0=[initial_a, initial_t2, initial_c],
                 fit_bounds=([0, 0, -1], [2, expected_t2 * 1.2, 1]))
Ejemplo n.º 5
0
    def test_t2star(self):
        """
        Run the simulator with thermal relaxation noise.
        Then verify that the calculated T2star matches the t2
        parameter.
        """

        # Setting parameters

        num_of_gates = num_of_gates = np.append(
            (np.linspace(10, 150, 30)).astype(int),
            (np.linspace(160, 450, 20)).astype(int))
        gate_time = 0.1
        qubits = [0]

        expected_t2 = 10
        error = thermal_relaxation_error(np.inf, expected_t2, gate_time, 0.5)
        noise_model = NoiseModel()
        noise_model.add_all_qubit_quantum_error(error, 'id')

        backend = qiskit.Aer.get_backend('qasm_simulator')
        shots = 300

        # Estimating T2* via an exponential function
        circs, xdata, _ = t2star_circuits(num_of_gates, gate_time,
                                          qubits)
        backend_result = qiskit.execute(
            circs, backend, shots=shots,
            backend_options={'max_parallel_experiments': 0},
            noise_model=noise_model).result()

        initial_t2 = expected_t2
        initial_a = 0.5
        initial_c = 0.5

        fit = T2Fitter(backend_result, xdata,
                       qubits,
                       fit_p0=[initial_a, initial_t2, initial_c],
                       fit_bounds=([-0.5, 0, -0.5],
                                   [1.5, expected_t2*1.2, 1.5]),
                       circbasename='t2star')

        self.assertAlmostEqual(fit.time(qid=0), expected_t2, delta=2,
                               msg='Calculated T2 is inaccurate')
        self.assertTrue(
            fit.time_err(qid=0) < 2,
            'Confidence in T2 calculation is too low: ' + str(fit.time_err))

        # Estimate T2* via an oscilliator function
        circs_osc, xdata, omega = t2star_circuits(num_of_gates, gate_time,
                                                  qubits, 5)

        backend_result = qiskit.execute(
            circs_osc, backend,
            shots=shots,
            backend_options={'max_parallel_experiments': 0},
            noise_model=noise_model).result()

        initial_a = 0.5
        initial_c = 0.5
        initial_f = omega
        initial_phi = 0

        fit = T2StarFitter(backend_result, xdata, qubits,
                           fit_p0=[initial_a, initial_t2, initial_f,
                                   initial_phi, initial_c],
                           fit_bounds=([-0.5, 0, omega-0.02, -np.pi, -0.5],
                                       [1.5, expected_t2*1.2, omega+0.02,
                                        np.pi, 1.5]))

        self.assertAlmostEqual(fit.time(qid=0), expected_t2, delta=2,
                               msg='Calculated T2 is inaccurate')
        self.assertTrue(
            fit.time_err(qid=0) < 2,
            'Confidence in T2 calculation is too low: ' + str(fit.time_err))
Ejemplo n.º 6
0
    def test_t2star(self):
        """
        Run the simulator with thermal relaxation noise.
        Then verify that the calculated T2star matches the t2
        parameter.
        """

        # Setting parameters

        num_of_gates = num_of_gates = np.append(
            (np.linspace(10, 150, 10)).astype(int),
            (np.linspace(160, 450, 5)).astype(int))
        gate_time = 0.1
        qubits = [0]

        expected_t2 = 10
        error = thermal_relaxation_error(np.inf, expected_t2, gate_time, 0.5)
        noise_model = NoiseModel()
        noise_model.add_all_qubit_quantum_error(error, 'id')

        backend = qiskit.Aer.get_backend('qasm_simulator')
        shots = 200

        # Estimating T2* via an exponential function
        circs, xdata, _ = t2star_circuits(num_of_gates, gate_time, qubits)
        backend_result = qiskit.execute(circs,
                                        backend,
                                        shots=shots,
                                        seed_simulator=SEED,
                                        backend_options={
                                            'max_parallel_experiments': 0
                                        },
                                        noise_model=noise_model,
                                        optimization_level=0).result()

        initial_t2 = expected_t2
        initial_a = 0.5
        initial_c = 0.5

        T2Fitter(backend_result,
                 xdata,
                 qubits,
                 fit_p0=[initial_a, initial_t2, initial_c],
                 fit_bounds=([-0.5, 0, -0.5], [1.5, expected_t2 * 1.2, 1.5]),
                 circbasename='t2star')

        # Estimate T2* via an oscilliator function
        circs_osc, xdata, omega = t2star_circuits(num_of_gates, gate_time,
                                                  qubits, 5)

        backend_result = qiskit.execute(circs_osc,
                                        backend,
                                        shots=shots,
                                        seed_simulator=SEED,
                                        backend_options={
                                            'max_parallel_experiments': 0
                                        },
                                        noise_model=noise_model,
                                        optimization_level=0).result()

        initial_a = 0.5
        initial_c = 0.5
        initial_f = omega
        initial_phi = 0

        T2StarFitter(
            backend_result,
            xdata,
            qubits,
            fit_p0=[initial_a, initial_t2, initial_f, initial_phi, initial_c],
            fit_bounds=([-0.5, 0, omega - 0.02, -np.pi, -0.5],
                        [1.5, expected_t2 * 1.2, omega + 0.02, np.pi, 1.5]))