Sweeps: Hyperparameter Optimization Engine
This repo contains the routines that generate hyperparameter sweep suggestions in the W&B backend and client local controller.
Issues are not enabled in this repository. Please open issues related to sweeps in the wandb client library github issues page.
Installation
To install:
pip install sweeps
Examples
Get next run in a sweep.
Requires two arguments, config, the config that defines the sweep, and runs, the other runs in the sweep
config:
{
"metric": {"name": "loss", "goal": "minimize"},
"method": "bayes",
"parameters": {
"v1": {"min": 1, "max": 10},
"v2": {"min": 1.0, "max": 10.0},
},
}
runs:
[
SweepRun(
name="b",
state=RunState.finished,
history=[
{"loss": 5.0},
],
config={"v1": {"value": 7}, "v2": {"value": 6}},
summary_metrics={"zloss": 1.2},
),
SweepRun(
name="b2",
state=RunState.finished,
config={"v1": {"value": 1}, "v2": {"value": 8}},
summary_metrics={"loss": 52.0},
history=[],
)
]
Codepath:
suggestion = next_run(config, runs)
next_run:
- validates that sweep config conforms to the jsonschema in
config/schema.json, if not, it raises aValidationError - parses the config file and determines the method that it should use to find the next run (in this case
bayes_search_next_run) - calls
bayes_search_next_run(config, runs)and returns the suggestedSweepRun
Return list of runs to stop in a sweep.
Requires two arguments, config, the config that defines the sweep, and runs, the other runs in the sweep
config:
{
"method": "grid",
"metric": {"name": "loss", "goal": "minimize"},
"early_terminate": {
"type": "hyperband",
"max_iter": 5,
"eta": 2,
"s": 2,
},
"parameters": {"a": {"values": [1, 2, 3]}},
}
runs:
[
SweepRun(
name="a",
state=RunState.finished, # This is already stopped
history=[
{"loss": 10},
{"loss": 9},
],
),
SweepRun(
name="b",
state=RunState.running, # This should be stopped
history=[
{"loss": 10},
{"loss": 10},
],
),
SweepRun(
name="c",
state=RunState.running, # This passes band 1 but not band 2
history=[
{"loss": 10},
{"loss": 8},
{"loss": 8},
],
),
SweepRun(
name="d",
state=RunState.running,
history=[
{"loss": 10},
{"loss": 7},
{"loss": 7},
],
),
SweepRun(
name="e",
state=RunState.finished,
history=[
{"loss": 10},
{"loss": 6},
{"loss": 6},
],
),
]
Codepath:
to_stop = stop_runs(config, runs)
stop_runs:
- validates that sweep config conforms to the jsonschema in
config/schema.json, if not, it raises aValidationError - parses the config file and determines the method that it should use to early terminate runs (in this case
hyperband_stop_runs) - calls
hyperband_stop_runs(config, runs)and returns theSweepRuns to stop
Testing
Tests are run using tox, the makefile defines convenience commands for short and long tests:
make test-short
make test-full
Contributing
Review the Contributing Instructions
Create and activate a uv-managed virtual environment:
uv python install 3.11
uv venv --python 3.11
source .venv/bin/activate
Install the package in editable mode with development and test dependencies:
uv pip install -r requirements.dev.txt -e .
Install the pre-commit hooks:
pre-commit install
Run formatting and tests:
make format
make test
Releasing
make
Metadata
Release files for sweeps 0.3.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| sweeps-0.3.0.tar.gz | 55.3 kB | With provenance | Details for sweeps-0.3.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| sweeps-0.3.0-py3-none-any.whl | Python 3 | none | any | Details for sweeps-0.3.0-py3-none-any.whl |
Total release size: 87.4 kB
Release files / sweeps-0.3.0.tar.gz
| Download URL | sweeps-0.3.0.tar.gz |
|---|---|
| Size | 55.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
f3912bb116e745aacc18b1e4be8e7cb560ee666e642b858a24f5e5d50f664e77
|
|
BLAKE2b-256 checksum How to use checksums |
447c4f5fe0ed0e732884e961fca4c9db0002bfb947c5db0815b015e3d437edf4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 4, 2026.
Transparency logRelease files / sweeps-0.3.0-py3-none-any.whl
| Download URL | sweeps-0.3.0-py3-none-any.whl |
|---|---|
| Size | 32.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
e35fbfa87215000238dd4ee8589fc0fed476e4f792cbe803f65071e52d53a692
|
|
BLAKE2b-256 checksum How to use checksums |
6ef33b2fdf5120bdfc403b4ac7acb33b9b6f6aeca591ffce6165d12d43ab58de
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 4, 2026.
Transparency logSecurity for sweeps 0.3.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.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for sweeps-0.3.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 4, 2026.
Transparency logA 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.