Skip to main content

Documentation Index

Fetch the complete documentation index at: https://wb-21fd5541-style-guide-support-models-articles-20260527-00.mintlify.app/llms.txt

Use this file to discover all available pages before exploring further.

You can use W&B Sweeps with custom CLI commands if training configuration passes command-line arguments. This lets you run sweeps against existing training scripts that already expect specific CLI flags, without modifying how the script consumes its arguments. The following example shows a Bash terminal that trains a Python script named train.py and provides values that the script parses:
/usr/bin/env python train.py -b \
    your-training-config \
    --batchsize 8 \
    --lr 0.00001
To reproduce that invocation under a sweep, modify the command key in the sweep configuration YAML file so the sweep agent builds the same command line. Based on the previous example, the configuration looks like this:
program:
  train.py
method: grid
parameters:
  batch_size:
    value: 8
  lr:
    value: 0.0001
command:
  - ${env}
  - python
  - ${program}
  - "-b"
  - your-training-config
  - ${args}
The ${args} key expands to all parameters in the sweep configuration, formatted for argparse as --param1 value1 --param2 value2. If your script accepts additional arguments outside of argparse, use parse_known_args so unrecognized flags don’t cause the parser to fail:
parser = argparse.ArgumentParser()
args, unknown = parser.parse_known_args()
Depending on the environment, python might refer to Python 2. To invoke Python 3, use python3 in the command configuration:
program:
  script.py
command:
  - ${env}
  - python3
  - ${program}
  - ${args}

Sweeps