Skip to content

Pin BLAS to one thread per xdist worker in CI - #67

Merged
Autoplectic merged 1 commit into
mainfrom
pin-blas-threads
Nov 16, 2026
Merged

Autoplectic merged 1 commit into
mainfrom
pin-blas-threads

Conversation

@Autoplectic

Copy link
Copy Markdown
Member

CI's Ubuntu test jobs take about 2 hours, while Windows takes about 35 minutes with the same 4 xdist workers. The gap is concentrated in tests that run scipy optimizers (SLSQP, L-BFGS, basin-hopping) on tiny matrices. On the last run, test_separating_optima_finds_the_generating_flags took 1507 s on Ubuntu versus 70 s on Windows, and test_pipeline_offers_line_split_candidates 4142 s versus 343 s. Tests dominated by Python loops or HiGHS ran at the same speed on both.

The likely cause is BLAS oversubscription. The Linux and Windows numpy/scipy wheels use OpenBLAS, which starts a thread per CPU in every process. That gives 16 threads on a 4-vCPU runner, and those threads contend on every small LAPACK call. macOS wheels use Accelerate, which has no thread pool.

This PR sets OPENBLAS_NUM_THREADS=1 and OMP_NUM_THREADS=1 on the test steps of test and test-without-symbolic. The Ubuntu job durations on this PR are the experiment.

Co-authored-by: Cursor <cursoragent@cursor.com>
@Autoplectic
Autoplectic merged commit 331270c into main Nov 16, 2026
26 of 30 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant