Configure Placeholders
Parameter placeholders give you precise control over how parameters are passed to your training scripts and commands. Instead of manually crafting command-line arguments, you define them once in your valohai.yaml and let Valohai handle the parameter injection.
This approach makes hyperparameter optimization seamless and ensures all parameter values are tracked for reproducibility.
When to Use Parameter Placeholders
Use parameter placeholders when you need to:
Track parameters automatically for hyperparameter optimization
Avoid hardcoding values in your training scripts
Pass different parameter formats to various tools (e.g.,
--lr=0.001vslr 0.001)Handle multiple parameter values in a single execution
Core Placeholder Types
{parameters} - Inject All Parameters
The {parameters} placeholder injects all defined parameters into your command at once.
YAML Configuration:
- step:
name: train-model
image: python:3.11
command: python train.py {parameters}
parameters:
- name: max-steps
type: integer
description: Number of training steps
default: 300
- name: learning-rate
type: float
pass-as: --lr={v}
description: Initial learning rate
default: 0.001
- name: architecture
type: string
pass-as: --arch={v}
default: resnet50
optional: trueGenerated Command:
💡 Parameters only appear if they have values. Optional parameters with no value are skipped.
{parameter:} - Use Specific Parameters
Target individual parameters using {parameter:<NAME>} syntax. This is useful for multi-step commands or when you need parameters in specific positions.
YAML Configuration:
Generated Commands:
{parameter-value:} - Raw Values Only
Use {parameter-value:<NAME>} to pass only the parameter value, ignoring any pass-as formatting.
YAML Configuration:
Generated Command:
Advanced Use Cases
Parameters in Input Paths
Parameter placeholders work in input definitions, enabling dynamic data loading based on parameter values.
Multiple Value Parameters
Handle lists of values with multiple parameter configuration.
Comma-Separated Values:
Generated Command:
Repeated Arguments:
Generated Command:
Alternative: Configuration Files
For complex parameter structures, read parameters from JSON or YAML configuration files instead of command placeholders.
Python (Standard Library):
Python (valohai-utils):
💡 Learn more about available configuration files in System Configuration Files.
Best Practices
Combine placeholder types freely:
Use descriptive parameter names that match your script's argument parser.
Set reasonable defaults so executions work without manual parameter tuning.
Use optional: true for parameters that shouldn't appear when undefined.
Parameter placeholders make your ML workflows more flexible and your experiments more reproducible. They're essential for automated hyperparameter optimization and tracking parameter impact on model performance.
Last updated
Was this helpful?
