Skip to content

Commit 2e87dc7

Browse files
authored
Enable free-threaded Python for dpnp (#3026)
This PR removes `python-gil` as a dependency for dpnp and enables free-threaded builds, which are now run in public CI as part of the conda-package workflow. Changes were made in particular to `dpnp_capi` aligning with similar changes in dpctl, print options which now align with NumPy's `ContextVar` approach, dpnp verbosity mode, and `dpnp.random` module, which has introduced locks for some state
1 parent 2191b84 commit 2e87dc7

38 files changed

Lines changed: 402 additions & 159 deletions

.github/workflows/check-onemath.yaml

Lines changed: 32 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ env:
1515
build-with-oneapi-env: 'environments/build_with_oneapi.yml'
1616
dpctl-pkg-env: 'environments/dpctl_pkg.yml'
1717
oneapi-pkgs-env: 'environments/oneapi_pkgs.yml'
18+
python-pkg-env: 'environments/python.yml'
1819
test-pkg-env: 'environments/test.yml'
1920
test-env-name: 'test_onemath'
2021
rerun-tests-on-failure: 'true'
@@ -29,9 +30,19 @@ jobs:
2930
# Needed to cancel any previous runs that are not completed for a given workflow
3031
actions: write
3132

33+
strategy:
34+
fail-fast: false
35+
matrix:
36+
python: ['3.14']
37+
python_spec: ['3.14.* *_cp314', '3.14.* *_cp314t']
38+
3239
runs-on: 'ubuntu-latest'
3340
timeout-minutes: 5
3441

42+
env:
43+
python-label: ${{ endsWith(matrix.python_spec, 't') && format('{0}t', matrix.python) || matrix.python }}
44+
python-install-spec: "python ${{ matrix.python_spec || format('{0}.*', matrix.python) }}"
45+
3546
steps:
3647
- name: Cancel Previous Runs
3748
uses: styfle/cancel-workflow-action@d07a454dad7609a92316b57b23c9ccfd4f59af66 # 0.13.1
@@ -48,18 +59,29 @@ jobs:
4859
with:
4960
packages: conda-merge
5061

62+
- name: Build Python env file
63+
run: |
64+
cat > ${{ env.python-pkg-env }} <<EOF
65+
name: Python interpreter to test with
66+
channels:
67+
- conda-forge
68+
dependencies:
69+
- ${{ env.python-install-spec }}
70+
EOF
71+
5172
- name: Merge conda env files
5273
run: |
5374
conda-merge ${{ env.dpctl-pkg-env }} \
5475
${{ env.oneapi-pkgs-env }} \
5576
${{ env.build-with-oneapi-env }} \
56-
${{ env.test-pkg-env }} > ${{ env.environment-file }}
77+
${{ env.test-pkg-env }} \
78+
${{ env.python-pkg-env }} > ${{ env.environment-file }}
5779
cat ${{ env.environment-file }}
5880
5981
- name: Upload artifact
6082
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
6183
with:
62-
name: ${{ env.environment-file-name }}
84+
name: ${{ env.environment-file-name }}-${{ env.python-label }}
6385
path: ${{ env.environment-file }}
6486

6587
test_by_tag:
@@ -71,6 +93,7 @@ jobs:
7193
fail-fast: false
7294
matrix:
7395
python: ['3.14']
96+
python_spec: ['3.14.* *_cp314', '3.14.* *_cp314t']
7497
os: [ubuntu-latest] # windows-2022 - no DFT support for Windows in oneMKL
7598

7699
runs-on: ${{ matrix.os }}
@@ -80,6 +103,9 @@ jobs:
80103
run:
81104
shell: ${{ matrix.os == 'windows-2022' && 'cmd /C CALL {0}' || 'bash -el {0}' }}
82105

106+
env:
107+
python-label: ${{ endsWith(matrix.python_spec, 't') && format('{0}t', matrix.python) || matrix.python }}
108+
83109
steps:
84110
- name: Checkout DPNP repo
85111
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
@@ -89,7 +115,7 @@ jobs:
89115
- name: Download artifact
90116
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
91117
with:
92-
name: ${{ env.environment-file-name }}
118+
name: ${{ env.environment-file-name }}-${{ env.python-label }}
93119
path: ${{ env.environment-file-loc }}
94120

95121
- name: Setup miniconda
@@ -100,7 +126,6 @@ jobs:
100126
miniforge-version: latest
101127
use-mamba: 'true'
102128
conda-remove-defaults: 'true'
103-
python-version: ${{ matrix.python }}
104129
environment-file: ${{ env.environment-file }}
105130
activate-environment: ${{ env.test-env-name }}
106131

@@ -111,7 +136,6 @@ jobs:
111136
miniforge-version: latest
112137
use-mamba: 'true'
113138
conda-remove-defaults: 'true'
114-
python-version: ${{ matrix.python }}
115139
environment-file: ${{ env.environment-file }}
116140
activate-environment: ${{ env.test-env-name }}
117141

@@ -188,6 +212,7 @@ jobs:
188212
fail-fast: false
189213
matrix:
190214
python: ['3.14']
215+
python_spec: ['3.14.* *_cp314', '3.14.* *_cp314t']
191216
os: [ubuntu-latest] # windows-2022 - no DFT support for Windows in oneMKL
192217

193218
runs-on: ${{ matrix.os }}
@@ -199,6 +224,7 @@ jobs:
199224

200225
env:
201226
onemkl-source-dir: '${{ github.workspace }}/onemkl/'
227+
python-label: ${{ endsWith(matrix.python_spec, 't') && format('{0}t', matrix.python) || matrix.python }}
202228

203229
steps:
204230
- name: Checkout DPNP repo
@@ -209,7 +235,7 @@ jobs:
209235
- name: Download artifact
210236
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
211237
with:
212-
name: ${{ env.environment-file-name }}
238+
name: ${{ env.environment-file-name }}-${{ env.python-label }}
213239
path: ${{ env.environment-file-loc }}
214240

215241
- name: Checkout oneMKL repo
@@ -232,7 +258,6 @@ jobs:
232258
miniforge-version: latest
233259
use-mamba: 'true'
234260
conda-remove-defaults: 'true'
235-
python-version: ${{ matrix.python }}
236261
environment-file: ${{ env.environment-file }}
237262
activate-environment: ${{ env.test-env-name }}
238263

@@ -243,7 +268,6 @@ jobs:
243268
miniforge-version: latest
244269
use-mamba: 'true'
245270
conda-remove-defaults: 'true'
246-
python-version: ${{ matrix.python }}
247271
environment-file: ${{ env.environment-file }}
248272
activate-environment: ${{ env.test-env-name }}
249273

0 commit comments

Comments
 (0)