Skip to main content

Hydra Experiment Sweeper

hydra is a great library to configure model trainings and numerical experiments. Via its --multirun facility, you can launch multiple jobs at a time and evaluate multiple combinations of settings such as learning rates and seeds easily. However, the built-in sweepers only accept sweep ranges on the command line, which means that reproducing a set of experiments for a paper or similar relies on you to remember or write down the exact invocation of hydra that produced the results in the first place.

hydra-experiment-sweeper lets you configure experiments via YAML. This way colleagues and yourself a year from now can re-run the same jobs with exactly the same parameters.

defaults:
  - override hydra/sweeper: experiment

hydra:
  sweeper:
    overrides:
      learning_rate: 1e-5,1e-6,1e-7
      # Any other overrides such as seeds, model, dataset, etc.

Installation

pip install hydra-experiment-sweeper

How to Use

The sweeper accepts any override syntax that hydra accepts on the command line as well as YAML lists for long values such as seeds or paths.

defaults:
  - override hydra/sweeper: experiment

hydra:
  sweeper:
    max_batch_size: 2
    overrides:
      model: linreg,svm
      learning_rate: range(0.1, 0.3, 0.1)
      seed:
        - 123
        - 42

Running this experiment with python example/train.py --config-name experiment -m launches the configured jobs.

Experiment invocation and output
$ python example/train.py -m
[2021-10-15 17:57:18,241][HYDRA] ExperimentSweeper(max_batch_size=2, overrides={'model': 'linreg,svm', 'learning_rate': 'range(0.1, 0.3, 0.1)', 'seed': [123, 42]}) sweeping
[2021-10-15 17:57:18,242][HYDRA] Sweep output dir : multirun/2021-10-15/17-57-18
[2021-10-15 17:57:18,796][HYDRA] Launching 2 jobs locally
[2021-10-15 17:57:18,796][HYDRA] 	#0 : model=linreg learning_rate=0.1 seed=123
model:
  model_type: linear_regression
seed: 123
learning_rate: 0.1

[2021-10-15 17:57:18,888][HYDRA] 	#1 : model=linreg learning_rate=0.1 seed=42
model:
  model_type: linear_regression
seed: 42
learning_rate: 0.1

[2021-10-15 17:57:18,982][HYDRA] Launching 2 jobs locally
[2021-10-15 17:57:18,982][HYDRA] 	#2 : model=linreg learning_rate=0.2 seed=123
model:
  model_type: linear_regression
seed: 123
learning_rate: 0.2

[2021-10-15 17:57:19,079][HYDRA] 	#3 : model=linreg learning_rate=0.2 seed=42
model:
  model_type: linear_regression
seed: 42
learning_rate: 0.2

[2021-10-15 17:57:19,171][HYDRA] Launching 2 jobs locally
[2021-10-15 17:57:19,171][HYDRA] 	#4 : model=svm learning_rate=0.1 seed=123
model:
  model_type: support_vector_machine
seed: 123
learning_rate: 0.1

[2021-10-15 17:57:19,290][HYDRA] 	#5 : model=svm learning_rate=0.1 seed=42
model:
  model_type: support_vector_machine
seed: 42
learning_rate: 0.1

[2021-10-15 17:57:19,405][HYDRA] Launching 2 jobs locally
[2021-10-15 17:57:19,405][HYDRA] 	#6 : model=svm learning_rate=0.2 seed=123
model:
  model_type: support_vector_machine
seed: 123
learning_rate: 0.2

[2021-10-15 17:57:19,497][HYDRA] 	#7 : model=svm learning_rate=0.2 seed=42
model:
  model_type: support_vector_machine
seed: 42
learning_rate: 0.2

You can still override parameters on the command line. Let's say you want to run the same experiment but instead of sweeping over the configured learning rates, you want to try a different order of magnitude. python example/train.py --config-name experiment -m learning_rate=1e-6,5e-5,1e-5 works just as you would expect with the built-in sweeper and overwrites the configured override.

Metadata

Release files for hydra-experiment-sweeper 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for hydra-experiment-sweeper 0.1.0
File Size Uploaded Provenance Actions
hydra-experiment-sweeper-0.1.0.tar.gz 5.1 kB Without provenance Details for hydra-experiment-sweeper-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for hydra-experiment-sweeper 0.1.0
File Interpreter ABI Platform Actions
hydra_experiment_sweeper-0.1.0-py3-none-any.whl Python 3 none any Details for hydra_experiment_sweeper-0.1.0-py3-none-any.whl

Total release size: 10.6 kB

Release files / hydra-experiment-sweeper-0.1.0.tar.gz

Download URL hydra-experiment-sweeper-0.1.0.tar.gz
Size 5.1 kB
Tags Source
SHA-256 checksum
How to use checksums
0842a6756468f5015e0a95ca410c9edbaf9fea289d79c04d88c8b0b57ea58f34
BLAKE2b-256 checksum
How to use checksums
3f85d4b8f21015ce64ba8a5c9e73a17154dbe8b684315b183937e33ef9fd7266
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via python-requests/2.26.0

Release files / hydra_experiment_sweeper-0.1.0-py3-none-any.whl

Download URL hydra_experiment_sweeper-0.1.0-py3-none-any.whl
Size 5.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
df8a0c1edfe7bc0be1dd9f4be19c61e930cfcbb65aa30abceb0930ca34f59e84
BLAKE2b-256 checksum
How to use checksums
39451782eed6eb85ac22b32002ce0087a8f2ef21b6d33b9b806eb3c7f6a20e1c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via python-requests/2.26.0

Security for hydra-experiment-sweeper 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page