build: add freethreaded python ci and wheels#284
Conversation
|
Nope it's in beta now! |
|
refreshing this PR since there's now beta2 of the freethreaded pydantic |
|
I noticed when it's doing the freethreaded windows build that the MS linker is looking for Results in the error (I think): I think that's the only blocker on windows. |
|
That looks like https://gitlab.kitware.com/cmake/cmake/-/issues/26016, which is supposedly fixed but I'm not sure in which CMake version. |
Ah, sorry, now I see 3.30.3 — so supposedly it should work here. |
|
Sorry for thinking loudly. I see that CMake is doing the right thing: So looks like |
|
No problem - think out loud all you want. I'm just not sure where to look :-) |
|
You need to use the modern FindPython, not the old one. FindPythonLibs / FindPythonInterp was "removed" (sort of) in CMake 3.27, so that's not what 3.30.3 is referring to. |
|
Right above here Lines 16 to 21 in ea10902 set(PYBIND11_FINDPYTHON ON). pybind11 3.0 will change the default.
|
|
Thanks @henryiii, giving it a try. |
|
3.13t manylinux wheels are dying on tests because of missing awkward 3.13t wheel. Otherwise they build fine! |
|
@henryiii I guess the best way to test this in freethreaded mode for races and such would to first just try pytest-parallel? Probably mark the dask tests to not be run in parallel? |
|
Yes, I believe so. |
|
Nice - parallel tests seem to go, except on windows. Looks like some issue with parallel processing on windows to begin with. |
|
I don't really understand this failure in macos. Must be a threadsafety thing, but then why not in ubuntu? |
|
Oh wow, it's definitely a thread safety issue (it passed in this latest commit!). Yikes! |
|
@nsmith- Any first ideas on what needs a mutex around it? |
|
For reference the error that crops up in the MT tests is: |
|
My best guess would be something related to this: Lines 106 to 108 in 093ce46 is not threadsafe. |
|
Digging around there seems to be something suspicious w.r.t. the Will continue digging. |
|
OK - majorly thinned down on changes. Let's see how it rolls :-) |
1d3491c to
0d0fb91
Compare
|
A lot of packages are now not supporting 3.13t as that was experimental and are just testing 3.14t only. We should probably do 3.14t only? |
|
Yeah features might drift significantly from the 3.13t version so probably a good idea. I'll take it out. |
.github/workflows/ci.yml
Outdated
|
|
||
| - name: Test package (parallel) | ||
| if: endsWith(matrix.python-version , 't') | ||
| run: python -Xgil=0 -m pytest -ra --parallel-threads=16 --iterations=10 |
There was a problem hiding this comment.
Maybe this is too many threads? Idk how many threads the CI workers have. Numpy tests with 4 but they have a much larger test suite. Maybe 8 would be good here?
There was a problem hiding this comment.
It all runs so fast it probably doesn't matter.
pyproject.toml
Outdated
|
|
||
| [tool.cibuildwheel] | ||
| skip = ["cp314t-*"] | ||
| skip = [] |
There was a problem hiding this comment.
can this field be removed altogether if we're not skipping anything
pyproject.toml
Outdated
| test-groups = ["test"] | ||
| test-command = "python -m pytest {package}/tests" | ||
| test-skip = ["*-musllinux_*", "cp3{10,11,12}-win32"] | ||
| test-skip = ["cp314t-*", "cp313t-*", "*-musllinux_*", "cp3{10,11,12}-win32", "cp3*t-*:x86_64"] |
There was a problem hiding this comment.
I'm not in expert in cibuildwheel configuration but this skips tests when building correct? Is that what we want? We just trust that the regular CI testing is good here?
There was a problem hiding this comment.
I'll try removing it again but the threaded tests were failing because of missing wheels and building is not support in the cibuildwheel environment (at least if you're a sane person). It's getting tested anyway in the basic CI, so this is largely benign.
There was a problem hiding this comment.
I'll remove it for now to see if it was largely people dropping 3.13t.
|
Ah yeah it because people were dropping 3.13t. Cool we pass now :-) |
|
@nsmith- ok - looks like this is good to go too and is thoroughly tested. Please review and merge as you see fit. |
.github/workflows/ci.yml
Outdated
|
|
||
| - name: Test package (parallel) | ||
| if: endsWith(matrix.python-version , 't') | ||
| run: python -Xgil=0 -m pytest -ra --parallel-threads=16 --iterations=10 |
There was a problem hiding this comment.
One final comment I have is that I don't know if we should have -Xgil=0 here. This forces the gil to be disabled even if a module requires it because it cannot run without it.
There was a problem hiding this comment.
That's awkward array and a few other packages. If you try to import without this is switches away from no-gil mode, destroying the efficacy of the tests.
There was a problem hiding this comment.
If it's a per-module re-instantiation of the gil, then that is a different matter. My understanding is that this globally re-enables the GIL behavior of all modules.
There was a problem hiding this comment.
Really? But we do test free-threaded awkward. This was my source:
https://py-free-threading.github.io/running-gil-disabled/#force-the-gil-to-be-disabled
There was a problem hiding this comment.
Ah ok - it's here: https://github.com/scikit-hep/awkward/blob/main/awkward-cpp/src/python/_ext.cpp#L12
Good.
| if: ${{ !endsWith(matrix.python-version , 't') }} | ||
| run: python -m pytest -ra | ||
|
|
||
| - name: Test package (parallel) | ||
| if: endsWith(matrix.python-version , 't') | ||
| run: python -m pytest -ra --parallel-threads=16 --iterations=10 |
There was a problem hiding this comment.
Ah, apologies for seeing these one by one, but one final thought here. It is now doing only parallel testing in 3.14t. We should probably do normal testing on all of them and parallel testing as an extra in free-threaded python. (just no if condition for python -m pytest -ra) basically.
There was a problem hiding this comment.
The parallel tests are strictly more stringent since we have deterministic outcomes here. Further testing is unnecessary.
There was a problem hiding this comment.
What I would try to catch with this is a pybind11 or cpython bug that isn't there in free-threaded mode in 3.14, that's all.
There was a problem hiding this comment.
That sounds like tests the python core team would/should do, not us. The code on our side is the same.
Will add wheels when they're fixed up by #283