Pipelines

These are the two main pipeline classes exposed at the top-level minerva_opt namespace.

RayHyperParameterSearch

class RayHyperParameterSearch(*args, **kwargs)[source]

Bases: Pipeline

Hyperparameter search pipeline using Ray Tune and PyTorch Lightning.

Supports any Ray Tune search algorithm via the search_alg parameter in _search. When no algorithm is provided, Ray’s default random/grid search is used. To use Bayesian optimisation, pass a HyperOptSearch instance.

Variables:
  • model (type) – Lightning model class to instantiate for each trial.

  • search_space (dict) – Ray Tune search-space definition passed as param_space.

__init__(model, search_space, log_dir=None, save_run_status=True, seed=None)[source]
Parameters:
  • model (type) – Lightning LightningModule subclass. Each trial instantiates it with model(**config) where config is sampled from search_space.

  • search_space (dict) – Mapping of hyperparameter names to Ray Tune search distributions (e.g. tune.loguniform, tune.choice).

  • log_dir (path-like, optional) – Directory for Ray storage and run artefacts. Passed to the base Pipeline.

  • save_run_status (bool, optional) – Whether to persist pipeline run status. Defaults to True.

  • seed (int, optional) – Global random seed forwarded to the base Pipeline.

AblationStudyPipeline

class AblationStudyPipeline(*args, **kwargs)[source]

Bases: Pipeline

Ablation study pipeline using Ray Tune and PyTorch Lightning.

Runs every named condition (plus the baseline) across multiple seeds so each component’s contribution can be measured by comparing against the full-model baseline. All conditions are exhaustive — no early stopping by default and no sampling; every condition × seed pair always trains to max_epochs.

Variables:
  • model (type) – Lightning model class to instantiate for each trial.

  • baseline_config (dict) – Full hyperparameter configuration for the baseline (all-on) condition.

  • ablations (dict) – Mapping of condition name → override dict applied on top of baseline_config.

__init__(model, baseline_config, ablations, log_dir=None, save_run_status=True, seed=None)[source]
Parameters:
  • model (type) – Lightning LightningModule subclass instantiated as model(**config) for each trial.

  • baseline_config (dict) – Complete hyperparameter dict for the full (baseline) model.

  • ablations (dict) –

    Mapping of condition name → partial config override. Each entry’s values are merged on top of baseline_config to form the condition’s full config. The key "baseline" is reserved and will raise ValueError if present.

    A single override value may be a list to sweep multiple values for that parameter. The condition is then expanded into one named condition per value, using the pattern "{name}_{value}". For example:

    {"dropout": {"dropout": [0.2, 0.5, 0.8]}}
    

    produces conditions dropout_0.2, dropout_0.5, and dropout_0.8. Only one key per condition entry may be a list; passing multiple list-valued keys raises ValueError.

  • log_dir (path-like or None, optional) – Directory for Ray storage and run artefacts. Passed to the base Pipeline.

  • save_run_status (bool, optional) – Whether to persist pipeline run status. Defaults to True.

  • seed (int, optional) – Base seed added to the per-trial seed offset so results are reproducible.

Raises:

ValueError – If "baseline" appears as a key in ablations.