Repository navigation
fix(automl): enable limit_resource on LRL1Classifier (#1612) - #1634
Abhinav Maurya (Fire162) wants to merge 19 commits into
Conversation
LRL1Classifier omitted limit_resource = True, causing budgeted training in AutoML.fit to bypass resource and timeout limits. This adds limit_resource = True matching LRL2Classifier and unit tests verifying that resource limits are applied during fit.
There was a problem hiding this comment.
🟡 Changes recommended
The new invocation test fails on Windows and needs to skip platforms without resource limiting.
1 open issue
What changed in this PR
Enables existing resource limiting for L1 logistic regression, addressing budget overruns reported in #1612.
Changes:
- Sets
LRL1Classifier.limit_resource = True, matching L2. - Adds tests for the flag, budgeted fitting, and limiter invocation.
| File | Description |
|---|---|
test/automl/test_model.py |
Adds L1 resource-limiting regression tests. |
flaml/automl/model.py |
Enables resource limiting for LRL1Classifier. |
Review effort: Balanced
Li Jiang (thinkall)
left a comment
There was a problem hiding this comment.
Overall review of the complete PR: changes requested for a deterministic Windows test failure.
The LRL1 resource-limit flag matches LRL2 and reuses the existing production platform guard. The added invocation assertion does not respect that guard. Running the two new tests on Windows produced 1 passed and 1 failed: test_lrl1_resource_limit_called asserts a call even though resource is unavailable and BaseEstimator.fit intentionally bypasses the limiter. Please make that test capability-aware; do not remove the production guard. The review-code harness and current Balanced Copilot review agree on this blocker.
Posted by thinkall-agent-auto-reviewer
| X, y = make_classification(50, 5, random_state=0) | ||
| lr = LRL1Classifier() | ||
| lr.fit(X, y, budget=1.0) | ||
| assert len(called) > 0, "limit_resource was not invoked for LRL1Classifier" |
There was a problem hiding this comment.
This assertion fails on supported Windows platforms. model_mod.resource is None there, so BaseEstimator.fit deliberately does not enter limit_resource, regardless of the new LRL1 flag. I reproduced the failure with python -m pytest test/automl/test_model.py::test_lrl1 test/automl/test_model.py::test_lrl1_resource_limit_called -q (1 passed, 1 failed). Skip the invocation-specific case when resource is unavailable, or assert the appropriate call/no-call behavior for each capability while retaining the cross-platform fit smoke test.
Posted by thinkall-agent-auto-reviewer
Li Jiang (thinkall)
left a comment
There was a problem hiding this comment.
Re-reviewed commits 4d9553cefbb14233782ccfd928264bfde5ca739c -> 6d5a3a774153cf7836d651b90b73ad48e33694bb. The only delta is main's website/yarn.lock update of follow-redirects 1.16.0 -> 1.16.1. One explicitly head-bound review-code Low execution (actual runtime gpt-6.1-sol) found no new issue in this identical inherited patch. Controller Git comparisons verify all non-lockfile tree entries are unchanged. This is a scoped merge-delta review, not a fresh clean signoff for unchanged feature code.
Version/URL/caret/SRI shape checks pass. No independent local registry/tarball verification, package smoke test or website rebuild is claimed. Previous feature findings and runtime validation limits remain preserved.
Changes remain required. The existing Windows test blocker remains: test_lrl1_resource_limit_called still requires a limiter call when resource is unavailable and production deliberately bypasses that limiter. The test and production guard are unchanged by this merge. The prior Windows result was one passed and one failed; this cycle does not claim to rerun that native test. The original changes-requested review remains applicable.
At the 2026-10-26T12:13:44.943946+00:00 gate snapshot, actual current-head workflows were: Build in_progress/no conclusion; Code formatting completed/success; docs completed/success. Copilot has Balanced review without an Approval recommended verdict; 2 review thread(s) remain unresolved. Gate approval is not successful CI completion, and no new PR approval is being submitted while required gates remain unmet.
Posted by thinkall-agent-auto-reviewer
| def test_lrl1(): | ||
| BaseEstimator.search_space(1, "") | ||
| assert LRL1Classifier.limit_resource is True | ||
| X, y = make_classification(100, 10, random_state=0) | ||
| lr = LRL1Classifier() | ||
| lr.predict(X) | ||
| lr.fit(X, y, budget=1e-5) |
Li Jiang (thinkall)
left a comment
There was a problem hiding this comment.
Reviewed new commits from 6d5a3a774153cf7836d651b90b73ad48e33694bb to c831ee525ff1c995a893577a47ced80c164d0e7d. The main-branch advance is inherited across this update; the driver proves the complete resulting tree is the previously reviewed feature tree plus the same upstream patch, with no changed contributor feature blobs or function ASTs outside that integration.
One shared review-code Medium package used six independent isolated grok-4.7/xhigh lenses. All six original outcomes are issues_found and all canonical responses are committed on exact owning PR 1642 source aaa3b672462534d3e28dfbd3e88ce2e1c64a21ef, with explicit tree/content bindings to the updated heads. This is not six new whole-feature clearances or a blanket endorsement of unchanged feature code.
P2 inherited-upstream follow-up: real seasonal-naive HPO with 60,005 minute rows, period=12001, sample=True, min_sample_size=10000, max_iter=3, time_budget=15 chooses season 12,001 for a 10,000-row first trial and aborts with ValueError on current main and the owning updated head. Identical real-search settings succeed on exact prior main on both native stacks. Bound the season against the minimum actual sampled training window or avoid undersized sampling for that configuration. This issue is already in current main and inherited, not a new contributor-specific feature edit; it is preserved as an upstream follow-up rather than duplicated as an unrelated inline request. The shared review therefore does not grant new full-source approval. max_iter=1 bypasses search and refits full data, so those initial successful diagnostics were not used as HPO clearance.
Selected integration validation passed 592 executions of 296 distinct cases on native Windows Python 3.10/pandas 2.3.3/NumPy 1.26.4 and Python 3.13/pandas 3.0.5/NumPy 2.3.3. That includes actual classifier and naive/seasonal-average fits plus controlled accessor/facade tests. Additional native controls reject unproven zero-lag/season-1/NaT-lookup/sparse-exog allegations; actual SARIMAX sparse prediction selects the requested rows. No native Spark/TFT training or complete optional/minimum-version matrix is claimed. Passing selected tests does not override the independently reproduced P2.
Changes remain required for the existing feature finding: the limiter-invocation assertion is still unconditional on Windows where production intentionally bypasses the limiter because resource is unavailable. Both model and test blobs are byte-identical to the prior reviewed head. No duplicate inline is being posted.
At 2026-10-31T20:28:04.854853+00:00, actual current-head pull_request workflows were: Build in_progress/None (attempt 2); Code formatting completed/success (attempt 2); docs completed/success (attempt 2). 3 review thread(s) remain unresolved. No explicit current-head Balanced Copilot approval recommendation is claimed. No new PR approval is submitted while source or external gates remain unmet.
Posted by thinkall-agent-auto-reviewer
Li Jiang (thinkall)
left a comment
There was a problem hiding this comment.
Current foreign-feature review at author head 8ba4bba98ee58ccc2b4a34d400ab08554683f1a7.
The new LRL1Classifier.limit_resource flag in flaml/automl/model.py:2037 exposes problems in the shared limiter and fallback.
Controlled fake resource/signal protocols on both stacks show that a caller alarm/handler is not restored, a 1.9 second budget programs one second, out-of-order overlapping contexts leave the cap at 600 instead of the original 1000, and infinite timer setup raises after state changes. These are shared-helper defects newly reachable from L1; no real POSIX alarm or address-space limit was changed in these probes.
A forced-timeout L1 fit also loses sample_weight: labels [0,0,0,1] with weights [1,1,1,10] return a dummy predicting zero, whereas a weighted dummy predicts one. Main L1 bypasses the limiter and fits normally. Please make state ownership/cleanup safe and preserve weights in fallback before opting L1 into this path. The current targeted tests pass two cases and deliberately skip the two native-resource checks on Windows; that is not native POSIX enforcement proof.
Selected-scope independent coverage: 1/1. Source/documentation/test followups above remain; no overall approval is submitted. Local native validation uses Python3.10/3.13, not the new Python3.14/Spark4.2/4.3 matrix. Review artifacts are retained only in detached local evidence commits, not pushed to this PR.
Posted by thinkall-agent-auto-reviewer
| X, y = make_classification(100, 10, random_state=0) | ||
| lr = LRL1Classifier() | ||
| lr.predict(X) | ||
| lr.fit(X, y, budget=1e-5) |
Li Jiang (thinkall)
left a comment
There was a problem hiding this comment.
Clean imported-base integration only, reviewed at 9a0c6d507c0d31e160853328ec4f5397be72bb1d.
The new foreign SVC constructor change preserves explicit random_state (including None), consumes the random_seed alias, and retains clone/stacking behavior. The imported default forest classifier change leaves preprocessing to predict_proba, avoiding a second transformation while leaving regressor behavior unchanged. The selected tests pass14cases on each pinned stack (28for this head); the representative old-source controls fail26cases and pass2across stacks.
Exact merge-parent and changed-path checks show this is base alignment, not a new edit to this PR's original feature. The separate own-authored release README/docs/version paths were excluded from review. Independent Low coverage is1/1 at the live maximum reasoning, with a CLEAN verdict only for this imported-code scope. This does not resolve existing feature findings, active change requests, missing whole-PR evidence or prior safety stops, and is not overall PR approval.
All-files hooks passed for the retained local evidence commit. No contributor source was edited and no review outputs were pushed here.
At 2026-12-04T02:22:52.927435+00:00, checks=PENDING; actual current-head workflows: docs=completed/success; Build=in_progress/None; Code formatting=completed/success. Balanced Copilot approval recommendation=False; unresolved threads=4. Workflow permission is not CI success. Existing approval records, if retargeted by a base merge, are not a fresh whole-source or CI signoff.
Posted by thinkall-agent-auto-reviewer
Li Jiang (thinkall)
left a comment
There was a problem hiding this comment.
Imported FLOW2 integration only, reviewed at df782b41a26082dcbeaf59470ee98d1acfdbfa2a.
The imported unordered categorical choice correction picks an index instead of allowing NumPy to coerce the choice values. Tuple/mixed choices, movement and seeded draws pass14cases on each pinned stack (28for this head). Exact merge/path proofs show no new feature-author edit in this branch. Existing branch-feature findings, active change requests and missing whole-PR coverage are not cleared by this new-base review.
Independent Low coverage1/1 at maximum reasoning; original CLEAN outcome is retained. This narrow verdict is not whole-PR code-review clearance and cannot reset prior safety/coverage bounds.
All-files hooks passed for the retained local evidence commit. Own-authored workflow/package-metadata changes were excluded; no contributor source was edited and no review outputs were pushed here.
At 2026-12-04T07:22:11.970204+00:00, checks=PENDING; actual current-head workflows: Build=in_progress/None; Code formatting=completed/success; docs=completed/success. Balanced Copilot approval recommendation=True; unresolved threads=4. Workflow permission is not CI success.
Posted by thinkall-agent-auto-reviewer


Why are these changes needed?
In
flaml/automl/model.py,SKLearnEstimator.fit()checksgetattr(self, "limit_resource", None)before wrapping execution in thelimit_resourcecontext manager. WhileLRL2Classifierdeclareslimit_resource = True,LRL1Classifieromitted this attribute.Because
lrl1is included in the default classification estimator list, trainingLRL1Classifierwith a specifiedtime_budgetbypassed resource and timeout limiting entirely, causing long-running fits to overrun budgets significantly on wide or many-class datasets.This change:
limit_resource = TruetoLRL1Classifierinflaml/automl/model.py, aligning it withLRL2Classifier.test/automl/test_model.pyverifying thatLRL1Classifier.limit_resourceisTrue, fit respects budget constraints, andlimit_resourceis invoked during execution.Related issue number
Closes #1612
Checks