Grid Search

Grid Search tests all possible combinations of your specified parameter values.

It's the most thorough approach, every combination gets evaluated. This works well when you have a manageable parameter space and want exhaustive results.

💡 Tip: For large parameter spaces, consider Random Search or Bayesian Optimization to reduce execution count.

Before you start

You need at least one step with parameters defined in your valohai.yaml:

- step:
    name: train-model
    image: tensorflow/tensorflow:2.6.0
    command:
      - python train.py {parameters}
    parameters:
      - name: learning_rate
        default: 0.001
        type: float
      - name: batch_size
        default: 32
        type: integer

You can also launch a Task from a completed execution without editing your YAML.

Parameter types

When creating a Grid Search Task, you can define parameters using these types:

Single: Use one specific value for this parameter across all executions.

Multiple: Provide a list of discrete values. Valohai will test every combination with other parameters.

Linear: Generate evenly spaced values between a minimum and maximum (e.g., 0.001, 0.002, 0.003).

Logspace: Generates values that are evenly spaced on a logarithmic scale, which means each step multiplies by a constant factor rather than adding a constant amount.

Create a Grid Search from Git

  1. Open your project in Valohai

  2. Go to the Tasks tab

  3. Click Create Task

  4. Select the step that contains your parameters

  5. Scroll to Parameters

  6. Confirm Grid search is selected as the Task type (this is the default)

  7. For each parameter:

    • Choose the type (Single, Multiple, Linear, Logspace)

    • Enter the values:

      • Multiple: One value per line

      • Linear/Logspace: Min, max, and count

  8. Click Create task

Valohai will queue executions for every parameter combination and start running them in parallel.

Create a Grid Search from an execution

If you've already run an execution and want to explore variations:

  1. Open your project in Valohai

  2. Go to the Executions tab and open a completed execution

  3. Click the Task button in the top-right corner

  4. Scroll to Parameters

  5. Confirm Grid search is selected

  6. Configure parameter values as described above

  7. Click Create task

Example: Grid Search Task

This configuration creates 12 executions (3 learning rates × 4 batch sizes):

Parameter

Type

Values

learning_rate

Multiple

0.001, 0.01, 0.1

batch_size

Multiple

16, 32, 64, 128

Each execution will train with one unique combination, and you can compare results in the Task view.

Next steps

Last updated

Was this helpful?