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

Unpin scipy & use threadpoolctl in minimize_with_timeout #2712

Closed
wants to merge 1 commit into from

Conversation

saitcakmak
Copy link
Contributor

Scipy>=1.15 was leading to significant slowdowns in CI due to issues with OpenBLAS configuration (see scipy/scipy#22438). Thanks to suggestions by SciPy maintainers, we've found a solution that resolves the slowdown without modifying and global configurations for OpenBLAS.

This PR wraps minimize calls in minimize_with_timeout in a with threadpool_limits(limits=1, user_api="blas") context, which makes OpenBLAS operate single-threaded within the context. Since PyTorch relies on OpenMP & MKL rather than OpenBLAS, this does not affect the evaluations of the acquisition functions or the MLL.

Test Plan:
Compare runtimes in the following tutorial workflows
Baseline - with scipy 1.14.1, without threadpool_limits: https://github.com/pytorch/botorch/actions/runs/13044166839/job/36391816602
With scipy 1.14.1, with threadpool_limits: https://github.com/pytorch/botorch/actions/runs/13044167834/job/36391818438
With scipy 1.15.1, with threadpool_limits: https://github.com/pytorch/botorch/actions/runs/13044245918/job/36392026548

@facebook-github-bot facebook-github-bot added the CLA Signed Do not delete this pull request or issue due to inactivity. label Jan 30, 2025
@facebook-github-bot
Copy link
Contributor

@saitcakmak has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

Copy link

codecov bot commented Jan 30, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 99.98%. Comparing base (472de87) to head (8bf1230).
Report is 2 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2712   +/-   ##
=======================================
  Coverage   99.98%   99.98%           
=======================================
  Files         202      202           
  Lines       18602    18604    +2     
=======================================
+ Hits        18600    18602    +2     
  Misses          2        2           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Summary:
Scipy>=1.15 was leading to significant slowdowns in CI due to issues with OpenBLAS configuration (see scipy/scipy#22438). Thanks to suggestions by SciPy maintainers, we've found a solution that resolves the slowdown without modifying and global configurations for OpenBLAS. 

This PR wraps `minimize` calls in `minimize_with_timeout` in a `with threadpool_limits(limits=1, user_api="blas")` context, which makes OpenBLAS operate single-threaded within the context. Since PyTorch relies on OpenMP & MKL rather than OpenBLAS, this does not affect the evaluations of the acquisition functions or the MLL.


Test Plan:
Compare runtimes in the following tutorial workflows
Baseline - with scipy 1.14.1, without `threadpool_limits`: https://github.com/pytorch/botorch/actions/runs/13044166839/job/36391816602
With scipy 1.14.1, with `threadpool_limits`: https://github.com/pytorch/botorch/actions/runs/13044167834/job/36391818438
With scipy 1.15.1, with `threadpool_limits`: https://github.com/pytorch/botorch/actions/runs/13044245918/job/36392026548

Differential Revision: D68874700

Pulled By: saitcakmak
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D68874700

@facebook-github-bot
Copy link
Contributor

@saitcakmak merged this pull request in acae12d.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed Do not delete this pull request or issue due to inactivity. fb-exported Merged
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants