Skip to content

Commit 5556e72

Browse files
authored
ci - skip slow tests on PR, run them in daily ci instead (#6331)
* Add slow marks to the unit tests with over 20 second duration. * Update the ci-daily job so it runs all slow tests. * Add ci-daily jobs for Windows and MacOS operating systems so that slow tests are tested on these platforms too. Refs: * #6211 (comment) * #6211 (comment) Resolves #6211
1 parent 1eced48 commit 5556e72

8 files changed

+120
-15
lines changed

.github/workflows/ci-daily.yml

Lines changed: 56 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,65 @@ jobs:
2828
key: ${{ env.pythonLocation }}-${{ hashFiles('**/requirements.txt', 'dev_tools/requirements/**/*.txt') }}
2929
- name: Install requirements
3030
run: |
31-
pip install --pre cirq
31+
pip install --pre cirq &&
3232
pip install \
33-
-r dev_tools/requirements/deps/format.txt \
34-
-r dev_tools/requirements/deps/pylint.txt \
35-
-r dev_tools/requirements/deps/pytest.txt
33+
-r dev_tools/requirements/deps/format.txt \
34+
-r dev_tools/requirements/deps/pylint.txt \
35+
-r dev_tools/requirements/deps/pytest.txt
3636
- name: Run Quil dependencies
3737
run: docker-compose -f cirq-rigetti/docker-compose.test.yaml up -d
3838
- name: Pytest check
39-
run: check/pytest --ignore=cirq-core/cirq/contrib --rigetti-integration
39+
run: check/pytest -n auto --ignore=cirq-core/cirq/contrib --rigetti-integration --enable-slow-tests
4040
- name: Stop Quil dependencies
4141
run: docker-compose -f cirq-rigetti/docker-compose.test.yaml down
42+
windows:
43+
name: Pytest Windows
44+
strategy:
45+
matrix:
46+
python-version: ['3.9', '3.10', '3.11']
47+
runs-on: windows-2019
48+
steps:
49+
- uses: actions/checkout@v3
50+
- uses: actions/setup-python@v4
51+
with:
52+
python-version: ${{ matrix.python-version }}
53+
architecture: 'x64'
54+
- uses: actions/cache@v2
55+
with:
56+
path: ${{ env.pythonLocation }}
57+
key: ${{ env.pythonLocation }}-${{ hashFiles('**/requirements.txt', 'dev_tools/requirements/**/*.txt') }}
58+
- name: Install requirements
59+
run: |
60+
pip install --pre cirq &&
61+
pip install \
62+
-r dev_tools/requirements/deps/format.txt \
63+
-r dev_tools/requirements/deps/pylint.txt \
64+
-r dev_tools/requirements/deps/pytest.txt
65+
- name: Pytest Windows
66+
run: check/pytest -n auto --ignore=cirq-core/cirq/contrib --enable-slow-tests
67+
shell: bash
68+
macos:
69+
name: Pytest MacOS
70+
strategy:
71+
matrix:
72+
python-version: ['3.9', '3.10', '3.11']
73+
runs-on: macos-latest
74+
steps:
75+
- uses: actions/checkout@v3
76+
- uses: actions/setup-python@v4
77+
with:
78+
python-version: ${{ matrix.python-version }}
79+
architecture: 'x64'
80+
- uses: actions/cache@v2
81+
with:
82+
path: ${{ env.pythonLocation }}
83+
key: ${{ env.pythonLocation }}-${{ hashFiles('**/requirements.txt', 'dev_tools/requirements/**/*.txt') }}
84+
- name: Install requirements
85+
run: |
86+
pip install --pre cirq &&
87+
pip install \
88+
-r dev_tools/requirements/deps/format.txt \
89+
-r dev_tools/requirements/deps/pylint.txt \
90+
-r dev_tools/requirements/deps/pytest.txt
91+
- name: Pytest check
92+
run: check/pytest -n auto --ignore=cirq-core/cirq/contrib --enable-slow-tests

cirq-ft/cirq_ft/algos/qrom_test.py

Lines changed: 29 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,20 @@
2424

2525

2626
@pytest.mark.parametrize(
27-
"data", [[[1, 2, 3, 4, 5]], [[1, 2, 3], [4, 5, 10]], [[1], [2], [3], [4], [5], [6]]]
27+
"data,num_controls",
28+
[
29+
pytest.param(
30+
data,
31+
num_controls,
32+
id=f"{num_controls}-data{idx}",
33+
marks=pytest.mark.slow if num_controls == 2 and idx == 2 else (),
34+
)
35+
for idx, data in enumerate(
36+
[[[1, 2, 3, 4, 5]], [[1, 2, 3], [4, 5, 10]], [[1], [2], [3], [4], [5], [6]]]
37+
)
38+
for num_controls in [0, 1, 2]
39+
],
2840
)
29-
@pytest.mark.parametrize("num_controls", [0, 1, 2])
3041
def test_qrom_1d(data, num_controls):
3142
qrom = cirq_ft.QROM.build(*data, num_controls=num_controls)
3243
greedy_mm = cirq.GreedyQubitManager('a', maximize_reuse=True)
@@ -195,10 +206,23 @@ def test_qrom_variable_spacing():
195206

196207

197208
@pytest.mark.parametrize(
198-
"data",
199-
[[np.arange(6).reshape(2, 3), 4 * np.arange(6).reshape(2, 3)], [np.arange(8).reshape(2, 2, 2)]],
209+
"data,num_controls",
210+
[
211+
pytest.param(
212+
data,
213+
num_controls,
214+
id=f"{num_controls}-data{idx}",
215+
marks=pytest.mark.slow if num_controls == 2 and idx == 0 else (),
216+
)
217+
for idx, data in enumerate(
218+
[
219+
[np.arange(6).reshape(2, 3), 4 * np.arange(6).reshape(2, 3)],
220+
[np.arange(8).reshape(2, 2, 2)],
221+
]
222+
)
223+
for num_controls in [0, 1, 2]
224+
],
200225
)
201-
@pytest.mark.parametrize("num_controls", [0, 1, 2])
202226
def test_qrom_multi_dim(data, num_controls):
203227
selection_bitsizes = tuple((s - 1).bit_length() for s in data[0].shape)
204228
target_bitsizes = tuple(int(np.max(d)).bit_length() for d in data)

cirq-ft/cirq_ft/algos/qubitization_walk_operator_test.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ def get_walk_operator_for_1d_Ising_model(
4646
return walk_operator_for_pauli_hamiltonian(ham, eps)
4747

4848

49+
@pytest.mark.slow
4950
@pytest.mark.parametrize('num_sites,eps', [(4, 2e-1), (3, 1e-1)])
5051
def test_qubitization_walk_operator(num_sites: int, eps: float):
5152
ham = get_1d_Ising_hamiltonian(cirq.LineQubit.range(num_sites))

cirq-ft/cirq_ft/algos/reflection_using_prepare_test.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ def get_3q_uniform_dirac_notation(signs):
7878
return ret
7979

8080

81+
@pytest.mark.slow
8182
@pytest.mark.parametrize('num_ones', [*range(5, 9)])
8283
@pytest.mark.parametrize('eps', [0.01])
8384
def test_reflection_using_prepare(num_ones, eps):

cirq-ft/cirq_ft/algos/select_swap_qrom_test.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,19 @@
2020
from cirq_ft.infra.bit_tools import iter_bits
2121

2222

23-
@pytest.mark.parametrize("data", [[[1, 2, 3, 4, 5]], [[1, 2, 3], [3, 2, 1]]])
24-
@pytest.mark.parametrize("block_size", [None, 1, 2, 3])
23+
@pytest.mark.parametrize(
24+
"data,block_size",
25+
[
26+
pytest.param(
27+
data,
28+
block_size,
29+
id=f"{block_size}-data{didx}",
30+
marks=pytest.mark.slow if block_size == 3 and didx == 1 else (),
31+
)
32+
for didx, data in enumerate([[[1, 2, 3, 4, 5]], [[1, 2, 3], [3, 2, 1]]])
33+
for block_size in [None, 1, 2, 3]
34+
],
35+
)
2536
def test_select_swap_qrom(data, block_size):
2637
qrom = cirq_ft.SelectSwapQROM(*data, block_size=block_size)
2738
qubit_regs = infra.get_named_qubits(qrom.signature)

cirq-ft/cirq_ft/algos/selected_majorana_fermion_test.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,14 @@
2020
from cirq_ft.infra.bit_tools import iter_bits
2121

2222

23-
@pytest.mark.parametrize("selection_bitsize, target_bitsize", [(2, 4), (3, 8), (4, 9)])
23+
@pytest.mark.parametrize(
24+
"selection_bitsize, target_bitsize",
25+
[
26+
(2, 4),
27+
pytest.param(3, 8, marks=pytest.mark.slow),
28+
pytest.param(4, 9, marks=pytest.mark.slow),
29+
],
30+
)
2431
@pytest.mark.parametrize("target_gate", [cirq.X, cirq.Y])
2532
def test_selected_majorana_fermion_gate(selection_bitsize, target_bitsize, target_gate):
2633
gate = cirq_ft.SelectedMajoranaFermionGate(

cirq-ft/cirq_ft/algos/state_preparation_test.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,15 @@
2020
from cirq_ft.infra.jupyter_tools import execute_notebook
2121

2222

23-
@pytest.mark.parametrize("num_sites, epsilon", [[2, 3e-3], [3, 3.0e-3], [4, 5.0e-3], [7, 8.0e-3]])
23+
@pytest.mark.parametrize(
24+
"num_sites, epsilon",
25+
[
26+
(2, 3e-3),
27+
pytest.param(3, 3.0e-3, marks=pytest.mark.slow),
28+
pytest.param(4, 5.0e-3, marks=pytest.mark.slow),
29+
pytest.param(7, 8.0e-3, marks=pytest.mark.slow),
30+
],
31+
)
2432
def test_state_preparation_via_coherent_alias_sampling(num_sites, epsilon):
2533
lcu_coefficients = get_1d_Ising_lcu_coeffs(num_sites)
2634
gate = cirq_ft.StatePreparationAliasSampling.from_lcu_probs(

cirq-ft/cirq_ft/algos/unary_iteration_gate_test.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,9 @@ def nth_operation( # type: ignore[override]
118118
yield [cirq.CNOT(control, t1[i]), cirq.CNOT(control, t2[j]), cirq.CNOT(control, t3[k])]
119119

120120

121-
@pytest.mark.parametrize("target_shape", [(2, 3, 2), (2, 2, 2)])
121+
@pytest.mark.parametrize(
122+
"target_shape", [pytest.param((2, 3, 2), marks=pytest.mark.slow), (2, 2, 2)]
123+
)
122124
def test_multi_dimensional_unary_iteration_gate(target_shape: Tuple[int, int, int]):
123125
greedy_mm = cirq.GreedyQubitManager(prefix="_a", maximize_reuse=True)
124126
gate = ApplyXToIJKthQubit(target_shape)

0 commit comments

Comments
 (0)