Skip to content

Commit

Permalink
More stable and consistent test params
Browse files Browse the repository at this point in the history
  • Loading branch information
itoko committed Jan 31, 2023
1 parent 6bfeb15 commit 9a2bad7
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand Down Expand Up @@ -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."""
Expand All @@ -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."""
Expand Down Expand Up @@ -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)
Expand All @@ -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."""
Expand Down Expand Up @@ -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):
Expand All @@ -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."""
Expand All @@ -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."""
Expand Down
1 change: 0 additions & 1 deletion test/library/randomized_benchmarking/test_rb_experiment.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 9a2bad7

Please sign in to comment.