Skip to content

feat(operator): Implement OptimizationJob reconciler loop - #3878

Open
Swaraj-do wants to merge 1 commit into
kubeflow:masterfrom
Swaraj-do:feat/optimization-job-controller
Open

feat(operator): Implement OptimizationJob reconciler loop#3878
Swaraj-do wants to merge 1 commit into
kubeflow:masterfrom
Swaraj-do:feat/optimization-job-controller

Conversation

@Swaraj-do

Copy link
Copy Markdown

What this PR does / why we need it

This PR implements the OptimizationJobReconciler controller in pkg/controller/optimizationjob_controller.go to orchestrate hyperparameter tuning trial TrainJobs per KEP-3562 (https://github.com/kubeflow/trainer/blob/master/proposals/2605-optimization-job-crd/README.md).

Key Features Implemented

  • Controller Reconciler: Implemented OptimizationJobReconciler with ctrl.NewControllerManagedBy(mgr) watching OptimizationJob and owning child TrainJobs.
  • Trial Orchestration: Dynamically provisions trial TrainJobs from spec.trainJobTemplate.
  • Parameter Sampling & Injection: Samples parameter values across Categorical, Uniform, and LogUniform search spaces and injects them as environment variables (KUBEFLOW_TRAINER_OPT_) into trainJob.spec.trainer.env and metadata annotations.
  • Concurrency & Limits: Enforces parallelTrials concurrency limits and total numTrials limits.
  • Status & Result Recording: Initializes .status.conditions (Created, Complete, Failed) and records highest-performing trial parameters in .status.result.
  • Controller Registration: Registered NewOptimizationJobReconciler in SetupControllers (pkg/controller/setup.go).
  • Unit Test Suite: Added unit tests in pkg/controller/optimizationjob_controller_test.go verifying reconciler status initialization, trial creation, env var injection, and trial completion.

Which issue(s) this PR fixes

Fixes #3877

Checklist

  • Title follows conventional commit guidelines (feat(controller): ...)
  • Code complies with project style and guidelines
  • Unit tests added and passing cleanly (go test ./pkg/controller/...)
  • DCO Signed-off

Implement OptimizationJobReconciler controller in pkg/controller/optimizationjob_controller.go to orchestrate hyperparameter tuning trial TrainJobs per KEP-3562 (proposals/2605-optimization-job-crd/README.md).

- Add OptimizationJobReconciler controller watching OptimizationJob and owning child TrainJobs
- Sample parameter values across Categorical, Uniform, and LogUniform search spaces
- Inject hyperparameter environment variables (KUBEFLOW_TRAINER_OPT_<NAME>) into TrainJob trainer specs and metadata annotations
- Enforce parallelTrials concurrency limits and numTrials total trial limits
- Update status conditions (Created, Complete, Failed) and record best trial parameters in status.result
- Register reconciler in SetupControllers in setup.go
- Add unit tests in pkg/controller/optimizationjob_controller_test.go

Fixes kubeflow#3877

Signed-off-by: Swaraj-do <swarajmohanty183@gmail.com>
@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 tenzen-y 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

@Swaraj-do Swaraj-do changed the title feat(controller): Implement OptimizationJob reconciler loop feat(operator): Implement OptimizationJob reconciler loop Aug 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(controller): Implement OptimizationJob reconciler loop

2 participants