Configuration

The frozen dataclasses produced by the TOML/env/CLI parser. For the meaning of each field, see Apeiron Configuration Reference.

apeiron.config.configuration.get_available_device(multi_gpu=False)[source]

Return a torch.device with sensible fallbacks.

  • CPU-only hosts: cpu.

  • CUDA hosts:

    • multi_gpu=True -> cuda (let the caller handle DDP/DataParallel).

    • multi_gpu=False -> choose the GPU with the most free memory, then restrict CUDA_VISIBLE_DEVICES so only that GPU is visible.

  • Apple Silicon with PyTorch MPS: mps if CUDA is unavailable.

Never raises if nvidia-smi is missing.

Parameters:

multi_gpu (bool)

Return type:

torch.device

class apeiron.config.configuration.ModelCfg[source]

Bases: object

ModelCfg(name: ‘str’, pretrained_path: ‘str’ = ‘’, max_ckpts: ‘int’ = 0, ckpts_path: ‘str’ = ‘’)

name: str
pretrained_path: str = ''
max_ckpts: int = 0
ckpts_path: str = ''
__init__(name, pretrained_path='', max_ckpts=0, ckpts_path='')
Parameters:
  • name (str)

  • pretrained_path (str)

  • max_ckpts (int)

  • ckpts_path (str)

Return type:

None

class apeiron.config.configuration.TrainCfg[source]

Bases: object

TrainCfg(batch_size: ‘int’, num_workers: ‘int’, init_lr: ‘float’, grad_accumulation_steps: ‘int’ = 1, max_iter: ‘int’ = 600)

batch_size: int
num_workers: int
init_lr: float
grad_accumulation_steps: int = 1
max_iter: int = 600
__init__(batch_size, num_workers, init_lr, grad_accumulation_steps=1, max_iter=600)
Parameters:
  • batch_size (int)

  • num_workers (int)

  • init_lr (float)

  • grad_accumulation_steps (int)

  • max_iter (int)

Return type:

None

class apeiron.config.configuration.DataCfg[source]

Bases: object

DataCfg(name: ‘str’, path: ‘str’, batch_size: ‘int’ = 1)

name: str
path: str
batch_size: int = 1
__init__(name, path, batch_size=1)
Parameters:
Return type:

None

class apeiron.config.configuration.ContinualLearningCfg[source]

Bases: object

ContinualLearningCfg(update_mode: ‘str’ = ‘base’, mix_historic_data: ‘bool’ = False, jvp_rho_theta: ‘float’ = 0.05, jvp_rho_x: ‘float’ = 1.0, jvp_data_sign: ‘float’ = 1.0, ewc_lambda: ‘float’ = 1000.0, ewc_ema_decay: ‘float’ = 0.95, kfac_lambda: ‘float’ = 0.01, kfac_ema_decay: ‘float’ = 0.95)

update_mode: str = 'base'
mix_historic_data: bool = False
jvp_rho_theta: float = 0.05
jvp_rho_x: float = 1.0
jvp_data_sign: float = 1.0
ewc_lambda: float = 1000.0
ewc_ema_decay: float = 0.95
kfac_lambda: float = 0.01
kfac_ema_decay: float = 0.95
__init__(update_mode='base', mix_historic_data=False, jvp_rho_theta=0.05, jvp_rho_x=1.0, jvp_data_sign=1.0, ewc_lambda=1000.0, ewc_ema_decay=0.95, kfac_lambda=0.01, kfac_ema_decay=0.95)
Parameters:
Return type:

None

class apeiron.config.configuration.DriftDetectionCfg[source]

Bases: object

DriftDetectionCfg(detector_name: ‘str’ = ‘ADWINDetector’, detection_interval: ‘int’ = 10, aggregation: ‘str’ = ‘mean’, metric_index: ‘int’ = 0, reset_after_learning: ‘bool’ = False, max_stream_updates: ‘int’ = 20, adwin_delta: ‘float’ = 0.002, adwin_minor_threshold: ‘float’ = 0.3, adwin_moderate_threshold: ‘float’ = 0.6, kswin_alpha: ‘float’ = 0.005, kswin_window_size: ‘int’ = 100, kswin_stat_size: ‘int’ = 30, kswin_seed: ‘int | None’ = None, ph_min_instances: ‘int’ = 30, ph_delta: ‘float’ = 0.005, ph_threshold: ‘float’ = 50, ph_alpha: ‘float’ = 0.9999, ensemble_detectors: ‘tuple[str, …]’ = (), ensemble_voting: ‘str’ = ‘majority’)

detector_name: str = 'ADWINDetector'
detection_interval: int = 10
aggregation: str = 'mean'
metric_index: int = 0
reset_after_learning: bool = False
max_stream_updates: int = 20
adwin_delta: float = 0.002
adwin_minor_threshold: float = 0.3
adwin_moderate_threshold: float = 0.6
kswin_alpha: float = 0.005
kswin_window_size: int = 100
kswin_stat_size: int = 30
kswin_seed: int | None = None
ph_min_instances: int = 30
ph_delta: float = 0.005
ph_threshold: float = 50
ph_alpha: float = 0.9999
ensemble_detectors: tuple[str, ...] = ()
ensemble_voting: str = 'majority'
__init__(detector_name='ADWINDetector', detection_interval=10, aggregation='mean', metric_index=0, reset_after_learning=False, max_stream_updates=20, adwin_delta=0.002, adwin_minor_threshold=0.3, adwin_moderate_threshold=0.6, kswin_alpha=0.005, kswin_window_size=100, kswin_stat_size=30, kswin_seed=None, ph_min_instances=30, ph_delta=0.005, ph_threshold=50, ph_alpha=0.9999, ensemble_detectors=(), ensemble_voting='majority')
Parameters:
  • detector_name (str)

  • detection_interval (int)

  • aggregation (str)

  • metric_index (int)

  • reset_after_learning (bool)

  • max_stream_updates (int)

  • adwin_delta (float)

  • adwin_minor_threshold (float)

  • adwin_moderate_threshold (float)

  • kswin_alpha (float)

  • kswin_window_size (int)

  • kswin_stat_size (int)

  • kswin_seed (int | None)

  • ph_min_instances (int)

  • ph_delta (float)

  • ph_threshold (float)

  • ph_alpha (float)

  • ensemble_detectors (tuple[str, ...])

  • ensemble_voting (str)

Return type:

None

class apeiron.config.configuration.LoggingCfg[source]

Bases: object

LoggingCfg(backend: ‘MetricsBackend’ = ‘none’, experiment_name: ‘str | None’ = None, mlflow_tracking_uri: ‘str | None’ = None, metrics_output_path: ‘str | None’ = None)

backend: MetricsBackend = 'none'
experiment_name: str | None = None
mlflow_tracking_uri: str | None = None
metrics_output_path: str | None = None
__init__(backend='none', experiment_name=None, mlflow_tracking_uri=None, metrics_output_path=None)
Parameters:
  • backend (MetricsBackend)

  • experiment_name (str | None)

  • mlflow_tracking_uri (str | None)

  • metrics_output_path (str | None)

Return type:

None

class apeiron.config.configuration.Config[source]

Bases: object

Config(model: ‘ModelCfg’, data: ‘DataCfg’, train: ‘TrainCfg’, continual_learning: ‘ContinualLearningCfg’, drift_detection: ‘DriftDetectionCfg’, seed: ‘int’, device: ‘str’, multi_gpu: ‘bool’ = False, verbosity: ‘str’ = ‘INFO’, logging: ‘LoggingCfg | None’ = None)

model: ModelCfg
data: DataCfg
train: TrainCfg
continual_learning: ContinualLearningCfg
drift_detection: DriftDetectionCfg
seed: int
device: str
multi_gpu: bool = False
verbosity: str = 'INFO'
logging: LoggingCfg | None = None
__init__(model, data, train, continual_learning, drift_detection, seed, device, multi_gpu=False, verbosity='INFO', logging=None)
Parameters:
Return type:

None

apeiron.config.configuration.parse_args(argv=None)[source]

Parse command line arguments.

Parameters:

argv (list[str] | None) – The command line arguments to parse. If None, use sys.argv.

Returns:

The parsed command line arguments.

Return type:

argparse.Namespace

apeiron.config.configuration.load_toml(p)[source]

Load TOML configuration from file.

Parameters:

p (Path) – The file path to load from.

Returns:

The loaded configuration.

Return type:

dict[str, Any]

apeiron.config.configuration.deep_update(x, y)[source]

Recursively update a nested dictionary with values from another mapping.

Parameters:
  • x (dict) – The dictionary to update.

  • y (Mapping) – The mapping containing the values to update with.

Returns:

The updated dictionary.

Return type:

dict

apeiron.config.configuration.kv_to_nested(items)[source]

Recursively build a nested dictionary from a list of key-value strings.

Parameters:

items (list[str]) – List of key-value strings in the format “key=value”.

Returns:

The built nested dictionary.

Return type:

dict[str, Any]

apeiron.config.configuration.env_overrides(prefix='APP_')[source]

Recursively build a nested dictionary from environment variables that start with the given prefix.

Parameters:

prefix (str, optional) – The prefix to filter environment variables with. Defaults to APP_.

Returns:

The built nested dictionary.

Return type:

dict[str, Any]

apeiron.config.configuration.build_config(argv=None)[source]

Load configuration from TOML file, environment variables, and command line arguments.

Parameters:

argv (list[str] | None) – The command line arguments to parse. If None, use sys.argv.

Returns:

The final configuration.

Return type:

Config