speechbrain.utils.run_opts moduleο
Contains the defaults and parsing code for run-time controls
- Authors
Nouran Ali 2025
Peter Plantinga 2025
Summaryο
Classes:
Holds configuration options and runtime controls for SpeechBrain experiments. |
Referenceο
- class speechbrain.utils.run_opts.RunOptions(test_only: bool = False, debug: bool = False, debug_batches: int = 2, debug_epochs: int = 2, debug_persistently: bool = False, device: str | None = None, data_parallel_backend: bool = False, data_parallel_count: int = -1, distributed_backend: ~typing.Literal['nccl', 'gloo', 'mpi'] = 'nccl', distributed_launch: bool = False, find_unused_parameters: bool = False, jit: bool = False, jit_module_keys: list[str] | None = None, compile: bool = False, compile_module_keys: list[str] | None = None, compile_mode: ~typing.Literal['default', 'reduce-overhead', 'max-autotune'] = 'default', compile_using_fullgraph: bool = False, compile_using_dynamic_shape_tracing: bool = False, precision: ~typing.Literal['fp32', 'fp16', 'bf16'] = 'fp32', eval_precision: ~typing.Literal['fp32', 'fp16', 'bf16'] = 'fp32', auto_mix_prec: bool = False, bfloat16_mix_prec: bool = False, max_grad_norm: float = 5.0, skip_nonfinite_grads: bool = False, nonfinite_patience: int = 3, noprogressbar: bool = False, ckpt_interval_minutes: int = 0, ckpt_interval_steps: int = 0, grad_accumulation_factor: int = 1, optimizer_step_limit: int | None = None, tqdm_colored_bar: bool = False, tqdm_barcolor: ~typing.Dict[str, str] = <factory>, remove_vector_weight_decay: bool = False, profile_training: bool = False, profile_warmup: int = 5, profile_steps: int = 5, log_config: str | None = None, param_file: str = '', overridden_args: set = <factory>)[source]ο
Bases:
objectHolds configuration options and runtime controls for SpeechBrain experiments.
This dataclass encapsulates all tunable parameters and flags that affect the behavior of a SpeechBrain experiment, including device selection, debugging, distributed training, mixed-precision settings, checkpointing, profiling, and more. It provides default values for each option and can be constructed directly or via command-line argument parsing.
- deviceο
The device on which to run (e.g., βcpuβ, βcuda:0β). Default of None may be handled with
speechbrain.utils.distributed.infer_device()- Type:
- distributed_backendο
Backend for distributed training.
- Type:
Literal[βncclβ, βglooβ, βmpiβ]
- compile_modeο
Compilation mode.
- Type:
Literal[βdefaultβ, βreduce-overheadβ, βmax-autotuneβ]
- precisionο
Training precision.
- Type:
Literal[βfp32β, βfp16β, βbf16β]
- eval_precisionο
Inference precision.
- Type:
Literal[βfp32β, βfp16β, βbf16β]
- as_dict() Dict[source]ο
Converts the instance into a dictionary.
- Returns:
Dict: A dictionary representation of the instance.
- classmethod from_command_line_args(arg_list=None)[source]ο
Parse command-line arguments to the experiment.
- Parameters:
arg_list (list, None) β A list of arguments to parse. If not given, this is read from
sys.argv[1:]- Returns:
param_file (str) β The location of the parameters file.
run_opts (dict) β Run options, such as distributed, device, etc.
overrides (dict) β The overrides to pass to
load_hyperpyyaml.
Example
>>> argv = ["hyperparams.yaml", "--device", "cuda:1", "--seed", "10"] >>> filename, run_opts, overrides = RunOptions.from_command_line_args( ... argv ... ) >>> filename 'hyperparams.yaml' >>> run_opts["device"] 'cuda:1' >>> overrides 'seed: 10'