feat(api): validate grid search space and trial budget - #3870
Draft
sanskar-singh-2403 wants to merge 2 commits into
Draft
feat(api): validate grid search space and trial budget#3870sanskar-singh-2403 wants to merge 2 commits into
sanskar-singh-2403 wants to merge 2 commits into
Conversation
Contributor
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
Grid search enumerates the full cartesian product of the search space up front, so it needs a discrete space and a trial budget that fits. The API did not enforce either, so an invalid grid config passed admission and then failed with a Python traceback from inside the suggestion container, with nothing pointing at the offending field. Add two checks that reject these configs before the Experiment starts, mirroring what Katib validates: - CEL rule on OptimizationJobSpec: when grid is set, every parameter must use a categorical search space. This rejects uniform and logUniform for both Int and Float. The INTEGER branch in Katib calls int(parameter.step) on an empty string and raises before the finite-range logic runs, so rejecting only Float would still let a broken Int config through. - Webhook ValidateCreate: reject a grid job whose numTrials exceeds the product of the categorical choice-set sizes. This is a fold over the parameter list, which CEL cannot express, so it lives in the webhook that previously delegated everything to CEL. The step-field alternative for quantised continuous spaces is intentionally out of scope here and better tracked under KEP-3562. Add unit tests for the trial-budget check and envtest integration cases covering both the CEL and webhook paths. Signed-off-by: Sanskar Singh <sanskarsinghty1234@gmail.com>
sanskar-singh-2403
force-pushed
the
feat/validate-grid-search-3862
branch
from
August 7, 2026 10:55
f7ba59a to
8de0b1f
Compare
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.
What this PR does / why we need it:
Grid search enumerates the full cartesian product of the search space up front, so it needs a discrete space and a
numTrialsbudget that actually fits that product. TheOptimizationJobAPI enforced neither, so an invalid grid config passed admission and then failed with a Python traceback from inside thesuggestion-optunacontainer, with nothing pointing at the offending field. Katib rejects both cases before the Experiment starts; this PR brings that same pre-flight validation to Trainer.Two checks are added:
CEL rule on
OptimizationJobSpec: whengridis set, every parameter must use acategoricalsearch space.uniformandlogUniform, for bothIntandFloattypes.Intis deliberately not treated as a safe case. Katib's INTEGER branch callsint(parameter.step)on an empty string and raises before the finite-range logic runs, so a rule that only rejectedFloatwould still let a brokenIntconfig through. Reference: https://github.com/kubeflow/katib/blob/dec5030ef9791add2a7224d8ba3cb9b699bf70da/pkg/suggestion/v1beta1/internal/search_space.py#L53-L62Webhook
ValidateCreate: reject a grid job whosenumTrialsexceeds the number of grid combinations (the product of the categorical choice-set sizes).ValidateAlgorithmSettings. Reference: https://github.com/kubeflow/katib/blob/dec5030ef9791add2a7224d8ba3cb9b699bf70da/pkg/suggestion/v1beta1/optuna/service.py#L242-L251numTrials, so it stays correct and cannot overflowint64even at the API'sMaxItemsbounds (up to 100 parameters x 100 choices each).The
step-field alternative (quantised continuous spaces mapping onto Katib'sFeasibleSpace.step) is intentionally out of scope here, since it is an API-surface addition better tracked separately under KEP-3562.Testing:
Note on base branch: this builds on the OptimizationJob CRD from #3552, which is not yet merged. It targets that work and should be rebased onto master once #3552 lands.
Which issue(s) this PR fixes (optional, in
Fixes #<issue number>, #<issue number>, ...format, will close the issue(s) when PR gets merged):Fixes #3862
Checklist:
/area hpo
/kind feature