Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

srb agent tune — Hyperparameter Optimization

Use srb agent tune with Optuna to tune reinforcement-learning hyperparameters. The Isaac-free study process launches training children. Install with uv sync --extra tune. See the Hyperparameter Tuning workflow for concepts, wall-clock estimates, and adoption guidance.

Verbs

srb agent tune check    [options]   # preflight without training (Isaac-free)
srb agent tune run      [options]   # run or resume a study
srb agent tune status   --study S   # summarize a study
srb agent tune validate --study S   # rerun top trials on fresh seeds
srb agent tune export   --study S   # write a tuned config
srb agent tune repair   --study S   # fail stale RUNNING trials
srb agent tune baseline [options]   # capture portfolio normalization baselines

run Options

OptionDescriptionDefault
-e/--env/--task ENVSingle task—
--tasks T [T …]Portfolio task set, trained in turn—
--algo ALGOAlgorithm label (e.g. skrl_ppo)REQUIRED
--obs {state,visual}Observation modality; visual needs registered profilesstate
--trial-steps NTotal environment steps per trial, per task segment (canonical budget)REQUIRED
--n-trials NTarget; terminal and RUNNING trials count20
--n-workers NConcurrent trial slots1
--gpus 0,1GPU ids, round-robin; otherwise inherit framework defaultunset
--trial-num-envs NParallel envs per trial (pinned; drives budget conversion)1024
--seed-base NBase seed; child seed = seed-base + trial*seeds-per-trial + replicate42
--seeds-per-trial KReplicates averaged per trial; pruning uses replicate 01
--pin agent.X=Y …Fixed, unsampled config values—
--objective {ep_return_mean,success_rate}Tail-mean objective fieldep_return_mean
--normalize {none,baseline,rank}Portfolio score normalizationnone
--aggregate {median,mean,min}Portfolio task aggregationmedian
--max-wall-hours HStop starting trials after this limit—
--trial-timeout SKill a trial after this many seconds—
--fps FMeasured env-steps/s for runtime estimate—
--n-startup NTPE random-startup trials10; 15 portfolio
--boot-stagger SSerialize concurrent Isaac first-boots; stops after first child reports metrics30 if --n-workers > 1, else 0
--keep-artifactsKeep PRUNED child logdirs (deleted after the prune by default); configs and metrics always surviveFalse
--retry-failed NRe-enqueue up to N failed sets at startup; skip reason=timeout, raise --n-trials to fund retries0
--version NVersion for incompatible reruns1
--logdir/--logsStudy artifact rootlogs/tune
--storage URLPostgreSQL Optuna URL (postgresql:// or postgresql+psycopg2://) for shared workers; requires tune-rdbJournal file

All actions reject bare key=value and tokens after --; use --pin KEY=VALUE to fix values for every trial. --storage never falls back to a journal. Install both extras with uv sync --extra tune --extra tune-rdb. Credentials are redacted; unsupported schema changes fail closed without migration. Back up PostgreSQL before an operator-managed schema upgrade.

If a task does not emit the selected objective, e.g. success_rate, its trial fails early with success_rate_unavailable.

Averaging seeds during a study (--seeds-per-trial)

--seeds-per-trial K averages K distinct-seed children; failed replicates are excluded and survivors cost about K times more because pruning uses replicate 0. Resume rejects changes to search space, tasks, budget, objective, observation mode, ordered pins, resolved agent config, --trial-num-envs or --seeds-per-trial, and rejects legacy studies that lack these fields; use --version for an incompatible study. seed-base and Optuna-version changes are allowed. Use validate to rerank leaders on fresh seeds.

check Options

check runs trial config and budget checks in memory, starts no study or child, prints [OK], [WARN], or [FAIL], and exits nonzero on hard errors. It accepts config-shaping run options: -e/--env/--task, --tasks, --algo (REQUIRED), --obs, --trial-steps (REQUIRED), --pin, --trial-num-envs, --seed-base, --seeds-per-trial, --normalize, --aggregate, --objective, --fps, --n-trials, --n-workers, --version, and --logdir. Baseline-normalized portfolios also check each task’s baseline is present and fresh; --fps adds a runtime estimate.

srb agent tune check --env sample_collection --algo skrl_ppo --trial-steps 10_000_000 --fps 50000
srb agent tune check --tasks sample_collection peg_in_hole --algo skrl_ppo \
  --trial-steps 10_000_000 --normalize baseline   # also checks baselines.yaml

validate Options (noise arbiter)

validate reruns top completed trials with fresh seeds, using recorded configs and pins; only seeds change. Portfolio runs repeat every task segment with study normalization. It writes <study>/validation.json without changing trial records. Choose a --seed-base range disjoint from training seeds; candidates need at least --min-ok completed seeds (default: majority).

OptionDescriptionDefault
--study NAMEStudy to validateREQUIRED
--storage URLStudy PostgreSQL URLjournal default
--top-k KTop trials by training value to rerun3
--seeds SFresh seeds per candidate3
--seed-base BValidation seed base; seeds are B through B+S-110000
--min-ok NCompleted seeds required for winnermajority of --seeds
--validate-steps NEnv-steps per rerun; raise above the study budget for higher fidelitystudy budget
--gpus 0,1GPU ids, round-robin; otherwise inherit framework defaultunset
--n-workers NConcurrent rerun slots1
--trial-timeout SKill a rerun after this many seconds—
--keep-artifactsKeep rerun child logdirsFalse
--logdir/--logsStudy artifact rootlogs/tune
srb agent tune validate --study srb-skrl_ppo-state-sample_collection-v1 \
  --top-k 5 --seeds 4 --gpus 0,1

The report ranks validated means and names the robust winner; if it differs from best_trial, it prints that trial’s export command.

status / export / repair Options

OptionApplies toDescriptionDefault
--study NAMEallStudy name (e.g. srb-skrl_ppo-state-pick-v1)REQUIRED
--storage URLstatus, export, repairPostgreSQL study URLjournal default
--logdir/--logs PATHstatus, export, repairStudy artifact rootlogs/tune
--trial N or bestexportTrial to exportbest
--to {task,global}exportTask-specific (L1) or global (L0) slot; default depends on studystudy-dependent
--dry-runexportPrint diff without writingFalse
--forceexportOverwrite existing fileFalse
--stale-hours HrepairFail RUNNING trials older than this24

Portfolio exports default to global; --to task is ambiguous and errors.

baseline Options

Capture floor/reference scores per task for --normalize baseline; entries go to hyperparams/tune/baselines.yaml.

OptionDescriptionDefault
-e/--env/--task / --tasksTask(s) to baseline—
--algo ALGOBaseline algorithm labelREQUIRED
--obs {state,visual}Observation modalitystate
--budget/--ref-steps NReference env-steps (same as trial budget)REQUIRED
--floor-steps NRandom-rollout env-steps200000
--trial-num-envs NParallel envs (pinned; drives budget conversion)1024
--seed-base NBase; task k uses seed-base + k42
--gpus 0,1GPU ids, round-robinenv / GPU 0
--objective {ep_return_mean,success_rate}Measured floor/ref fieldep_return_mean
--trial-timeout SKill a floor/ref run after this many seconds—
--forceOverwrite baseline entriesFalse
--dry-runCompute without writing baselines.yamlFalse
--logdir/--logs PATHStudy artifact rootlogs/tune

Baselines record measured scores and the source config’s git blob SHA. run and check warn on config changes.

Registered search spaces

Registered state-observation spaces (runtime support still depends on capability preflight):

FrameworkLabels
skrlskrl_ppo; skrl_sac; skrl_ppo_rnn
stable-baselines3sb3_ppo, sb3_sac, sb3_tqc, sb3_td3, sb3_crossq
sbx (JAX SB3)sbx_ppo, sbx_sac, sbx_tqc, sbx_td3, sbx_crossq
rsl_rlrsl_rl_ppo
DreamerV3dreamer
TD-MPC2tdmpc2

Unknown --algo values list available spaces and exit; registered but unavailable labels fail preflight. Visual spaces are not yet registered.

DreamerV3 / TD-MPC2 caveats

Both integrations tune only global (L0) configs and ignore per-task blocks in dreamerv3.yaml / tdmpc2.yaml; a task-scoped export at hyperparams/task/<task>/dreamerv3.yaml or tdmpc2.yaml is not read yet. Plain-YAML frameworks support L1. --trial-steps sets native total-env-step budgets (run.steps for Dreamer, steps for TD-MPC2); export restores production values and --pin on these driver-owned keys errors. With num_envs > 1, framework and reporter step counts can differ by a constant factor; calibrate against a short reference run before estimating wall time.

Dreamer tunes run.train_ratio and model_size (RSSM/depth/units). TD-MPC2 tunes optimizer, MPPI planner, and loss coefficients; model_size sets architecture dimensions at load.

Portfolio (Multi-Task) Studies

--tasks A B C … trains one shared parameter set sequentially across tasks in fixed order, one srb agent train child per task in trials/NNN/seg-<task>/. Task scores normalize and aggregate into one objective; divergence prunes the trial, and intermediate aggregates let MedianPruner stop weak trials between tasks.

Raw returns (--normalize none, default) suit only tasks with shared scales; the driver warns otherwise. baseline normalizes (score − floor) / (ref − floor) from hyperparams/tune/baselines.yaml (missing fails fast; stale config SHA warns). rank uses per-task fractional ranks across completed trials; it needs no baseline but is non-stationary early. --aggregate median (default) resists one outlier; min makes the weakest task decisive; mean averages. Portfolio export defaults to global L0.

# 1. Capture floor/ref baselines for the task set.
srb agent tune baseline --tasks sample_collection peg_in_hole landing \
  --algo skrl_ppo --budget 10_000_000

# 2. Run the portfolio study, normalized against those baselines.
srb agent tune run --tasks sample_collection peg_in_hole landing --algo skrl_ppo \
  --trial-steps 10_000_000 --n-trials 30 --normalize baseline --aggregate median

# 3. Export the winner to the global per-algorithm config.
srb agent tune export --study srb-skrl_ppo-state-multi-<hash8>-v1   # --to global by default

Examples

Single-task smoke-budget study, two workers on two GPUs:

srb agent tune run --env sample_collection --algo skrl_ppo \
  --trial-steps 20_000_000 --n-trials 40 --n-workers 2 --gpus 0,1

Inspect and export the best trial to the task-specific slot:

srb agent tune status --study srb-skrl_ppo-state-sample_collection-v1
srb agent tune export --study srb-skrl_ppo-state-sample_collection-v1 --to task --dry-run
srb agent tune export --study srb-skrl_ppo-state-sample_collection-v1 --to task

Pin a value outside the search and fix a task-side override:

srb agent tune run --env peg_in_hole --algo skrl_ppo --trial-steps 10_000_000 \
  --pin agent.agent.grad_norm_clip=1.0 env.robot=franka

Output

Study artifacts live under logs/tune/<study-name>/:

logs/tune/srb-skrl_ppo-state-sample_collection-v1/
  journal.log        # Optuna JournalStorage (NFS-safe; shared by workers)
  study.yaml         # frozen manifest (search space, pins, resolved config, budgets)
  trials/000/        # trial_cfg.yaml, metrics.jsonl, logs/

Exports write hyperparams/<framework>/<algo>.yaml (global) or hyperparams/task/<task>/<framework>/<algo>.yaml (task) with provenance; adopt through git review.

See Also

Hyperparameter Tuning Workflow · srb agent train · Agent Configuration