Skip to content

Commit 58f4749

Browse files
authored
Kill hung tensor tests with pytest-timeout and lower the Windows retry timeout in CI (#3152)
Lower the Windows tensor-tests retry timeout from 20 to 15 minutes and add a per-test timeout via `pytest-timeout` to the tensor tests in `conda-package.yml` and `conda-build-test.yml` (used by `conda-package-cf.yml`). The `dpnp.tests.tensor` run sporadically hangs at 99% (IntelPython/dpctl#1954), on both Linux and Windows. Since October 1, in `conda-package.yml`, 48 of 885 Linux and 25 of 871 Windows tensor steps hit it. The log shows no progress for the rest of the attempt until the retry timeout kills it, and the next attempt passes. | Change | Before | After | |---|---|---| | Windows tensor retry timeout | 20 min (`rerun-tensor-tests-timeout-win`) | 15 min, the same `rerun-tensor-tests-timeout` as Linux | | Per-test timeout (Linux and Windows) | none | `--timeout=120 --timeout-method=thread` | Healthy Windows tensor steps now take 4-6 min, and the slowest took 10-11 min since October 16 (`conda-package-cf.yml`: 4-9 min), so 15 min leaves room without the 20 min tail kept by #3132. `--timeout-method=thread` is set explicitly because the hung main thread waits in native code (`SyclQueue.wait()`), where the default `signal` method on Linux would never fire. The thread method ends the stuck pytest-xdist worker: xdist reports the test as failed with its name and stack, starts a new worker and finishes the run, so a hang fails within ~2 min and the retry reruns the step. This was checked locally with a test that blocks in native code under `-n 2 --timeout=5 --timeout-method=thread`: `worker 'gw1' crashed while running 'tests/test_hang.py::test_hang'`, `1 failed, 2 passed in 5.58s`.
1 parent 58c2370 commit 58f4749

2 files changed

Lines changed: 16 additions & 16 deletions

File tree

‎.github/workflows/conda-build-test.yml‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ env:
3737
rerun-tests-timeout: 45
3838
rerun-tensor-tests-timeout: 15
3939
rerun-tensor-tests-max-attempts: 3
40-
# Healthy Windows tensor runs take up to ~19 min
41-
rerun-tensor-tests-timeout-win: 20
40+
# Per-test limit to kill a test stuck at 99%: https://github.com/IntelPython/dpctl/issues/1954
41+
tensor-test-timeout: 120
4242

4343
jobs:
4444
build:
@@ -232,14 +232,14 @@ jobs:
232232
id: install_dpnp
233233
continue-on-error: true
234234
run: |
235-
conda install ${{ env.package-name }}=${{ env.PACKAGE_VERSION }} pytest pytest-xdist "${{ env.python-install-spec }}" ${{ env.TEST_CHANNELS }}
235+
conda install ${{ env.package-name }}=${{ env.PACKAGE_VERSION }} pytest pytest-timeout pytest-xdist "${{ env.python-install-spec }}" ${{ env.TEST_CHANNELS }}
236236
env:
237237
TEST_CHANNELS: '-c ${{ env.channel-path }} ${{ inputs.channels-list }}'
238238

239239
- name: ReInstall dpnp
240240
if: steps.install_dpnp.outcome == 'failure'
241241
run: |
242-
conda install ${{ env.package-name }}=${{ env.PACKAGE_VERSION }} pytest pytest-xdist "${{ env.python-install-spec }}" ${{ env.TEST_CHANNELS }}
242+
conda install ${{ env.package-name }}=${{ env.PACKAGE_VERSION }} pytest pytest-timeout pytest-xdist "${{ env.python-install-spec }}" ${{ env.TEST_CHANNELS }}
243243
env:
244244
TEST_CHANNELS: '-c ${{ env.channel-path }} ${{ inputs.channels-list }}'
245245

@@ -291,7 +291,7 @@ jobs:
291291
id: run_tests_tensor
292292
uses: nick-fields/retry@ad984534de44a9489a53aefd81eb77f87c70dc60 # v4.0.0
293293
with:
294-
timeout_minutes: ${{ runner.os == 'Windows' && env.rerun-tensor-tests-timeout-win || env.rerun-tensor-tests-timeout }}
294+
timeout_minutes: ${{ env.rerun-tensor-tests-timeout }}
295295
max_attempts: ${{ env.rerun-tensor-tests-max-attempts }}
296296
retry_on: any
297297
shell: bash
@@ -300,4 +300,4 @@ jobs:
300300
. "$CONDA_UNIX/etc/profile.d/conda.sh"
301301
conda activate ${{ env.test-env-name }}
302302
303-
python -m pytest -n auto -ra --pyargs dpnp.tests.tensor
303+
python -m pytest -n auto -ra --timeout=${{ env.tensor-test-timeout }} --timeout-method=thread --pyargs dpnp.tests.tensor

‎.github/workflows/conda-package.yml‎

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ env:
2626
rerun-tests-timeout: 45
2727
rerun-tensor-tests-timeout: 15
2828
rerun-tensor-tests-max-attempts: 3
29-
# Healthy Windows tensor runs take up to ~19 min
30-
rerun-tensor-tests-timeout-win: 20
29+
# Per-test limit to kill a test stuck at 99%: https://github.com/IntelPython/dpctl/issues/1954
30+
tensor-test-timeout: 120
3131

3232
jobs:
3333
build:
@@ -253,14 +253,14 @@ jobs:
253253
id: install_dpnp
254254
continue-on-error: true
255255
run: |
256-
mamba install ${{ env.package-name }}=${{ env.PACKAGE_VERSION }} pytest pytest-xdist "${{ env.python-install-spec }}" ${{ env.TEST_CHANNELS }}
256+
mamba install ${{ env.package-name }}=${{ env.PACKAGE_VERSION }} pytest pytest-timeout pytest-xdist "${{ env.python-install-spec }}" ${{ env.TEST_CHANNELS }}
257257
env:
258258
TEST_CHANNELS: '-c ${{ env.channel-path }} ${{ env.channels-list }}'
259259

260260
- name: ReInstall dpnp
261261
if: steps.install_dpnp.outcome == 'failure'
262262
run: |
263-
mamba install ${{ env.package-name }}=${{ env.PACKAGE_VERSION }} pytest pytest-xdist "${{ env.python-install-spec }}" ${{ env.TEST_CHANNELS }}
263+
mamba install ${{ env.package-name }}=${{ env.PACKAGE_VERSION }} pytest pytest-timeout pytest-xdist "${{ env.python-install-spec }}" ${{ env.TEST_CHANNELS }}
264264
env:
265265
TEST_CHANNELS: '-c ${{ env.channel-path }} ${{ env.channels-list }}'
266266

@@ -307,7 +307,7 @@ jobs:
307307
- name: Run tensor tests
308308
if: env.rerun-tests-on-failure != 'true'
309309
run: |
310-
python -m pytest -n auto -ra --pyargs dpnp.tests.tensor
310+
python -m pytest -n auto -ra --timeout=${{ env.tensor-test-timeout }} --timeout-method=thread --pyargs dpnp.tests.tensor
311311
312312
- name: Run tensor tests
313313
if: env.rerun-tests-on-failure == 'true'
@@ -322,7 +322,7 @@ jobs:
322322
. $CONDA/etc/profile.d/mamba.sh
323323
mamba activate ${{ env.test-env-name }}
324324
325-
python -m pytest -n auto -ra --pyargs dpnp.tests.tensor
325+
python -m pytest -n auto -ra --timeout=${{ env.tensor-test-timeout }} --timeout-method=thread --pyargs dpnp.tests.tensor
326326
327327
test_examples_linux:
328328
name: Test examples
@@ -553,7 +553,7 @@ jobs:
553553
- name: Install dpnp
554554
run: |
555555
@echo on
556-
mamba install ${{ env.package-name }}=${{ env.PACKAGE_VERSION }} pytest pytest-xdist "${{ env.python-install-spec }}" ${{ env.TEST_CHANNELS }}
556+
mamba install ${{ env.package-name }}=${{ env.PACKAGE_VERSION }} pytest pytest-timeout pytest-xdist "${{ env.python-install-spec }}" ${{ env.TEST_CHANNELS }}
557557
env:
558558
TEST_CHANNELS: '-c ${{ env.channel-path }} ${{ env.channels-list }}'
559559
MAMBA_NO_LOW_SPEED_LIMIT: 1
@@ -616,19 +616,19 @@ jobs:
616616
if: env.rerun-tests-on-failure != 'true'
617617
shell: pwsh
618618
run: |
619-
python -m pytest -n auto -ra --pyargs dpnp.tests.tensor
619+
python -m pytest -n auto -ra --timeout=${{ env.tensor-test-timeout }} --timeout-method=thread --pyargs dpnp.tests.tensor
620620
621621
- name: Run tensor tests
622622
if: env.rerun-tests-on-failure == 'true'
623623
id: run_tests_tensor_win
624624
uses: nick-fields/retry@ad984534de44a9489a53aefd81eb77f87c70dc60 # v4.0.0
625625
with:
626-
timeout_minutes: ${{ env.rerun-tensor-tests-timeout-win }}
626+
timeout_minutes: ${{ env.rerun-tensor-tests-timeout }}
627627
max_attempts: ${{ env.rerun-tensor-tests-max-attempts }}
628628
retry_on: any
629629
shell: pwsh
630630
command: |
631-
python -m pytest -n auto -ra --pyargs dpnp.tests.tensor
631+
python -m pytest -n auto -ra --timeout=${{ env.tensor-test-timeout }} --timeout-method=thread --pyargs dpnp.tests.tensor
632632
633633
upload:
634634
name: Upload

0 commit comments

Comments
 (0)