> ## Documentation Index
> Fetch the complete documentation index at: https://notes.kodekloud.com/llms.txt
> Use this file to discover all available pages before exploring further.

# A Katib Experiment

> Overview of Katib Experiments on Kubernetes for automated hyperparameter tuning, defining search space, objective, search algorithm, and trial templates to run and manage parallel trials

Katib Experiment is the Kubernetes-native resource for automated hyperparameter tuning. A single Experiment manifest declares the complete optimization workflow: which hyperparameters to search, which metric to optimize, which search algorithm to use, and how to run each trial. After you submit the manifest, Katib launches many trials across the cluster, collects metrics, and orchestrates the search automatically so you can find the best configuration without manual trial-and-error.

<Frame>
  <img src="https://mintcdn.com/kodekloud-c4ac6d9a/MGkgrGfKHDtoCnUb/images/Kubeflow/KServe-and-Katib/A-Katib-Experiment/katib-automated-hyperparameter-tuning-kubernetes.jpg?fit=max&auto=format&n=MGkgrGfKHDtoCnUb&q=85&s=d6bc7221d81a054eb2c0944a7960906b" alt="A presentation slide titled &#x22;What is a Katib Experiment?&#x22; describing Katib as the central resource for automated hyperparameter tuning on Kubernetes. The slide shows a hexagon telescope icon and five feature cards: automated workflow, how trials run, hyperparameter search space, optimization objective, and runs on Kubernetes." width="1920" height="1080" data-path="images/Kubeflow/KServe-and-Katib/A-Katib-Experiment/katib-automated-hyperparameter-tuning-kubernetes.jpg" />
</Frame>

Core components of a Katib Experiment

* Objective metric: the metric Katib optimizes (for example, minimize `loss` or maximize `accuracy`).
* Search algorithm: the exploration strategy (e.g., Random Search, Grid Search, Bayesian Optimization).
* Parameter (search) space: ranges and types for each hyperparameter.
* Trial template: the Kubernetes workload template that runs each training trial and how sampled parameters are injected.

| Component | Purpose | Example |
| - | - | - |
| Objective metric | Defines what to optimize and the optimization direction | `maximize accuracy` |
| Search algorithm | Strategy Katib uses to sample hyperparameters | `random` / `bayesian` |
| Parameter (search) space | Allowed values, ranges, and types for each parameter | `n-estimators: 50-200` |
| Trial template | Kubernetes manifest template that runs training jobs with injected parameters | `command: ["python","train.py","--lr=${trialParameters.lr}"]` |

<Frame>
  <img src="https://mintcdn.com/kodekloud-c4ac6d9a/MGkgrGfKHDtoCnUb/images/Kubeflow/KServe-and-Katib/A-Katib-Experiment/katib-experiment-components-objective-search-template.jpg?fit=max&auto=format&n=MGkgrGfKHDtoCnUb&q=85&s=b8118e772a22d82005cbd2c905b8ef97" alt="A presentation slide titled &#x22;Experiment Components&#x22; showing four rounded cards: Objective Metric, Search Algorithm, Parameter Space, and Trial Template. Each card gives a short description about what to optimize (loss/accuracy), how Katib explores hyperparameter space, allowed hyperparameter ranges, and how training jobs run on Kubernetes." width="1920" height="1080" data-path="images/Kubeflow/KServe-and-Katib/A-Katib-Experiment/katib-experiment-components-objective-search-template.jpg" />
</Frame>

Define the search space
The search space constrains which hyperparameter values Katib can try. You typically define numeric ranges, discrete choices, or categorical values. For example, when tuning a decision-tree-based model you might vary the number of estimators and maximum depth; Katib will sample combinations from those feasible ranges.

<Frame>
  <img src="https://mintcdn.com/kodekloud-c4ac6d9a/MGkgrGfKHDtoCnUb/images/Kubeflow/KServe-and-Katib/A-Katib-Experiment/define-search-space-nestimators-maxdepth.jpg?fit=max&auto=format&n=MGkgrGfKHDtoCnUb&q=85&s=4822e9e8a3546d88cacc72a98c1b23a9" alt="A presentation slide titled &#x22;Define the Search Space&#x22; showing feasible ranges for two hyperparameters with blue slider bars: n-estimators (50–200) and max-depth (3–15). The slide includes a &#x22;FEASIBLE RANGE (min → max)&#x22; label and a © KodeKloud copyright in the corner." width="1920" height="1080" data-path="images/Kubeflow/KServe-and-Katib/A-Katib-Experiment/define-search-space-nestimators-maxdepth.jpg" />
</Frame>

Trial template and parameter injection
Each trial is a standalone Kubernetes workload. The trial template shows how to run your training job and how sampled parameters are substituted into the container command or environment. Below is an example fragment of a trial template command where Katib injects sampled parameters:

```yaml theme={null}
command:
  - python
  - train.py
  - --n-estimators=${trialParameters.n-estimators}
  - --max-depth=${trialParameters.max-depth}
```

Submitting and running an Experiment
Once your Experiment YAML is ready, submit it to the cluster:

```bash theme={null}
kubectl apply -f experiment.yaml
```

Katib will create Trials, schedule training jobs, collect metrics, and continue the search until stopping criteria are met (e.g., max trials, max time, or converged objective).

<Callout icon="lightbulb" color="#1CB2FE">
  Ensure you use the correct namespace for your Katib installation (commonly `kubeflow` — lowercase) when running kubectl commands.
</Callout>

Monitoring Katib
Use standard Kubernetes commands to inspect Experiments and watch Trials as they run:

```bash theme={null}
kubectl get experiments -n kubeflow
kubectl get trials -n kubeflow --watch
```

Benefits of using Katib
Katib automates what would otherwise be manual experimentation. Instead of single-threaded trial-and-error, you get:

* Parallel trials across the cluster
* Continuous metric aggregation and evaluation
* Built-in search algorithms and pluggable strategies
* Kubernetes-native scheduling and resource management

<Frame>
  <img src="https://mintcdn.com/kodekloud-c4ac6d9a/MGkgrGfKHDtoCnUb/images/Kubeflow/KServe-and-Katib/A-Katib-Experiment/katib-automated-tuning-distributed-k8s-scheduling.jpg?fit=max&auto=format&n=MGkgrGfKHDtoCnUb&q=85&s=64964f4c65c86a6feba630d76a78113f" alt="A presentation slide titled &#x22;What We Achieved with Katib&#x22; comparing &#x22;Before&#x22; and &#x22;With Katib&#x22; outcomes. It shows three swaps: trial-and-error guessing → automated tuning, one model at a time → distributed experimentation, and hours of babysitting jobs → Kubernetes-native scheduling." width="1920" height="1080" data-path="images/Kubeflow/KServe-and-Katib/A-Katib-Experiment/katib-automated-tuning-distributed-k8s-scheduling.jpg" />
</Frame>

Further reading and references

* Katib documentation: [https://www.kubeflow.org/docs/components/hyperparameter-tuning/](https://www.kubeflow.org/docs/components/hyperparameter-tuning/)
* Kubernetes Concepts: [https://kubernetes.io/docs/concepts/overview/what-is-kubernetes/](https://kubernetes.io/docs/concepts/overview/what-is-kubernetes/)
* Fundamentals of MLOps course: [https://learn.kodekloud.com/user/courses/fundamentals-of-mlops](https://learn.kodekloud.com/user/courses/fundamentals-of-mlops)

This Kubernetes-native approach to hyperparameter tuning is a central idea in modern MLOps: automate repetitive experimentation, scale with Kubernetes, and accelerate model development by letting Katib explore the configuration space for you.

<CardGroup>
  <Card title="Watch Video" icon="video" cta="Learn more" href="https://learn.kodekloud.com/user/courses/kubeflow/module/d9b1b119-0c6f-494b-b063-8eccd99dbff7/lesson/df35bc8c-8a82-4e57-939a-e01ee116869c" />
</CardGroup>


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.