Skip to content

fix(automl): enable limit_resource on LRL1Classifier (#1612) - #1634

Open
Abhinav Maurya (Fire162) wants to merge 19 commits into
microsoft:mainfrom
Fire162:fix/lrl1-resource-limit
Open

Abhinav Maurya (Fire162) wants to merge 19 commits into
microsoft:mainfrom
Fire162:fix/lrl1-resource-limit

Conversation

@Fire162

Copy link
Copy Markdown

Why are these changes needed?

In flaml/automl/model.py, SKLearnEstimator.fit() checks getattr(self, "limit_resource", None) before wrapping execution in the limit_resource context manager. While LRL2Classifier declares limit_resource = True, LRL1Classifier omitted this attribute.

Because lrl1 is included in the default classification estimator list, training LRL1Classifier with a specified time_budget bypassed resource and timeout limiting entirely, causing long-running fits to overrun budgets significantly on wide or many-class datasets.

This change:

  1. Adds limit_resource = True to LRL1Classifier in flaml/automl/model.py, aligning it with LRL2Classifier.
  2. Adds unit tests in test/automl/test_model.py verifying that LRL1Classifier.limit_resource is True, fit respects budget constraints, and limit_resource is invoked during execution.

Related issue number

Closes #1612

Checks

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.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 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

Comment thread test/automl/test_model.py Resolved

@thinkall Li Jiang (thinkall) left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Comment thread test/automl/test_model.py
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"

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

The invocation test needs to account for Windows, where resource limiting is intentionally unavailable.

1 open issue

Review effort: Balanced

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

The limiter-invocation test needs to account for Windows, where resource limiting is unavailable.

1 open issue

Review effort: Balanced

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

The limiter-invocation test needs to account for Windows, where resource limiting is unavailable.

1 open issue

Review effort: Balanced

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

The invocation test needs a platform guard because resource limiting is bypassed on Windows, causing its assertion to fail.

1 open issue

Review effort: Balanced

@thinkall Li Jiang (thinkall) left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The resource-limit invocation test fails on Windows CI because limiting is intentionally bypassed there, and the new tests do not verify timeout enforcement or fallback prediction.

2 open issues

Review effort: Balanced

Comment thread test/automl/test_model.py
Comment on lines +24 to +30
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)

@thinkall Li Jiang (thinkall) left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@thinkall
Li Jiang (thinkall) requested a balanced review from Copilot November 2, 2026 14:31

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues are recorded for the change enabling resource and timeout limits for LRL1Classifier.

2 open issues

Review effort: Balanced

@thinkall Li Jiang (thinkall) left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues remain for the change enabling resource limits on LRL1Classifier.

2 open issues

Review effort: Balanced

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues are reported for the L1 logistic regression resource-limiting change.

2 open issues

Review effort: Balanced

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues remain for the L1 logistic regression resource-limiting change.

2 open issues

Review effort: Balanced

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues remain for the L1 logistic regression resource-limiting change.

2 open issues

Review effort: Balanced

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The new tests do not reliably verify timeout behavior, and LRL1 budget forwarding and usable fallback predictions after timeout remain untested.

3 open issues

Review effort: Balanced

Comment thread test/automl/test_model.py
X, y = make_classification(100, 10, random_state=0)
lr = LRL1Classifier()
lr.predict(X)
lr.fit(X, y, budget=1e-5)

@thinkall Li Jiang (thinkall) left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues remain for the change enabling resource and timeout limits for L1 logistic regression.

3 open issues

Review effort: Balanced

@thinkall Li Jiang (thinkall) left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

lrl1 can overrun time_budget by orders of magnitude (770x on Dionis)

3 participants