From 7d8b4cf8ec2cb9a8848bccb7fe436591de89bf68 Mon Sep 17 00:00:00 2001 From: Nikita Grigorian Date: Tue, 1 Jul 2025 14:35:03 -0700 Subject: [PATCH 1/4] unpin Cython for Python 3.13 --- conda-recipe/meta.yaml | 6 ------ pyproject.toml | 3 +-- 2 files changed, 1 insertion(+), 8 deletions(-) diff --git a/conda-recipe/meta.yaml b/conda-recipe/meta.yaml index 812362a627..a6e06f0dfd 100644 --- a/conda-recipe/meta.yaml +++ b/conda-recipe/meta.yaml @@ -41,12 +41,6 @@ requirements: - {{ dep }} {% elif dep.startswith('build>=') %} - {{ 'python-' ~ dep }} - {% elif dep.startswith('cython') %} - {% if dep.split(';')[1] == "python_version<'3.13'" %} - - {{ dep.split(';')[0] }} # [py<313] - {% else %} - - {{ dep.split(';')[0] }} # [py>=313] - {% endif %} {% else %} - {{ dep|replace('_','-') }} {% endif %} diff --git a/pyproject.toml b/pyproject.toml index 098eefa0a3..e7795060a6 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -8,8 +8,7 @@ requires = [ "scikit-build>=0.17.0", "ninja>=1.11.1; platform_system!='Windows'", "cmake>=3.29.0", - "cython>=3.0.10;python_version<'3.13'", - "cython>=3.0.10,<3.1.0;python_version>='3.13'", + "cython>=3.0.10", "numpy >=1.23", # WARNING: check with doc how to upgrade "versioneer[toml]==0.29" From b09c901209baad9e4968cc0422aef9fbdbda5cd3 Mon Sep 17 00:00:00 2001 From: Nikita Grigorian Date: Thu, 3 Jul 2025 13:17:43 -0700 Subject: [PATCH 2/4] conditionally avoid pytest-cov if Python is 3.13 --- conda-recipe/run_test.sh | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/conda-recipe/run_test.sh b/conda-recipe/run_test.sh index 63ae7996cc..ea36ada687 100644 --- a/conda-recipe/run_test.sh +++ b/conda-recipe/run_test.sh @@ -4,4 +4,8 @@ set -e ${PYTHON} -c "import dpctl; print(dpctl.__version__)" ${PYTHON} -m dpctl -f -${PYTHON} -m pytest -q -ra --disable-warnings --cov dpctl --cov-report term-missing --pyargs dpctl -vv +if ${PYTHON} --version 2>&1 | grep -q '^Python 3\.13'; then + ${PYTHON} -m pytest -q -ra --disable-warnings --pyargs dpctl -vv +else + ${PYTHON} -m pytest -q -ra --disable-warnings --cov dpctl --cov-report term-missing --pyargs dpctl -vv +fi From 819612f98e1ef5610397fc523d9726d74d3c1b70 Mon Sep 17 00:00:00 2001 From: Nikita Grigorian Date: Tue, 22 Apr 2025 20:19:52 -0700 Subject: [PATCH 3/4] Make pybind11 modules GIL-free --- dpctl/tensor/libtensor/source/tensor_accumulation.cpp | 2 +- dpctl/tensor/libtensor/source/tensor_ctors.cpp | 2 +- dpctl/tensor/libtensor/source/tensor_elementwise.cpp | 2 +- dpctl/tensor/libtensor/source/tensor_linalg.cpp | 2 +- dpctl/tensor/libtensor/source/tensor_reductions.cpp | 2 +- dpctl/tensor/libtensor/source/tensor_sorting.cpp | 2 +- dpctl/tensor/libtensor/source/tensor_sorting_radix.cpp | 2 +- dpctl/utils/src/device_queries.cpp | 2 +- dpctl/utils/src/order_keeper.cpp | 2 +- 9 files changed, 9 insertions(+), 9 deletions(-) diff --git a/dpctl/tensor/libtensor/source/tensor_accumulation.cpp b/dpctl/tensor/libtensor/source/tensor_accumulation.cpp index f1b6eedbd6..4935ed7e3c 100644 --- a/dpctl/tensor/libtensor/source/tensor_accumulation.cpp +++ b/dpctl/tensor/libtensor/source/tensor_accumulation.cpp @@ -29,7 +29,7 @@ namespace py = pybind11; -PYBIND11_MODULE(_tensor_accumulation_impl, m) +PYBIND11_MODULE(_tensor_accumulation_impl, m, py::mod_gil_not_used()) { dpctl::tensor::py_internal::init_accumulator_functions(m); } diff --git a/dpctl/tensor/libtensor/source/tensor_ctors.cpp b/dpctl/tensor/libtensor/source/tensor_ctors.cpp index 2dccc4e359..1212423029 100644 --- a/dpctl/tensor/libtensor/source/tensor_ctors.cpp +++ b/dpctl/tensor/libtensor/source/tensor_ctors.cpp @@ -170,7 +170,7 @@ void init_dispatch_vectors(void) } // namespace -PYBIND11_MODULE(_tensor_impl, m) +PYBIND11_MODULE(_tensor_impl, m, py::mod_gil_not_used()) { init_dispatch_tables(); init_dispatch_vectors(); diff --git a/dpctl/tensor/libtensor/source/tensor_elementwise.cpp b/dpctl/tensor/libtensor/source/tensor_elementwise.cpp index 56a5795a17..a3c5562914 100644 --- a/dpctl/tensor/libtensor/source/tensor_elementwise.cpp +++ b/dpctl/tensor/libtensor/source/tensor_elementwise.cpp @@ -28,7 +28,7 @@ namespace py = pybind11; -PYBIND11_MODULE(_tensor_elementwise_impl, m) +PYBIND11_MODULE(_tensor_elementwise_impl, m, py::mod_gil_not_used()) { dpctl::tensor::py_internal::init_elementwise_functions(m); } diff --git a/dpctl/tensor/libtensor/source/tensor_linalg.cpp b/dpctl/tensor/libtensor/source/tensor_linalg.cpp index b21777654e..5e008b9c70 100644 --- a/dpctl/tensor/libtensor/source/tensor_linalg.cpp +++ b/dpctl/tensor/libtensor/source/tensor_linalg.cpp @@ -28,7 +28,7 @@ namespace py = pybind11; -PYBIND11_MODULE(_tensor_linalg_impl, m) +PYBIND11_MODULE(_tensor_linalg_impl, m, py::mod_gil_not_used()) { dpctl::tensor::py_internal::init_dot(m); } diff --git a/dpctl/tensor/libtensor/source/tensor_reductions.cpp b/dpctl/tensor/libtensor/source/tensor_reductions.cpp index ff94c37eb6..836ecd29ff 100644 --- a/dpctl/tensor/libtensor/source/tensor_reductions.cpp +++ b/dpctl/tensor/libtensor/source/tensor_reductions.cpp @@ -29,7 +29,7 @@ namespace py = pybind11; -PYBIND11_MODULE(_tensor_reductions_impl, m) +PYBIND11_MODULE(_tensor_reductions_impl, m, py::mod_gil_not_used()) { dpctl::tensor::py_internal::init_reduction_functions(m); } diff --git a/dpctl/tensor/libtensor/source/tensor_sorting.cpp b/dpctl/tensor/libtensor/source/tensor_sorting.cpp index 1a264c780b..a0d2a126b0 100644 --- a/dpctl/tensor/libtensor/source/tensor_sorting.cpp +++ b/dpctl/tensor/libtensor/source/tensor_sorting.cpp @@ -34,7 +34,7 @@ namespace py = pybind11; -PYBIND11_MODULE(_tensor_sorting_impl, m) +PYBIND11_MODULE(_tensor_sorting_impl, m, py::mod_gil_not_used()) { dpctl::tensor::py_internal::init_merge_sort_functions(m); dpctl::tensor::py_internal::init_merge_argsort_functions(m); diff --git a/dpctl/tensor/libtensor/source/tensor_sorting_radix.cpp b/dpctl/tensor/libtensor/source/tensor_sorting_radix.cpp index d0880c4ccf..c5a88a8713 100644 --- a/dpctl/tensor/libtensor/source/tensor_sorting_radix.cpp +++ b/dpctl/tensor/libtensor/source/tensor_sorting_radix.cpp @@ -30,7 +30,7 @@ namespace py = pybind11; -PYBIND11_MODULE(_tensor_sorting_radix_impl, m) +PYBIND11_MODULE(_tensor_sorting_radix_impl, m, py::mod_gil_not_used()) { dpctl::tensor::py_internal::init_radix_sort_functions(m); dpctl::tensor::py_internal::init_radix_argsort_functions(m); diff --git a/dpctl/utils/src/device_queries.cpp b/dpctl/utils/src/device_queries.cpp index c350a1f280..05fea90e2a 100644 --- a/dpctl/utils/src/device_queries.cpp +++ b/dpctl/utils/src/device_queries.cpp @@ -132,7 +132,7 @@ std::uint32_t py_intel_memory_bus_width(const sycl::device &d) }; // namespace -PYBIND11_MODULE(_device_queries, m) +PYBIND11_MODULE(_device_queries, m, py::mod_gil_not_used()) { m.def("intel_device_info_device_id", &py_intel_device_id, "Get ext_intel_device_id for the device, zero if not an intel device", diff --git a/dpctl/utils/src/order_keeper.cpp b/dpctl/utils/src/order_keeper.cpp index 62fc7e7e65..7f0074f91a 100644 --- a/dpctl/utils/src/order_keeper.cpp +++ b/dpctl/utils/src/order_keeper.cpp @@ -6,7 +6,7 @@ #include "sequential_order_keeper.hpp" #include -PYBIND11_MODULE(_seq_order_keeper, m) +PYBIND11_MODULE(_seq_order_keeper, m, py::mod_gil_not_used()) { py::class_(m, "_OrderManager") .def(py::init()) From 3aa710e1de07f94c298abe826d1468cd526acfc2 Mon Sep 17 00:00:00 2001 From: Nikita Grigorian Date: Tue, 22 Apr 2025 23:40:05 -0700 Subject: [PATCH 4/4] Declare each Cython module free-threading compatible --- dpctl/_diagnostics.pyx | 1 + dpctl/_sycl_context.pyx | 1 + dpctl/_sycl_device.pyx | 1 + dpctl/_sycl_device_factory.pyx | 1 + dpctl/_sycl_event.pyx | 1 + dpctl/_sycl_platform.pyx | 1 + dpctl/_sycl_queue.pyx | 1 + dpctl/_sycl_queue_manager.pyx | 1 + dpctl/memory/_memory.pyx | 1 + dpctl/program/_program.pyx | 1 + dpctl/tensor/_dlpack.pyx | 1 + dpctl/tensor/_flags.pyx | 1 + dpctl/tensor/_usmarray.pyx | 1 + dpctl/tests/_cython_api.pyx | 1 + dpctl/utils/_compute_follows_data.pyx | 1 + 15 files changed, 15 insertions(+) diff --git a/dpctl/_diagnostics.pyx b/dpctl/_diagnostics.pyx index 3723c23493..397194aa88 100644 --- a/dpctl/_diagnostics.pyx +++ b/dpctl/_diagnostics.pyx @@ -17,6 +17,7 @@ # distutils: language = c++ # cython: language_level=3 # cython: linetrace=True +# cython: freethreading_compatible = True """ Implements developer utilities. """ diff --git a/dpctl/_sycl_context.pyx b/dpctl/_sycl_context.pyx index aefa6d301f..d1fff106c9 100644 --- a/dpctl/_sycl_context.pyx +++ b/dpctl/_sycl_context.pyx @@ -17,6 +17,7 @@ # distutils: language = c++ # cython: language_level=3 # cython: linetrace=True +# cython: freethreading_compatible = True """ Implements SyclContext Cython extension type. """ diff --git a/dpctl/_sycl_device.pyx b/dpctl/_sycl_device.pyx index 96efc310c3..eb8c8d2478 100644 --- a/dpctl/_sycl_device.pyx +++ b/dpctl/_sycl_device.pyx @@ -17,6 +17,7 @@ # distutils: language = c++ # cython: language_level=3 # cython: linetrace=True +# cython: freethreading_compatible = True """ Implements SyclDevice Cython extension type. """ diff --git a/dpctl/_sycl_device_factory.pyx b/dpctl/_sycl_device_factory.pyx index 6fe7a9ad78..b17c9e0bd6 100644 --- a/dpctl/_sycl_device_factory.pyx +++ b/dpctl/_sycl_device_factory.pyx @@ -17,6 +17,7 @@ # distutils: language = c++ # cython: language_level=3 # cython: linetrace=True +# cython: freethreading_compatible = True """ This module implements several device creation helper functions: diff --git a/dpctl/_sycl_event.pyx b/dpctl/_sycl_event.pyx index 8766408644..6aa6a49d51 100644 --- a/dpctl/_sycl_event.pyx +++ b/dpctl/_sycl_event.pyx @@ -17,6 +17,7 @@ # distutils: language = c++ # cython: language_level=3 # cython: linetrace=True +# cython: freethreading_compatible = True """ Implements SyclEvent Cython extension type. """ diff --git a/dpctl/_sycl_platform.pyx b/dpctl/_sycl_platform.pyx index 7ceb725083..8a2f7a6bee 100644 --- a/dpctl/_sycl_platform.pyx +++ b/dpctl/_sycl_platform.pyx @@ -17,6 +17,7 @@ # distutils: language = c++ # cython: language_level=3 # cython: linetrace=True +# cython: freethreading_compatible = True """ Implements SyclPlatform Cython extension type. """ diff --git a/dpctl/_sycl_queue.pyx b/dpctl/_sycl_queue.pyx index 48c882b860..c13f1f6d1e 100644 --- a/dpctl/_sycl_queue.pyx +++ b/dpctl/_sycl_queue.pyx @@ -17,6 +17,7 @@ # distutils: language = c++ # cython: language_level=3 # cython: linetrace=True +# cython: freethreading_compatible = True """ Implements SyclQueue Cython extension type. """ diff --git a/dpctl/_sycl_queue_manager.pyx b/dpctl/_sycl_queue_manager.pyx index bf720e9402..dc5165e9d6 100644 --- a/dpctl/_sycl_queue_manager.pyx +++ b/dpctl/_sycl_queue_manager.pyx @@ -17,6 +17,7 @@ # distutils: language = c++ # cython: language_level=3 # cython: linetrace=True +# cython: freethreading_compatible = True import logging from contextvars import ContextVar diff --git a/dpctl/memory/_memory.pyx b/dpctl/memory/_memory.pyx index 0cc6394741..f59025e55f 100644 --- a/dpctl/memory/_memory.pyx +++ b/dpctl/memory/_memory.pyx @@ -17,6 +17,7 @@ # distutils: language = c++ # cython: language_level=3 # cython: linetrace=True +# cython: freethreading_compatible = True """This file implements Python buffer protocol using Sycl USM shared and host allocators. The USM device allocator is also exposed through this module for diff --git a/dpctl/program/_program.pyx b/dpctl/program/_program.pyx index 3859314505..4983e6e469 100644 --- a/dpctl/program/_program.pyx +++ b/dpctl/program/_program.pyx @@ -17,6 +17,7 @@ # distutils: language = c++ # cython: language_level=3 # cython: linetrace=True +# cython: freethreading_compatible = True """Implements a Python interface for SYCL's program and kernel runtime classes. diff --git a/dpctl/tensor/_dlpack.pyx b/dpctl/tensor/_dlpack.pyx index 29b3eccead..483be0e30b 100644 --- a/dpctl/tensor/_dlpack.pyx +++ b/dpctl/tensor/_dlpack.pyx @@ -17,6 +17,7 @@ # distutils: language = c++ # cython: language_level=3 # cython: linetrace=True +# cython: freethreading_compatible = True cdef extern from "numpy/npy_no_deprecated_api.h": pass diff --git a/dpctl/tensor/_flags.pyx b/dpctl/tensor/_flags.pyx index 052687838c..d132ddde40 100644 --- a/dpctl/tensor/_flags.pyx +++ b/dpctl/tensor/_flags.pyx @@ -17,6 +17,7 @@ # distutils: language = c++ # cython: language_level=3 # cython: linetrace=True +# cython: freethreading_compatible = True from libcpp cimport bool as cpp_bool diff --git a/dpctl/tensor/_usmarray.pyx b/dpctl/tensor/_usmarray.pyx index 0e42b42faf..999c449119 100644 --- a/dpctl/tensor/_usmarray.pyx +++ b/dpctl/tensor/_usmarray.pyx @@ -17,6 +17,7 @@ # distutils: language = c++ # cython: language_level=3 # cython: linetrace=True +# cython: freethreading_compatible = True import numpy as np diff --git a/dpctl/tests/_cython_api.pyx b/dpctl/tests/_cython_api.pyx index e694ecb9c3..84e981e040 100644 --- a/dpctl/tests/_cython_api.pyx +++ b/dpctl/tests/_cython_api.pyx @@ -16,6 +16,7 @@ # cython: language=c++ # cython: language_level=3 +# cython: freethreading_compatible = True cimport dpctl as c_dpctl diff --git a/dpctl/utils/_compute_follows_data.pyx b/dpctl/utils/_compute_follows_data.pyx index ce3823ffd5..8d34d8b6d1 100644 --- a/dpctl/utils/_compute_follows_data.pyx +++ b/dpctl/utils/_compute_follows_data.pyx @@ -17,6 +17,7 @@ # distutils: language = c++ # cython: language_level=3 # cython: linetrace=True +# cython: freethreading_compatible = True """This file implements Python buffer protocol using Sycl USM shared and host allocators. The USM device allocator is also exposed through this module for