Repository navigation
Forward free_mem_ratio from compute_estimator to the evaluation - #1591
Conversation
`compute_estimator` takes `free_mem_ratio` and is given the user's value
by `AutoMLState._compute_with_config_base`, but both branches pass a
hard-coded 0 on to the evaluation:
free_mem_ratio=0, # holdout path
free_mem_ratio=0, # CV path
so the setting is dropped for every trial of the search. It survives only
in `train_estimator`, which forwards it correctly, so the final retrain
honours it while the search - where the repeated fits happen and memory
pressure is highest - does not.
The value reaches `estimator.fit`, which uses it to size the training
memory limit:
mem.available * (1 - free_mem_ratio) + rss
Spying on `GenericTask.evaluate_model_CV` during a small `AutoML.fit`
with `free_mem_ratio=0.25`:
before: every call receives 0
after: every call receives 0.25
|
@microsoft-github-policy-service agree |
Li Jiang (thinkall)
left a comment
There was a problem hiding this comment.
Reviewed the updated head: no blocking correctness findings. Both compute_estimator evaluation branches now forward the configured free_mem_ratio, consistent with final training; the default remains unchanged. I also confirmed the value reaches estimator fitting through both holdout and CV. I updated the branch and approved its pending workflow runs. The refreshed build matrix is still running, so I am leaving final approval pending CI rather than marking it merge-ready yet.
There was a problem hiding this comment.
🟡 Changes recommended
The holdout forwarding path lacks regression coverage.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
Forwards free_mem_ratio into per-trial AutoML evaluation so memory headroom applies during search.
Changes:
- Passes the configured ratio through holdout and cross-validation paths.
- Adds cross-validation regression coverage.
File summaries
| File | Description |
|---|---|
flaml/automl/ml.py |
Forwards the ratio to both evaluation paths. |
test/automl/test_free_mem_ratio.py |
Verifies forwarding during CV search. |
Review details
- Files reviewed: 2/2 changed files
- Comments generated: 1
- Review effort level: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
The existing test only exercised the CV branch of `compute_estimator`.
The two branches call different helpers - `evaluate_model_CV` and
`get_val_loss` - so each needs its own coverage.
Adds the holdout equivalent, recording what `get_val_loss` receives
during an `eval_method="holdout"` search. Both tests fail against the
hard-coded 0 with `assert {0} == {0.25}`.
|
Thanks both, and thanks Li Jiang (@thinkall) for merging main in and approving the workflow runs. copilot-pull-request-reviewer is right that the holdout path had no coverage — the two branches of Both tests now fail against the hard-coded 0 with |
Why are these changes needed?
free_mem_ratiois a documentedAutoML.fitsetting:AutoMLState._compute_with_config_basedoes passstate.free_mem_ratiointocompute_estimator, butcompute_estimatorthen hands a hard-coded0to the evaluation in both branches:So the setting is discarded for every trial of the search. It survives only in
train_estimator, which forwards it correctly (free_mem_ratio=free_mem_ratio), meaning the final retrain honours the value while the search — where the repeated model fits happen and memory pressure is highest — silently runs at 0.The value is not cosmetic; it sizes the training memory limit in
BaseEstimator.fit:so someone setting
free_mem_ratio=0.25to keep headroom during an AutoML run does not get it where it matters.Evidence
Spying on
GenericTask.evaluate_model_CVduring a smallAutoML.fit(..., free_mem_ratio=0.25, eval_method="cv"):free_mem_ratioreceived per call00.25Only the two call sites inside
compute_estimatorare changed; thefree_mem_ratio=0defaults in the three function signatures are left as they are.Related issue number
None — found while reading the search path, not from a filed issue.
Checks
ruff checkandruff format --checkare clean on both files.test/automl/test_free_mem_ratio.pyrecords whatevaluate_model_CVreceives during a realAutoML.fit. It fails onmainwithassert {0} == {0.25}and passes with this change.