added a warning when n_trials budget is depleted but ask still return trials#1296
Open
sagar1sharma wants to merge 2 commits intodevelopmentfrom
Open
added a warning when n_trials budget is depleted but ask still return trials#1296sagar1sharma wants to merge 2 commits intodevelopmentfrom
sagar1sharma wants to merge 2 commits intodevelopmentfrom
Conversation
There was a problem hiding this comment.
Pull request overview
This pull request adds a warning mechanism to alert users when ask() is called after the optimization budget has been exhausted. The change maintains backward compatibility by continuing to return trials while warning users about this behavior, and updates documentation to explain the ask-and-tell interface behavior.
Changes:
- Added a warning flag and logic to warn users once when calling
ask()after budget exhaustion - Updated documentation to clarify ask-and-tell behavior after budget depletion
- Properly reset the warning flag in the
reset()method
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| smac/main/smbo.py | Added _warned_on_ask_after_budget_exhausted flag, warning logic in ask() method, and reset logic |
| docs/advanced_usage/5_ask_and_tell.md | Added warning section explaining ask-and-tell behavior after budget exhaustion |
Comments suppressed due to low confidence (4)
smac/main/smbo.py:164
- The warning message doesn't specify which type of budget was exhausted. Since budget_exhausted can be True due to walltime, cputime, or trial count limits, the message should clarify which specific budget(s) caused the exhaustion. Consider adding information about remaining_walltime and remaining_cputime in addition to remaining_trials, similar to the logging in the optimize() method at lines 350-354.
logger.warning(
"ask() was called after the scenario budget was exhausted."
f"remaining trials: {self.remaining_trials}). "
"SMAC will continue returning trials for backward compatibility."
)
smac/main/smbo.py:165
- The new warning functionality when ask() is called after budget exhaustion lacks test coverage. While test_ask_and_tell_after_optimization in tests/test_ask_and_tell/test_ask_and_tell_intensifier.py exercises this code path, it doesn't verify that the warning is emitted or that the warning flag is set correctly. Consider adding a test that captures and verifies the logger.warning call.
if self.budget_exhausted and not self._warned_on_ask_after_budget_exhausted:
logger.warning(
"ask() was called after the scenario budget was exhausted."
f"remaining trials: {self.remaining_trials}). "
"SMAC will continue returning trials for backward compatibility."
)
self._warned_on_ask_after_budget_exhausted = True
docs/advanced_usage/5_ask_and_tell.md:21
- The documentation states "SMAC does not hard-stop
ask()whenn_trialsis depleted" but this is misleading. The budget_exhausted check includes walltime, cputime, and n_trials budgets, not just n_trials. The documentation should clarify that ask() continues to return trials after any budget type is exhausted, not just when n_trials is depleted.
In pure ask-and-tell usage, SMAC does not hard-stop `ask()` when `n_trials` is depleted.
This means `ask()` can still return additional trials after budget exhaustion.
smac/main/smbo.py:82
- Trailing whitespace detected at the end of line 82. This should be removed to maintain code cleanliness and avoid potential issues with version control and linting tools.
self._warned_on_ask_after_budget_exhausted = False
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
…s trials
Reference Issues/PRs
Description, Motivation and Context
Changes
Type Of Changes
What is Missing?
Checklist
developbranch.CHANGELOG.rst.Any other comments?