Skip to content

Commit 303a203

Browse files
authored
Resolve issues in public CI (#2254)
The PR proposes to implement fixes/improvements into the public CI: - run `pre-commit` and `building docs` workflows on Ubuntu-22.04 (`ubuntu-latest` now refers to Ubuntu-24.04 where the workflows fail as for now) - use `fail-fast: false` rather than `continue-on-error: false` in workflow with night tests run (some jobs in strategy matrix may fail due to mamba/conda issues) _Note, the workflow will be reported as failed if any job fails._ - trigger rerun tests step on failure of `run_tests` step only in night tests workflow - trigger resetup minoconda step on failure in night tests and conda package workflows - build name of running job based on python and OS from strategy matrix - disable night tests workflow to be run in forked repositories Also the PR includes adaptation to the recent interface changes in dpctl implemented in [gh-1957](IntelPython/dpctl#1957).
1 parent e8c088c commit 303a203

File tree

6 files changed

+78
-66
lines changed

6 files changed

+78
-66
lines changed

.github/workflows/build-sphinx.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ jobs:
2525
build-and-deploy:
2626
name: Build and Deploy Docs
2727

28-
runs-on: ubuntu-latest
28+
runs-on: ubuntu-22.04
2929

3030
permissions:
3131
# Needed to cancel any previous runs that are not completed for a given workflow

.github/workflows/check-mkl-interfaces.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ env:
2828
2929
jobs:
3030
test_by_tag:
31-
name: Run on ['${{ matrix.os }}', python='${{ matrix.python }}'] with oneMKL tag
31+
name: Run tests with oneMKL tag
3232

3333
strategy:
3434
matrix:
@@ -121,7 +121,7 @@ jobs:
121121
SYCL_CACHE_PERSISTENT: 1
122122

123123
test_by_branch:
124-
name: Run on ['${{ matrix.os }}', python='${{ matrix.python }}'] with oneMKL develop branch
124+
name: Run tests with oneMKL develop branch
125125

126126
strategy:
127127
matrix:

.github/workflows/conda-package.yml

Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ env:
2525

2626
jobs:
2727
build:
28-
name: Build ['${{ matrix.os }}', python='${{ matrix.python }}']
28+
name: Build
2929

3030
strategy:
3131
matrix:
@@ -56,6 +56,8 @@ jobs:
5656
fetch-depth: 0
5757

5858
- name: Setup miniconda
59+
id: setup_miniconda
60+
continue-on-error: true
5961
uses: conda-incubator/setup-miniconda@d2e6a045a86077fb6cad6f5adf368e9076ddaa8d # v3.1.0
6062
with:
6163
miniforge-version: latest
@@ -65,9 +67,16 @@ jobs:
6567
python-version: ${{ env.CONDA_BUILD_INDEX_ENV_PY_VER}}
6668
activate-environment: 'build'
6769

68-
# Sometimes `mamba install ...` fails due to slow download speed rate, so disable the check in mamba
69-
- name: Disable speed limit check in mamba
70-
run: echo "MAMBA_NO_LOW_SPEED_LIMIT=1" >> $GITHUB_ENV
70+
- name: ReSetup miniconda
71+
if: steps.setup_miniconda.outcome == 'failure'
72+
uses: conda-incubator/setup-miniconda@d2e6a045a86077fb6cad6f5adf368e9076ddaa8d # v3.1.0
73+
with:
74+
miniforge-version: latest
75+
use-mamba: 'true'
76+
channels: conda-forge
77+
conda-remove-defaults: 'true'
78+
python-version: ${{ env.CONDA_BUILD_INDEX_ENV_PY_VER}}
79+
activate-environment: 'build'
7180

7281
- name: Store conda paths as envs
7382
shell: bash -el {0}
@@ -76,6 +85,12 @@ jobs:
7685
echo "WHEELS_OUTPUT_FOLDER=$GITHUB_WORKSPACE${{ runner.os == 'Linux' && '/' || '\\' }}" >> $GITHUB_ENV
7786
7887
- name: Install conda-build
88+
id: install_conda_build
89+
continue-on-error: true
90+
run: mamba install conda-build=${{ env.CONDA_BUILD_VERSION}}
91+
92+
- name: ReInstall conda-build
93+
if: steps.install_conda_build.outcome == 'failure'
7994
run: mamba install conda-build=${{ env.CONDA_BUILD_VERSION}}
8095

8196
- name: Build conda package
@@ -96,11 +111,11 @@ jobs:
96111
path: ${{ env.WHEELS_OUTPUT_FOLDER }}${{ env.PACKAGE_NAME }}-*.whl
97112

98113
test_linux:
99-
name: Test ['ubuntu-latest', python='${{ matrix.python }}']
114+
name: Test
100115

101116
needs: build
102117

103-
runs-on: ubuntu-latest
118+
runs-on: ${{ matrix.os }}
104119

105120
defaults:
106121
run:
@@ -109,6 +124,7 @@ jobs:
109124
strategy:
110125
matrix:
111126
python: ['3.9', '3.10', '3.11', '3.12', '3.13']
127+
os: [ubuntu-latest]
112128

113129
continue-on-error: true
114130

@@ -199,11 +215,11 @@ jobs:
199215
python -m pytest -ra --pyargs ${{ env.PACKAGE_NAME }}.tests
200216
201217
test_windows:
202-
name: Test ['windows-2019', python='${{ matrix.python }}']
218+
name: Test
203219

204220
needs: build
205221

206-
runs-on: windows-2019
222+
runs-on: ${{ matrix.os }}
207223

208224
defaults:
209225
run:
@@ -212,6 +228,7 @@ jobs:
212228
strategy:
213229
matrix:
214230
python: ['3.9', '3.10', '3.11', '3.12', '3.13']
231+
os: [windows-2019]
215232

216233
continue-on-error: true
217234

@@ -335,7 +352,7 @@ jobs:
335352
python -m pytest -ra --pyargs ${{ env.PACKAGE_NAME }}.tests
336353
337354
upload:
338-
name: Upload ['${{ matrix.os }}', python='${{ matrix.python }}']
355+
name: Upload
339356

340357
needs: [test_linux, test_windows]
341358

.github/workflows/cron-run-tests.yaml

Lines changed: 29 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,14 @@ env:
1515
PACKAGE_NAME: dpnp
1616
CHANNELS: '-c dppy/label/dev -c https://software.repos.intel.com/python/conda/ -c conda-forge --override-channels'
1717
TEST_ENV_NAME: test
18-
RERUN_TESTS_ON_FAILURE: 'true'
1918
RUN_TESTS_MAX_ATTEMPTS: 2
2019

2120
jobs:
2221
test:
23-
name: Test ['${{ matrix.runner }}', python='${{ matrix.python }}']
22+
name: Test
23+
24+
# disable scheduled workflow to be run in forks
25+
if: github.event.repository.fork == false
2426

2527
runs-on: ${{ matrix.runner }}
2628

@@ -33,12 +35,11 @@ jobs:
3335
actions: write
3436

3537
strategy:
38+
fail-fast: false
3639
matrix:
3740
python: ['3.9', '3.10', '3.11', '3.12', '3.13']
3841
runner: [ubuntu-22.04, ubuntu-24.04, windows-2019]
3942

40-
continue-on-error: false
41-
4243
steps:
4344
- name: Cancel Previous Runs
4445
uses: styfle/cancel-workflow-action@85880fa0301c86cca9da44039ee3bb12d3bedbfa # 0.12.1
@@ -57,6 +58,19 @@ jobs:
5758
echo "Latest tag is ${{ steps.find_latest_tag.outputs.tag }}"
5859
5960
- name: Setup miniconda
61+
id: setup_miniconda
62+
continue-on-error: true
63+
uses: conda-incubator/setup-miniconda@d2e6a045a86077fb6cad6f5adf368e9076ddaa8d # v3.1.0
64+
with:
65+
miniforge-version: latest
66+
use-mamba: 'true'
67+
channels: conda-forge
68+
conda-remove-defaults: 'true'
69+
python-version: ${{ matrix.python }}
70+
activate-environment: ${{ env.TEST_ENV_NAME }}
71+
72+
- name: ReSetup miniconda
73+
if: steps.setup_miniconda.outcome == 'failure'
6074
uses: conda-incubator/setup-miniconda@d2e6a045a86077fb6cad6f5adf368e9076ddaa8d # v3.1.0
6175
with:
6276
miniforge-version: latest
@@ -67,10 +81,15 @@ jobs:
6781
activate-environment: ${{ env.TEST_ENV_NAME }}
6882

6983
- name: Install dpnp
84+
id: install_dpnp
85+
continue-on-error: true
86+
run: |
87+
mamba install ${{ env.PACKAGE_NAME }}=${{ steps.find_latest_tag.outputs.tag }} pytest ${{ env.CHANNELS }}
88+
89+
- name: ReInstall dpnp
90+
if: steps.install_dpnp.outcome == 'failure'
7091
run: |
7192
mamba install ${{ env.PACKAGE_NAME }}=${{ steps.find_latest_tag.outputs.tag }} pytest ${{ env.CHANNELS }}
72-
env:
73-
MAMBA_NO_LOW_SPEED_LIMIT: 1
7493
7594
- name: List installed packages
7695
run: mamba list
@@ -95,14 +114,15 @@ jobs:
95114
python -c "import dpnp; print(dpnp.__version__)"
96115
97116
- name: Run tests
98-
if: env.RERUN_TESTS_ON_FAILURE != 'true'
117+
id: run_tests
118+
continue-on-error: true
99119
run: |
100120
python -m pytest -ra --pyargs ${{ env.PACKAGE_NAME }}.tests
101121
env:
102122
SYCL_CACHE_PERSISTENT: 1
103123

104124
- name: ReRun tests on Linux
105-
if: env.RERUN_TESTS_ON_FAILURE == 'true' && matrix.runner != 'windows-2019'
125+
if: steps.run_tests.outcome == 'failure' && matrix.runner != 'windows-2019'
106126
id: run_tests_linux
107127
uses: nick-fields/retry@7152eba30c6575329ac0576536151aca5a72780e # v3.0.0
108128
with:
@@ -119,7 +139,7 @@ jobs:
119139
SYCL_CACHE_PERSISTENT: 1
120140

121141
- name: ReRun tests on Windows
122-
if: env.RERUN_TESTS_ON_FAILURE == 'true' && matrix.runner == 'windows-2019'
142+
if: steps.run_tests.outcome == 'failure' && matrix.runner == 'windows-2019'
123143
id: run_tests_win
124144
uses: nick-fields/retry@7152eba30c6575329ac0576536151aca5a72780e # v3.0.0
125145
with:

.github/workflows/pre-commit.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ permissions: read-all
99

1010
jobs:
1111
pre-commit:
12-
runs-on: ubuntu-latest
12+
runs-on: ubuntu-22.04
1313
steps:
1414
- name: Set up clang-format
1515
run: |

dpnp/backend/extensions/elementwise_functions/elementwise_functions.hpp

Lines changed: 19 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -218,28 +218,21 @@ std::pair<sycl::event, sycl::event>
218218
std::vector<sycl::event> host_tasks{};
219219
host_tasks.reserve(2);
220220

221-
const auto &ptr_size_event_triple_ = device_allocate_and_pack<py::ssize_t>(
221+
auto ptr_size_event_triple_ = device_allocate_and_pack<py::ssize_t>(
222222
q, host_tasks, simplified_shape, simplified_src_strides,
223223
simplified_dst_strides);
224-
py::ssize_t *shape_strides = std::get<0>(ptr_size_event_triple_);
225-
const sycl::event &copy_shape_ev = std::get<2>(ptr_size_event_triple_);
226-
227-
if (shape_strides == nullptr) {
228-
throw std::runtime_error("Device memory allocation failed");
229-
}
224+
auto shape_strides_owner = std::move(std::get<0>(ptr_size_event_triple_));
225+
const auto &copy_shape_ev = std::get<2>(ptr_size_event_triple_);
226+
const py::ssize_t *shape_strides = shape_strides_owner.get();
230227

231228
sycl::event strided_fn_ev =
232229
strided_fn(q, src_nelems, nd, shape_strides, src_data, src_offset,
233230
dst_data, dst_offset, depends, {copy_shape_ev});
234231

235232
// async free of shape_strides temporary
236-
auto ctx = q.get_context();
237-
sycl::event tmp_cleanup_ev = q.submit([&](sycl::handler &cgh) {
238-
cgh.depends_on(strided_fn_ev);
239-
using dpctl::tensor::alloc_utils::sycl_free_noexcept;
240-
cgh.host_task(
241-
[ctx, shape_strides]() { sycl_free_noexcept(shape_strides, ctx); });
242-
});
233+
sycl::event tmp_cleanup_ev = dpctl::tensor::alloc_utils::async_smart_free(
234+
q, {strided_fn_ev}, shape_strides_owner);
235+
243236
host_tasks.push_back(tmp_cleanup_ev);
244237

245238
return std::make_pair(
@@ -543,30 +536,21 @@ std::pair<sycl::event, sycl::event> py_binary_ufunc(
543536
}
544537

545538
using dpctl::tensor::offset_utils::device_allocate_and_pack;
546-
const auto &ptr_sz_event_triple_ = device_allocate_and_pack<py::ssize_t>(
539+
auto ptr_sz_event_triple_ = device_allocate_and_pack<py::ssize_t>(
547540
exec_q, host_tasks, simplified_shape, simplified_src1_strides,
548541
simplified_src2_strides, simplified_dst_strides);
542+
auto shape_strides_owner = std::move(std::get<0>(ptr_sz_event_triple_));
543+
auto &copy_shape_ev = std::get<2>(ptr_sz_event_triple_);
549544

550-
py::ssize_t *shape_strides = std::get<0>(ptr_sz_event_triple_);
551-
const sycl::event &copy_shape_ev = std::get<2>(ptr_sz_event_triple_);
552-
553-
if (shape_strides == nullptr) {
554-
throw std::runtime_error("Unable to allocate device memory");
555-
}
545+
const py::ssize_t *shape_strides = shape_strides_owner.get();
556546

557547
sycl::event strided_fn_ev = strided_fn(
558548
exec_q, src_nelems, nd, shape_strides, src1_data, src1_offset,
559549
src2_data, src2_offset, dst_data, dst_offset, depends, {copy_shape_ev});
560550

561551
// async free of shape_strides temporary
562-
auto ctx = exec_q.get_context();
563-
564-
sycl::event tmp_cleanup_ev = exec_q.submit([&](sycl::handler &cgh) {
565-
cgh.depends_on(strided_fn_ev);
566-
using dpctl::tensor::alloc_utils::sycl_free_noexcept;
567-
cgh.host_task(
568-
[ctx, shape_strides]() { sycl_free_noexcept(shape_strides, ctx); });
569-
});
552+
sycl::event tmp_cleanup_ev = dpctl::tensor::alloc_utils::async_smart_free(
553+
exec_q, {strided_fn_ev}, shape_strides_owner);
570554

571555
host_tasks.push_back(tmp_cleanup_ev);
572556

@@ -796,30 +780,21 @@ std::pair<sycl::event, sycl::event>
796780
}
797781

798782
using dpctl::tensor::offset_utils::device_allocate_and_pack;
799-
const auto &ptr_sz_event_triple_ = device_allocate_and_pack<py::ssize_t>(
783+
auto ptr_sz_event_triple_ = device_allocate_and_pack<py::ssize_t>(
800784
exec_q, host_tasks, simplified_shape, simplified_rhs_strides,
801785
simplified_lhs_strides);
786+
auto shape_strides_owner = std::move(std::get<0>(ptr_sz_event_triple_));
787+
auto copy_shape_ev = std::get<2>(ptr_sz_event_triple_);
802788

803-
py::ssize_t *shape_strides = std::get<0>(ptr_sz_event_triple_);
804-
const sycl::event &copy_shape_ev = std::get<2>(ptr_sz_event_triple_);
805-
806-
if (shape_strides == nullptr) {
807-
throw std::runtime_error("Unable to allocate device memory");
808-
}
789+
const py::ssize_t *shape_strides = shape_strides_owner.get();
809790

810791
sycl::event strided_fn_ev =
811792
strided_fn(exec_q, rhs_nelems, nd, shape_strides, rhs_data, rhs_offset,
812793
lhs_data, lhs_offset, depends, {copy_shape_ev});
813794

814795
// async free of shape_strides temporary
815-
auto ctx = exec_q.get_context();
816-
817-
sycl::event tmp_cleanup_ev = exec_q.submit([&](sycl::handler &cgh) {
818-
cgh.depends_on(strided_fn_ev);
819-
using dpctl::tensor::alloc_utils::sycl_free_noexcept;
820-
cgh.host_task(
821-
[ctx, shape_strides]() { sycl_free_noexcept(shape_strides, ctx); });
822-
});
796+
sycl::event tmp_cleanup_ev = dpctl::tensor::alloc_utils::async_smart_free(
797+
exec_q, {strided_fn_ev}, shape_strides_owner);
823798

824799
host_tasks.push_back(tmp_cleanup_ev);
825800

0 commit comments

Comments
 (0)