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

Add a minimize_with_timeout wrapper for scipy.optimize.minimize #1403

Closed
wants to merge 1 commit into from

Conversation

Balandat
Copy link
Contributor

Summary:
Unfortunately, scipy does not allow timing out the optimization based on wall time. This diff implements a lightweight wrapper around scipy.optimize.minimize to achieve this.

The new minimize_with_timeout method calls scipy.optimize.minimize with all arguments forwarded verbatim. The only difference is that if provided a timeout_sec setting in the options dict, it automatically stops the optimization after the timeout is reached.

Internally, this is achieved by automatically constructing a callback method that is injected to the scipy.optimize.minimize call that keeps track of the runtime and is used to extract the value of the optimization variables at
the current iteration.

Differential Revision: D39529835

@facebook-github-bot facebook-github-bot added CLA Signed Do not delete this pull request or issue due to inactivity. fb-exported labels Sep 15, 2022
@facebook-github-bot
Copy link
Contributor

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

@codecov
Copy link

codecov bot commented Sep 15, 2022

Codecov Report

Merging #1403 (f3cb4eb) into main (02ec731) will not change coverage.
The diff coverage is 100.00%.

@@            Coverage Diff            @@
##              main     #1403   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files          153       154    +1     
  Lines        13686     13730   +44     
=========================================
+ Hits         13686     13730   +44     
Impacted Files Coverage Δ
botorch/exceptions/__init__.py 100.00% <ø> (ø)
botorch/exceptions/errors.py 100.00% <100.00%> (ø)
botorch/optim/utils/__init__.py 100.00% <100.00%> (ø)
botorch/optim/utils/timeout.py 100.00% <100.00%> (ø)

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

Balandat added a commit to Balandat/botorch that referenced this pull request Sep 16, 2022
…rch#1403)

Summary:
Pull Request resolved: pytorch#1403

Unfortunately, scipy does not allow timing out the optimization based on wall time. This diff implements a lightweight wrapper around `scipy.optimize.minimize` to achieve this.

The new `minimize_with_timeout` method calls `scipy.optimize.minimize` with all arguments forwarded verbatim. The only difference is that if provided a `timeout_sec` setting in the `options` dict, it automatically stops the optimization after the timeout is reached.

Internally, this is achieved by automatically constructing a callback method that is injected to the `scipy.optimize.minimize` call that keeps track of the runtime and is used to extract the value of the optimization variables at
the current iteration.

Differential Revision: D39529835

fbshipit-source-id: 6caced5e689a79231699025a50f76fb69cfecb20
@facebook-github-bot
Copy link
Contributor

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

Balandat added a commit to Balandat/botorch that referenced this pull request Sep 18, 2022
…rch#1403)

Summary:
Pull Request resolved: pytorch#1403

Unfortunately, scipy does not allow timing out the optimization based on wall time. This diff implements a lightweight wrapper around `scipy.optimize.minimize` to achieve this.

The new `minimize_with_timeout` method calls `scipy.optimize.minimize` with all arguments forwarded verbatim. The only difference is that if provided a `timeout_sec` setting in the `options` dict, it automatically stops the optimization after the timeout is reached.

Internally, this is achieved by automatically constructing a callback method that is injected to the `scipy.optimize.minimize` call that keeps track of the runtime and is used to extract the value of the optimization variables at
the current iteration.

Differential Revision: D39529835

fbshipit-source-id: 71fa5eabbb3f073e32796d9d3d451b6786ef3a2d
@facebook-github-bot
Copy link
Contributor

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

1 similar comment
@facebook-github-bot
Copy link
Contributor

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

Balandat added a commit to Balandat/botorch that referenced this pull request Dec 14, 2022
…rch#1403)

Summary:
Pull Request resolved: pytorch#1403

Unfortunately, scipy does not allow timing out the optimization based on wall time. This diff implements a lightweight wrapper around `scipy.optimize.minimize` to achieve this.

The new `minimize_with_timeout` method calls `scipy.optimize.minimize` with all arguments forwarded verbatim. The only difference is that if provided a `timeout_sec` kwarg, it automatically stops the optimization after the timeout is reached.

Internally, this is achieved by automatically constructing a callback method that is injected to the `scipy.optimize.minimize` call that keeps track of the runtime and is used to extract the value of the optimization variables at
the current iteration.

Differential Revision: D39529835

fbshipit-source-id: 27232f43dae509e5415ad412f6c21af16be49ff4
Balandat added a commit to Balandat/botorch that referenced this pull request Dec 14, 2022
…rch#1403)

Summary:
Pull Request resolved: pytorch#1403

Unfortunately, scipy does not allow timing out the optimization based on wall time. This diff implements a lightweight wrapper around `scipy.optimize.minimize` to achieve this.

The new `minimize_with_timeout` method calls `scipy.optimize.minimize` with all arguments forwarded verbatim. The only difference is that if provided a `timeout_sec` kwarg, it automatically stops the optimization after the timeout is reached.

Internally, this is achieved by automatically constructing a callback method that is injected to the `scipy.optimize.minimize` call that keeps track of the runtime and is used to extract the value of the optimization variables at the current iteration.

Differential Revision: D39529835

fbshipit-source-id: 5921cd81f00033d47df39f3ab2c47d9448952356
@facebook-github-bot
Copy link
Contributor

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

Balandat added a commit to Balandat/botorch that referenced this pull request Dec 14, 2022
…rch#1403)

Summary:
Pull Request resolved: pytorch#1403

Unfortunately, scipy does not allow timing out the optimization based on wall time. This diff implements a lightweight wrapper around `scipy.optimize.minimize` to achieve this.

The new `minimize_with_timeout` method calls `scipy.optimize.minimize` with all arguments forwarded verbatim. The only difference is that if provided a `timeout_sec` kwarg, it automatically stops the optimization after the timeout is reached.

Internally, this is achieved by automatically constructing a callback method that is injected to the `scipy.optimize.minimize` call that keeps track of the runtime and is used to extract the value of the optimization variables at the current iteration.

Differential Revision: D39529835

fbshipit-source-id: db1464963e6d04b6b1f68835099b44f9fc442d6b
@facebook-github-bot
Copy link
Contributor

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

…rch#1403)

Summary:
Pull Request resolved: pytorch#1403

Unfortunately, scipy does not allow timing out the optimization based on wall time. This diff implements a lightweight wrapper around `scipy.optimize.minimize` to achieve this.

The new `minimize_with_timeout` method calls `scipy.optimize.minimize` with all arguments forwarded verbatim. The only difference is that if provided a `timeout_sec` kwarg, it automatically stops the optimization after the timeout is reached.

Internally, this is achieved by automatically constructing a callback method that is injected to the `scipy.optimize.minimize` call that keeps track of the runtime and is used to extract the value of the optimization variables at the current iteration.

Differential Revision: D39529835

fbshipit-source-id: ce5bde193cc63ca4ed9a0a8f2b8cc3110a116640
Balandat added a commit to Balandat/botorch that referenced this pull request Dec 28, 2022
…rch#1403)

Summary:
Pull Request resolved: pytorch#1403

Unfortunately, scipy does not allow timing out the optimization based on wall time. This diff implements a lightweight wrapper around `scipy.optimize.minimize` to achieve this.

The new `minimize_with_timeout` method calls `scipy.optimize.minimize` with all arguments forwarded verbatim. The only difference is that if provided a `timeout_sec` kwarg, it automatically stops the optimization after the timeout is reached.

Internally, this is achieved by automatically constructing a callback method that is injected to the `scipy.optimize.minimize` call that keeps track of the runtime and is used to extract the value of the optimization variables at the current iteration.

Differential Revision: D39529835

fbshipit-source-id: 4f54079fc395d9b1ec7e88edbdb2962ce36231f3
@facebook-github-bot
Copy link
Contributor

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

Balandat added a commit to Balandat/botorch that referenced this pull request Dec 28, 2022
…rch#1403)

Summary:
Pull Request resolved: pytorch#1403

Unfortunately, scipy does not allow timing out the optimization based on wall time. This diff implements a lightweight wrapper around `scipy.optimize.minimize` to achieve this.

The new `minimize_with_timeout` method calls `scipy.optimize.minimize` with all arguments forwarded verbatim. The only difference is that if provided a `timeout_sec` kwarg, it automatically stops the optimization after the timeout is reached.

Internally, this is achieved by automatically constructing a callback method that is injected to the `scipy.optimize.minimize` call that keeps track of the runtime and is used to extract the value of the optimization variables at the current iteration.

Differential Revision: D39529835

fbshipit-source-id: adc79a40f1cfeebed4a5706ec4eea71691ea4619
Balandat added a commit to Balandat/botorch that referenced this pull request Dec 28, 2022
…rch#1403)

Summary:
Pull Request resolved: pytorch#1403

Unfortunately, scipy does not allow timing out the optimization based on wall time. This diff implements a lightweight wrapper around `scipy.optimize.minimize` to achieve this.

The new `minimize_with_timeout` method calls `scipy.optimize.minimize` with all arguments forwarded verbatim. The only difference is that if provided a `timeout_sec` kwarg, it automatically stops the optimization after the timeout is reached.

Internally, this is achieved by automatically constructing a callback method that is injected to the `scipy.optimize.minimize` call that keeps track of the runtime and is used to extract the value of the optimization variables at the current iteration.

Differential Revision: D39529835

fbshipit-source-id: 985ad2c06abf4c7326aeed6b29aa196b5d4b2a97
Balandat added a commit to Balandat/botorch that referenced this pull request Dec 28, 2022
…rch#1403)

Summary:
Pull Request resolved: pytorch#1403

Unfortunately, scipy does not allow timing out the optimization based on wall time. This diff implements a lightweight wrapper around `scipy.optimize.minimize` to achieve this.

The new `minimize_with_timeout` method calls `scipy.optimize.minimize` with all arguments forwarded verbatim. The only difference is that if provided a `timeout_sec` kwarg, it automatically stops the optimization after the timeout is reached.

Internally, this is achieved by automatically constructing a callback method that is injected to the `scipy.optimize.minimize` call that keeps track of the runtime and is used to extract the value of the optimization variables at the current iteration.

Differential Revision: D39529835

fbshipit-source-id: 50f773bfa2fb5b50ab9c6d724d6fc4a67e4f6a6e
Balandat added a commit to Balandat/botorch that referenced this pull request Dec 28, 2022
…rch#1403)

Summary:
Pull Request resolved: pytorch#1403

Unfortunately, scipy does not allow timing out the optimization based on wall time. This diff implements a lightweight wrapper around `scipy.optimize.minimize` to achieve this.

The new `minimize_with_timeout` method calls `scipy.optimize.minimize` with all arguments forwarded verbatim. The only difference is that if provided a `timeout_sec` kwarg, it automatically stops the optimization after the timeout is reached.

Internally, this is achieved by automatically constructing a callback method that is injected to the `scipy.optimize.minimize` call that keeps track of the runtime and is used to extract the value of the optimization variables at the current iteration.

Differential Revision: D39529835

fbshipit-source-id: f3f6c9654f0ea1a348610428ca5b01e8ef3d78ef
@facebook-github-bot
Copy link
Contributor

This pull request has been merged in b885609.

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.

2 participants