Skip to content

MNT Add CI job that tests for thread-safety bugs by enabling threaded parallelism by default - #35314

Merged
lesteve merged 20 commits into
scikit-learn:mainfrom
itamarst:35313-parallel-test-job
Nov 19, 2026
Merged

lesteve merged 20 commits into
scikit-learn:mainfrom
itamarst:35313-parallel-test-job

Conversation

@itamarst

@itamarst itamarst commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

Part 1 of #35313

Add a new testing mode where threading backend + parallelism catches bugs not caught by normal CI. Failing tests are skipped in this mode, so that CI will be green.

Follow-up PRs will then fix the issues, one by one, removing the relevant skips.

@itamarst

itamarst commented Nov 4, 2026

Copy link
Copy Markdown
Contributor Author

Previous slowest job was 22 minutes, new one is 28 minute, so not ideal...

@itamarst itamarst closed this Nov 4, 2026
@lesteve

lesteve commented Nov 5, 2026

Copy link
Copy Markdown
Member

Previous slowest job was 22 minutes, new one is 28 minute, so not ideal...

Is it the only reason why you closed this? I think 6 more minutes may be OKish, it could also be the case that free-threaded CI is slow because of things like #35101. You can try to change the Python version python<=3.14.6 to test this hypothesis.

@itamarst

itamarst commented Nov 5, 2026

Copy link
Copy Markdown
Contributor Author

No, I closed it just so it doesn't do unnecessary builds, I'm continuing working on this (but will likely split off the fixes to the problems I found). Will eventually re-open, either once the fixes are in, or maybe will mark everything as xfail and then remove it in fix PRs...

@lesteve

lesteve commented Nov 5, 2026

Copy link
Copy Markdown
Member

OK sounds good!

@itamarst itamarst reopened this Nov 5, 2026
@itamarst

itamarst commented Nov 5, 2026

Copy link
Copy Markdown
Contributor Author

3.14.6 didn't help, alas. Will try something else.

@itamarst

itamarst commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor Author

I was hoping to reduce the number of threads so it's not (deliberately) oversubscribed, but at least one of the bugs I'm hitting only happen when the number threads is significantly higher than the number of cores...

@github-actions github-actions Bot added size/M and removed size/S labels Nov 10, 2026
@itamarst

Copy link
Copy Markdown
Contributor Author

I switched to only run with scheduled or manually selected with [free-threaded] job, like the pytest-run-parallel one. And I skipped as many failing tests as possible so it'll be green when run here; follow-up PRs will fix the problem and remove the skip. (I didn't do xfail because it's often intermittent failure, but could switch if anyone cares; the hope is that this is all temporary.)

Failures are often inconsistent so will have to see what CI says, and will continue trying to reproduce problems locally.

@itamarst itamarst changed the title WIP MNT Add CI job that tests for thread-safety bugs by enabling threaded parallelism by default MNT Add CI job that tests for thread-safety bugs by enabling threaded parallelism by default Nov 10, 2026
@itamarst
itamarst marked this pull request as ready for review November 10, 2026 17:02
@itamarst

itamarst commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor Author

The stalled CI job is one that shouldn't be affected by this PR, I think? EDIT it finished, eventually, maybe it's just always that slow.

@itamarst

Copy link
Copy Markdown
Contributor Author

@lesteve ready for review

@itamarst

Copy link
Copy Markdown
Contributor Author

I've started working on fixing these (in separate branches). So far I've found one real bug, and two cases where it's probably just floating point numerical instability and tweaking the test is all it took to fix it (but I could be wrong and perhaps one or both are real bugs).

@ogrisel ogrisel moved this to PR waiting for reviews in Labs Nov 16, 2026
@ogrisel ogrisel added this to Labs Nov 16, 2026

@ogrisel ogrisel left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Appart from the following naming nit, LGTM. Thanks @itamarst.

Comment thread sklearn/conftest.py Resolved
@itamarst

Copy link
Copy Markdown
Contributor Author

I also switched job to always run based on feedback from someone at our meeting earlier today (@lesteve if I'm not misremembering).

@lesteve

lesteve commented Nov 17, 2026 •

Copy link
Copy Markdown
Member

I also switched job to always run based on feedback from someone at our meeting earlier today (@lesteve if I'm not misremembering).

I would leave it to only run on [free-threaded] commit marker to be consistent with the other free-threaded one. Maybe I wasn't 100% clear but what I try to say at one point is that since it runs only on explicit commit marker [free-threaded] it's not a huge deal if it is a bit slow.

@itamarst

Copy link
Copy Markdown
Contributor Author

Ah, OK, I restored it.

@itamarst
itamarst requested a review from ogrisel November 17, 2026 13:17
Comment thread sklearn/conftest.py Resolved

@lesteve lesteve left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few comments, but otherwise looks good!

Comment thread build_tools/github/test_script.sh Resolved
Comment thread .github/workflows/unit-tests.yml Resolved
Comment thread sklearn/conftest.py Resolved
Comment thread sklearn/conftest.py Resolved
Comment thread sklearn/utils/_testing.py Resolved
Comment thread sklearn/utils/_testing.py Resolved
@itamarst
itamarst requested a review from lesteve November 18, 2026 13:46
@itamarst

Copy link
Copy Markdown
Contributor Author

I addressed review comments.

Comment thread sklearn/cluster/tests/test_optics.py Resolved
@itamarst

Copy link
Copy Markdown
Contributor Author

And addressed that last one too.

@lesteve

lesteve commented Nov 19, 2026

Copy link
Copy Markdown
Member

In it goes, thanks!

@lesteve
lesteve merged commit 2fb9046 into scikit-learn:main Nov 19, 2026
35 of 36 checks passed
@github-project-automation github-project-automation Bot moved this from PR waiting for reviews to Done in Labs Nov 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants