Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ENH: Support free-threaded python build (tracking issue) #26157

Open
6 of 8 tasks
ngoldbaum opened this issue Mar 28, 2024 · 4 comments
Open
6 of 8 tasks

ENH: Support free-threaded python build (tracking issue) #26157

ngoldbaum opened this issue Mar 28, 2024 · 4 comments
Assignees
Labels
39 - no-GIL PRs and issues related to support for free-threaded CPython (a.k.a. no-GIL, PEP 703) Tracking / planning

Comments

@ngoldbaum
Copy link
Member

ngoldbaum commented Mar 28, 2024

Myself, @lysnikolaou, and @rgommers are working on a new project in collaboration with the Python Runtime team at Meta to add support for Python 3.13 nogil builds in the scientific python software stack.

Our initial minimal goal is a build of NumPy that runs and passes all the tests in a nogil build of Python.

Resources:

Backlog

@ogrisel
Copy link
Contributor

ogrisel commented Apr 9, 2024

Maybe another interesting resource is the past work done by Sam Gross to patch numpy to make it work well enough with the original nogil fork of CPython 3.9: v1.24.0...colesbury:numpy:v1.24.0-nogil

Things might have drifted a bit since that time, but those patches are enough to get the scikit-learn test suite pass with nogil-CPython 3.9: see e.g. this run of the Linux_nogil pylatest_pip_nogil job that is scheduled run on a nightly basis on our Azure Pipelines CI.

@rgommers rgommers added the 39 - no-GIL PRs and issues related to support for free-threaded CPython (a.k.a. no-GIL, PEP 703) label Apr 10, 2024
@ngoldbaum
Copy link
Member Author

ngoldbaum commented Apr 16, 2024

It looks like numpy's main branch passes the full numpy test suite with the gil disabled. I've been testing using the nogil-integration branch in @colesbury's fork of CPython, but i tried just now using the CPython main branch and the test suite passes with the GIL disabled there as well.

There are still a ton of threading bugs I'm sure because of limited use of threads in the tests - we need better test coverage for threaded workflows. I'm already aware of a number of internal caches we'll likely need to disable or add locking for.

But, it's a good start!

@a-reich
Copy link

a-reich commented Apr 26, 2024

Just curious, are contributors planning to work on #24755 or is there any overlap where work for nogil would also help with allowing subinterpreters?

@ngoldbaum
Copy link
Member Author

ngoldbaum commented Apr 26, 2024

While this does have some overlap with work on subinterpreters since the C thread safety issues we're working on apply to subinterpreters as well, the bulk of the work required to support subinterpreters - converting numpy's extension types from single-phase to multi-phase initialization - is not required and we are not currently planning to do that.

@ngoldbaum ngoldbaum changed the title ENH: Support nogil python build (tracking issue) ENH: Support free-threaded python build (tracking issue) May 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
39 - no-GIL PRs and issues related to support for free-threaded CPython (a.k.a. no-GIL, PEP 703) Tracking / planning
Projects
None yet
Development

No branches or pull requests

4 participants