Repository navigation
Declare free-threading support in the sparse extension - #3101
Open
antonwolfy wants to merge 1 commit into
Open
antonwolfy wants to merge 1 commit into
antonwolfy wants to merge 1 commit into
Conversation
_sparse_impl was the only dpnp extension module without py::mod_gil_not_used(), so importing dpnp.scipy.sparse on a free-threaded Python build re-enabled the GIL for the whole process. Add a test that imports every compiled dpnp module on a free-threaded build and checks the GIL stays disabled.
antonwolfy
requested review from
ndgrigorian and
vlad-perevezentsev
as code owners
October 14, 2026 19:27
Contributor
|
View rendered docs @ https://intelpython.github.io/dpnp/pull/3101/index.html |
Collaborator
Contributor
|
Array API standard conformance tests for dpnp=0.21.0dev14=np2py314h8d9cdd5_5 ran successfully. |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
dpnp.backend.extensions.sparse._sparse_implwas the only dpnp extension module declared withoutpy::mod_gil_not_used(). On a free-threaded Python build, importing it (throughdpnp.scipy.sparse) re-enabled the GIL for the whole process, with aRuntimeWarning. Every other pybind11 extension and every Cython module in dpnp already declares free-threading support.The extension keeps no shared mutable state beyond its dispatch tables, which are filled once at import, so it can be declared safe like the others.
A new
dpnp/tests/test_free_threading.pyruns on free-threaded builds only (the3.14tCI jobs). In a subprocess it imports every compiled dpnp module and checks that the GIL stays disabled, so a future extension that forgets the declaration is caught too. It skips if a dependency has already re-enabled the GIL.The C++ change was not built locally; the new test was checked locally only for its module discovery (it finds and imports all 25 compiled modules) and its skip paths, so the CI
3.14tjobs are the real check.