-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Add a convenience method that runs both RB and XEB #6471
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 3 commits
af3c6ff
ebe3150
a33393c
ebe1cc8
ee46508
866fde2
ee50124
eb9c0ed
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -69,4 +69,5 @@ | |
InferredXEBResult, | ||
TwoQubitXEBResult, | ||
parallel_two_qubit_xeb, | ||
run_rb_and_xeb, | ||
) |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -264,3 +264,51 @@ def test_inferred_plots(ax, target_error, kind): | |
combined_results.plot_histogram(target_error=target_error, kind=kind, ax=ax) | ||
else: | ||
combined_results.plot_histogram(target_error=target_error, kind=kind, ax=ax) | ||
|
||
|
||
@pytest.mark.parametrize( | ||
'sampler,qubits', | ||
[ | ||
( | ||
cirq.DensityMatrixSimulator( | ||
seed=0, noise=cirq.ConstantQubitNoiseModel(cirq.amplitude_damp(0.1)) | ||
), | ||
cirq.GridQubit.rect(3, 2, 4, 3), | ||
), | ||
( | ||
DensityMatrixSimulatorWithProcessor( | ||
seed=0, noise=cirq.ConstantQubitNoiseModel(cirq.amplitude_damp(0.1)) | ||
), | ||
None, | ||
), | ||
], | ||
) | ||
def test_run_rb_and_xeb(sampler: cirq.Sampler, qubits: Optional[Sequence[cirq.GridQubit]]): | ||
np.random.seed(0) | ||
random.seed(0) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please remove here and in test_parallel_two_qubit_xeb above. Both tests pass There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. removed them, I forgot that I already figuredout why the methods produce different results for the same seed. the reason isn't treating random_state in a wrong way but that some of the subroutines are parallized. so the order of parallization changes the results. however the tests are not flaky I wrote them to be resilient to that. |
||
|
||
with redirect_stdout(io.StringIO()), redirect_stderr(io.StringIO()): | ||
NoureldinYosri marked this conversation as resolved.
Show resolved
Hide resolved
|
||
res = cirq.experiments.run_rb_and_xeb( | ||
sampler=sampler, | ||
qubits=qubits, | ||
repetitions=100, | ||
num_clifford_range=tuple(np.arange(3, 10, 1)), | ||
xeb_combinations=1, | ||
num_circuits=1, | ||
depths_xeb=(3, 4, 5), | ||
random_state=0, | ||
) | ||
np.testing.assert_allclose( | ||
[res.xeb_result.xeb_error(*pair) for pair in res.all_qubit_pairs], 0.1, atol=1e-1 | ||
) | ||
|
||
|
||
def test_run_rb_and_xeb_without_processor_fails(): | ||
sampler = ( | ||
cirq.DensityMatrixSimulator( | ||
seed=0, noise=cirq.ConstantQubitNoiseModel(cirq.amplitude_damp(0.1)) | ||
), | ||
) | ||
|
||
with pytest.raises(ValueError): | ||
_ = cirq.experiments.run_rb_and_xeb(sampler=sampler) |
Uh oh!
There was an error while loading. Please reload this page.