From 9a2bad757767ab51891e5a5005e8b8103230ee76 Mon Sep 17 00:00:00 2001 From: Toshinari Itoko Date: Tue, 31 Jan 2023 16:50:57 +0900 Subject: [PATCH] More stable and consistent test params --- .../test_randomized_benchmarking.py | 28 +++++++++---------- .../test_rb_experiment.py | 1 - 2 files changed, 14 insertions(+), 15 deletions(-) diff --git a/test/library/randomized_benchmarking/test_randomized_benchmarking.py b/test/library/randomized_benchmarking/test_randomized_benchmarking.py index 9b9893cb66..f9ba94e165 100644 --- a/test/library/randomized_benchmarking/test_randomized_benchmarking.py +++ b/test/library/randomized_benchmarking/test_randomized_benchmarking.py @@ -32,10 +32,10 @@ def setUp(self): super().setUp() # depolarizing error - self.p1q = 0.02 - self.p2q = 0.10 + self.p1q = 0.004 + self.p2q = 0.04 self.pvz = 0.0 - self.pcz = 0.15 + self.pcz = 0.06 # basis gates self.basis_gates = ["rz", "sx", "cx"] @@ -92,7 +92,7 @@ def test_single_qubit(self): epc = expdata.analysis_results("EPC") epc_expected = 1 - (1 - 1 / 2 * self.p1q) ** 1.0 - self.assertAlmostEqual(epc.value.n, epc_expected, delta=0.1 * epc_expected) + self.assertAlmostEqual(epc.value.n, epc_expected, delta=3 * epc.value.std_dev) def test_two_qubit(self): """Test two qubit RB. Use default basis gates.""" @@ -115,9 +115,9 @@ def test_two_qubit(self): # average number of CX gate per Clifford is 1.5. # Since this is two qubit RB, the dep-parameter is factored by 3/4. epc = expdata.analysis_results("EPC") - # Allow for 50 percent tolerance since we ignore 1q gate contribution + # Allow for 30 percent tolerance since we ignore 1q gate contribution epc_expected = 1 - (1 - 3 / 4 * self.p2q) ** 1.5 - self.assertAlmostEqual(epc.value.n, epc_expected, delta=0.5 * epc_expected) + self.assertAlmostEqual(epc.value.n, epc_expected, delta=0.3 * epc_expected) def test_three_qubit(self): """Test two qubit RB. Use default basis gates.""" @@ -235,12 +235,12 @@ def test_single_qubit_parallel(self): epc_expected = 1 - (1 - 1 / 2 * self.p1q) ** 1.0 for i in range(2): epc = par_expdata.child_data(i).analysis_results("EPC") - self.assertAlmostEqual(epc.value.n, epc_expected, delta=0.1 * epc_expected) + self.assertAlmostEqual(epc.value.n, epc_expected, delta=3 * epc.value.std_dev) def test_two_qubit_parallel(self): """Test two qubit RB in parallel.""" qubit_pairs = [[0, 1], [2, 3]] - lengths = list(range(5, 100, 5)) + lengths = list(range(1, 30, 3)) exps = [] for pair in qubit_pairs: exp = rb.StandardRB(qubits=pair, lengths=lengths, seed=123, backend=self.backend) @@ -255,8 +255,8 @@ def test_two_qubit_parallel(self): epc_expected = 1 - (1 - 3 / 4 * self.p2q) ** 1.5 for i in range(2): epc = par_expdata.child_data(i).analysis_results("EPC") - # Allow for 20 percent tolerance since we ignore 1q gate contribution - self.assertAlmostEqual(epc.value.n, epc_expected, delta=0.2 * epc_expected) + # Allow for 30 percent tolerance since we ignore 1q gate contribution + self.assertAlmostEqual(epc.value.n, epc_expected, delta=0.3 * epc_expected) def test_two_qubit_with_cz(self): """Test two qubit RB.""" @@ -284,9 +284,9 @@ def test_two_qubit_with_cz(self): # Since this is two qubit RB, the dep-parameter is factored by 3/4. epc = expdata.analysis_results("EPC") - # Allow for 50 percent tolerance since we ignore 1q gate contribution + # Allow for 30 percent tolerance since we ignore 1q gate contribution epc_expected = 1 - (1 - 3 / 4 * self.pcz) ** 1.5 - self.assertAlmostEqual(epc.value.n, epc_expected, delta=0.5 * epc_expected) + self.assertAlmostEqual(epc.value.n, epc_expected, delta=0.3 * epc_expected) class TestRunInterleavedRB(RBRunTestCase): @@ -310,7 +310,7 @@ def test_single_qubit(self): # Since this is interleaved, we can directly compare values, i.e. n_gpc = 1 epc = expdata.analysis_results("EPC") epc_expected = 1 / 2 * self.p1q - self.assertAlmostEqual(epc.value.n, epc_expected, delta=0.1 * epc_expected) + self.assertAlmostEqual(epc.value.n, epc_expected, delta=3 * epc.value.std_dev) def test_two_qubit(self): """Test two qubit IRB.""" @@ -330,7 +330,7 @@ def test_two_qubit(self): # Since this is interleaved, we can directly compare values, i.e. n_gpc = 1 epc = expdata.analysis_results("EPC") epc_expected = 3 / 4 * self.p2q - self.assertAlmostEqual(epc.value.n, epc_expected, delta=0.1 * epc_expected) + self.assertAlmostEqual(epc.value.n, epc_expected, delta=3 * epc.value.std_dev) def test_two_qubit_with_cz(self): """Test two qubit IRB.""" diff --git a/test/library/randomized_benchmarking/test_rb_experiment.py b/test/library/randomized_benchmarking/test_rb_experiment.py index aec5a40ff4..d2fbf9041c 100644 --- a/test/library/randomized_benchmarking/test_rb_experiment.py +++ b/test/library/randomized_benchmarking/test_rb_experiment.py @@ -162,7 +162,6 @@ def test_calibrations_via_transpile_options(self): exp.set_transpile_options(inst_map=my_inst_map) transpiled = exp._transpiled_circuits() for qc in transpiled: - print(qc.calibrations) self.assertTrue(qc.calibrations) self.assertTrue(qc.has_calibration_for((SXGate(), [qc.qubits[q] for q in qubits], []))) self.assertEqual(qc.calibrations["sx"][(qubits, tuple())], my_sched)