Skip to content

Commit a5b020f

Browse files
wshanksnkanazawa1989
authored andcommitted
Change RB test parameters to make the test faster and more robust (qiskit-community#1295)
`test_add_more_circuit_yields_lower_variance` started failing with qiskit-aer 0.13.0. The test was only comparing the results of 3 RB sampels to 5 RB samples and looking for the case with more samples to have lower variance. These numbers of samples were likely not enough to ensure that the case with more samples always had lower variance across a wide range of random seeds. Here the high number of samples was increased to 30. To make sure that the fit results were reasonable and that the test run time did not get too long, these additional changes were: * Convert the test from two qubit RB to single qubit RB. This makes the simulation faster. * Increase the single qubit gate error. This makes the qubit depolarize faster so that the RB curve can be traced out with less gates.
1 parent 82ea32c commit a5b020f

File tree

1 file changed

+23
-5
lines changed

1 file changed

+23
-5
lines changed

test/library/randomized_benchmarking/test_standard_rb.py

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -319,11 +319,29 @@ def test_three_qubit(self):
319319

320320
def test_add_more_circuit_yields_lower_variance(self):
321321
"""Test variance reduction with larger number of sampling."""
322+
323+
# Increase single qubit error so that we can see gate error with a
324+
# small number of Cliffords since we want to run many samples without
325+
# taking too long.
326+
p1q = 0.15
327+
pvz = 0.0
328+
329+
# setup noise model
330+
sx_error = depolarizing_error(p1q, 1)
331+
rz_error = depolarizing_error(pvz, 1)
332+
333+
noise_model = NoiseModel()
334+
noise_model.add_all_qubit_quantum_error(sx_error, "sx")
335+
noise_model.add_all_qubit_quantum_error(rz_error, "rz")
336+
337+
# Aer simulator
338+
backend = AerSimulator(noise_model=noise_model, seed_simulator=123)
339+
322340
exp1 = rb.StandardRB(
323-
physical_qubits=(0, 1),
341+
physical_qubits=(0,),
324342
lengths=list(range(1, 30, 3)),
325343
seed=123,
326-
backend=self.backend,
344+
backend=backend,
327345
num_samples=3,
328346
)
329347
exp1.analysis.set_options(gate_error_ratio=None)
@@ -332,11 +350,11 @@ def test_add_more_circuit_yields_lower_variance(self):
332350
self.assertExperimentDone(expdata1)
333351

334352
exp2 = rb.StandardRB(
335-
physical_qubits=(0, 1),
353+
physical_qubits=(0,),
336354
lengths=list(range(1, 30, 3)),
337355
seed=456,
338-
backend=self.backend,
339-
num_samples=5,
356+
backend=backend,
357+
num_samples=30,
340358
)
341359
exp2.analysis.set_options(gate_error_ratio=None)
342360
exp2.set_transpile_options(**self.transpiler_options)

0 commit comments

Comments
 (0)