Skip to content

feat(api): validate grid search space and trial budget - #3870

Draft
sanskar-singh-2403 wants to merge 2 commits into
kubeflow:masterfrom
sanskar-singh-2403:feat/validate-grid-search-3862
Draft

feat(api): validate grid search space and trial budget#3870
sanskar-singh-2403 wants to merge 2 commits into
kubeflow:masterfrom
sanskar-singh-2403:feat/validate-grid-search-3862

Conversation

@sanskar-singh-2403

Copy link
Copy Markdown

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 numTrials budget that actually fits that product. The OptimizationJob API enforced neither, so an invalid grid config passed admission and then failed with a Python traceback from inside the suggestion-optuna container, 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:

  1. CEL rule on OptimizationJobSpec: when grid is set, every parameter must use a categorical search space.

  2. Webhook ValidateCreate: reject a grid job whose numTrials exceeds the number of grid combinations (the product of the categorical choice-set sizes).

The step-field alternative (quantised continuous spaces mapping onto Katib's FeasibleSpace.step) is intentionally out of scope here, since it is an API-surface addition better tracked separately under KEP-3562.

Testing:

  • Unit tests for the trial-budget check, including the equal-to-combinations boundary, the single-choice case, and a wide-parameter overflow regression.
  • Integration (envtest) cases covering both the CEL path (uniform / logUniform / Int rejected, categorical accepted, random with a continuous param accepted) and the webhook path (numTrials exceeding combinations rejected).

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:

  • Docs included if any changes are user facing

/area hpo
/kind feature

@google-oss-prow

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign andreyvelich for approval. For more information see the Kubernetes Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

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
sanskar-singh-2403 force-pushed the feat/validate-grid-search-3862 branch from f7ba59a to 8de0b1f Compare August 7, 2026 10:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

KEP-3562: [OptimizationJob] Validate Grid search against the search space and trial budget

2 participants