quantumlib / Cirq

A Python framework for creating, editing, and invoking Noisy Intermediate Scale Quantum (NISQ) circuits.
Apache License 2.0
4.28k stars 1.02k forks source link

Avoid CI flakes due to random-seed-dependent unit tests #6700

Closed pavoljuhas closed 3 months ago

pavoljuhas commented 3 months ago

Add testing decorator retry_once_with_later_random_values to repeat test once with subsequent random values.

This reduces CI failures for random seed choices by pytest-randomly, e.g.,

check/pytest --numprocesses=0 --randomly-seed=1783995880 \
    cirq-core/cirq/transformers/analytical_decompositions/controlled_gate_decomposition_test.py::test_decompose_random_unitary

check/pytest --numprocesses=0 --randomly-seed=1454822943 \
    cirq-core/cirq/linalg/decompositions_test.py::test_num_two_qubit_gates_required
pavoljuhas commented 3 months ago

Example failure of CI workflow - https://github.com/quantumlib/Cirq/actions/runs/10276585312/job/28437228815

codecov[bot] commented 3 months ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 97.83%. Comparing base (51e8c3d) to head (06155fd). Report is 1 commits behind head on main.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #6700 +/- ## ======================================== Coverage 97.82% 97.83% ======================================== Files 1074 1077 +3 Lines 92187 92350 +163 ======================================== + Hits 90186 90349 +163 Misses 2001 2001 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.