Hyperparameter optimization extensions for Minerva.
Project description
Minerva-OPT
Hyperparameter optimization extensions for Minerva, powered by Ray Tune.
Description
Minerva-OPT provides a RayHyperParameterSearch pipeline that wraps Ray Tune and PyTorch Lightning to run distributed hyperparameter searches on top of any Minerva-compatible model. It supports random search, grid search, and Bayesian optimization (via HyperOpt), with early stopping through the ASHA scheduler.
Features
- Drop-in Minerva pipeline: inherits from
minerva.pipelines.base.Pipeline, so it integrates with Minerva's logging, reproducibility, and run-status tracking out of the box. - Flexible search algorithms: use Ray Tune's default random/grid search or pass any
ray.tune.search.Searcher(e.g.HyperOptSearchfor Bayesian optimization). - ASHA early stopping: trials are stopped early based on intermediate results;
grace_periodandmax_tare derived automatically frommax_epochs. - Distributed training: uses
RayDDPStrategyandRayLightningEnvironmentfor multi-worker trials. - Checkpointing: keeps only the best checkpoint per trial, scored on the target metric.
Installation
Requires Python 3.10+.
With uv (recommended)
uv pip install minerva-opt
With pip
pip install minerva-opt
Usage
Random / grid search
from ray import tune
from minerva_opt.pipelines.hyperparameter_search import RayHyperParameterSearch
search_space = {
"learning_rate": tune.loguniform(1e-4, 1e-1),
"hidden_size": tune.choice([64, 128, 256]),
}
pipeline = RayHyperParameterSearch(
model=MyLightningModel, # class, not instance — instantiated per trial as MyLightningModel(**config)
search_space=search_space,
log_dir="logs/",
)
results = pipeline.run(data=my_data_module, num_samples=20, max_epochs=50)
best = results.get_best_result()
print(best.config)
Bayesian optimization with HyperOpt
from ray.tune.search.hyperopt import HyperOptSearch
from hyperopt import hp
search_space = {
"learning_rate": tune.loguniform(1e-4, 1e-1),
"dropout": tune.uniform(0.1, 0.5),
}
pipeline = RayHyperParameterSearch(
model=MyLightningModel,
search_space=search_space,
)
results = pipeline.run(
data=my_data_module,
search_alg=HyperOptSearch(),
num_samples=30,
max_epochs=100,
tuner_metric="val_loss",
tuner_mode="min",
)
Key run() parameters
| Parameter | Default | Description |
|---|---|---|
data |
— | LightningDataModule to train on |
task |
"search" |
"search" to run the sweep |
ckpt_path |
None |
Resume training from a checkpoint |
num_samples |
10 |
Number of trials to run |
max_epochs |
100 |
Max epochs per trial |
tuner_metric |
"val_loss" |
Metric to optimize |
tuner_mode |
"min" |
"min" or "max" |
search_alg |
None |
Any ray.tune.search.Searcher; None = random search |
max_concurrent |
4 |
Max concurrent trials (when using a search_alg) |
scheduler |
ASHA | Override the trial scheduler |
scaling_config |
1 GPU/worker | Override Ray ScalingConfig |
checkpoint_interval |
1 |
Save a checkpoint every N epochs |
debug_mode |
False |
Disable checkpointing for fast iteration |
Requirements
minerva >= 0.3.10b0ray[tune] >= 2.55hyperopt >= 0.2.7
License
MIT License. See LICENSE for details.
Contact
For questions or bug reports, open an issue on the GitHub issue tracker.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file minerva_opt-1.0.0.tar.gz.
File metadata
- Download URL: minerva_opt-1.0.0.tar.gz
- Upload date:
- Size: 6.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a0b096dee3d62e659e7b5f80811f5b9a87fd12bc9fd67ce326f6b19dfd7ed146
|
|
| MD5 |
aab6a3da33d3e0be03dad956a6127b28
|
|
| BLAKE2b-256 |
7926f28de763bf1ba4deae7c69e20ba0864d6bcd5702931a1c11dae12fce0913
|
Provenance
The following attestation bundles were made for minerva_opt-1.0.0.tar.gz:
Publisher:
auto-release.yml on GabrielBG0/Minerva-OPT
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
minerva_opt-1.0.0.tar.gz -
Subject digest:
a0b096dee3d62e659e7b5f80811f5b9a87fd12bc9fd67ce326f6b19dfd7ed146 - Sigstore transparency entry: 1928093852
- Sigstore integration time:
-
Permalink:
GabrielBG0/Minerva-OPT@8aeaa79435dbc8a1989eb6d8fabe3b3fcaad8f97 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/GabrielBG0
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
auto-release.yml@8aeaa79435dbc8a1989eb6d8fabe3b3fcaad8f97 -
Trigger Event:
push
-
Statement type:
File details
Details for the file minerva_opt-1.0.0-py3-none-any.whl.
File metadata
- Download URL: minerva_opt-1.0.0-py3-none-any.whl
- Upload date:
- Size: 6.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
31dffef41586702cd4665830559b6a436ebe5a4df6fd60a06c005d90a1330ab9
|
|
| MD5 |
0d44d020606da68afee382ea3be7b88a
|
|
| BLAKE2b-256 |
fc5905d41491bd92fbe05569e15a84403a244abf28a0fc7fc9a9a01bf0136d92
|
Provenance
The following attestation bundles were made for minerva_opt-1.0.0-py3-none-any.whl:
Publisher:
auto-release.yml on GabrielBG0/Minerva-OPT
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
minerva_opt-1.0.0-py3-none-any.whl -
Subject digest:
31dffef41586702cd4665830559b6a436ebe5a4df6fd60a06c005d90a1330ab9 - Sigstore transparency entry: 1928094010
- Sigstore integration time:
-
Permalink:
GabrielBG0/Minerva-OPT@8aeaa79435dbc8a1989eb6d8fabe3b3fcaad8f97 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/GabrielBG0
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
auto-release.yml@8aeaa79435dbc8a1989eb6d8fabe3b3fcaad8f97 -
Trigger Event:
push
-
Statement type: