Training Configs¶
- pydantic model SkiNet.ML.configs.train_configs.train_config.TrainConfig[source]¶
Bases:
BaseModelConfiguration for training.
- Fields:
checkpoint_config (SkiNet.ML.configs.train_configs.train_config.CheckpointConfig)cosine_annealing_config (SkiNet.ML.configs.train_configs.train_config.CosineAnnealingConfig)early_stopping_config (SkiNet.ML.configs.train_configs.train_config.EarlyStoppingConfig)litlogger_config (SkiNet.ML.configs.train_configs.train_config.LitLoggerConfig)lr_scheduler_config (SkiNet.ML.configs.train_configs.train_config.ReduceOnPlateauConfig)mlflow_config (SkiNet.ML.configs.train_configs.train_config.MLflowConfig)precision (Literal['16-mixed', 'bf16-mixed', '32-true', '16-true', 'bf16-true'] | None)scheduler_type (Literal['reduce_on_plateau', 'cosine_annealing'])
- field checkpoint_config: CheckpointConfig [Optional]¶
Model-checkpoint callback config. Its ‘monitor’ is propagated from SWEEP_CONFIG.
- field cosine_annealing_config: CosineAnnealingConfig [Optional]¶
CosineAnnealingLR config; used when scheduler_type=’cosine_annealing’.
- field early_stopping_config: EarlyStoppingConfig [Optional]¶
Early-stopping callback config. Its ‘monitor’ is propagated from SWEEP_CONFIG.
- field experiment_name: str = 'unet2d_experiment'¶
MLflow experiment name and run-name prefix. Drives run naming (run = ‘{experiment_name}_seed{seed}_{YYYYMMDD-HHMMSS}’); checkpoints are written under ‘{log_dir}/checkpoints/{run_name}’.
- field litlogger_config: LitLoggerConfig [Optional]¶
Lightning Studio LitLogger config.
- field loss_name: LossFunctionKey = LossFunctionKey.BCE_DICE¶
Loss function name. Supported: ‘bce’, ‘dice’, ‘bce_dice’.
- field lr_scheduler_config: ReduceOnPlateauConfig [Optional]¶
ReduceLROnPlateau config; used when scheduler_type=’reduce_on_plateau’. Its ‘monitor’ is propagated from SWEEP_CONFIG.
- field mlflow_config: MLflowConfig [Optional]¶
MLflow logger config.
- field num_workers: int | None = None¶
DataLoader worker processes. When None, auto-set to os.cpu_count() (single GPU) or cpu_count // devices under DDP.
- Constraints:
ge = 0
- field optimal_threshold: float | None = None¶
Fixed sigmoid threshold to use instead of sweeping. When None (default), the threshold is found via grid search each validation epoch.
- Constraints:
ge = 0.0
le = 1.0
- field pin_memory: bool | None = None¶
Pin host memory for faster H2D copies. When None, auto-set True on CUDA/GPU and False on MPS/CPU.
- field precision: Literal['16-mixed', 'bf16-mixed', '32-true', '16-true', 'bf16-true'] | None = None¶
Training precision. When None, auto-set to ‘16-mixed’ on GPU/MPS and ‘32-true’ on CPU.
- field prefetch_factor: int | None = None¶
Batches pre-loaded per worker. Ignored (forced None) when num_workers=0.
- Constraints:
ge = 1
- field scheduler_type: Literal['reduce_on_plateau', 'cosine_annealing'] = 'reduce_on_plateau'¶
Which scheduler sub-config is used: ‘reduce_on_plateau’ → lr_scheduler_config, ‘cosine_annealing’ → cosine_annealing_config.
- field system_metrics_interval_sec: float = 5.0¶
System-metrics logging interval in seconds.
- Constraints:
gt = 0
- field test_on_val_split: bool = False¶
Use the validation split as the test set. Metrics may be optimistic; leave False unless you have no held-out test set.
- field torch_compile_backend: str = 'inductor'¶
torch.compile backend. Use ‘eager’ to avoid an nvcc dependency.
- field use_mlflow_logger: bool = False¶
Enable MLflow logging. Requires mlflow_config.tracking_uri to be set.
- validator set_num_workers_auto » all fields[source]¶
Auto-detect num_workers from os.cpu_count(), DDP-aware: when devices is an int > 1 (one process per device), divide the CPU budget among them to avoid oversubscription.
- validator set_pin_memory_from_accelerator » all fields[source]¶
Auto-set pin_memory: True iff effective accelerator is CUDA/GPU. pin_memory is a no-op (or unsupported) for MPS/CPU.
- pydantic model SkiNet.ML.configs.train_configs.train_config.ReduceOnPlateauConfig[source]¶
Bases:
BaseModelLearning rate ReduceOnPlateau scheduler configuration for PyTorch Lightning.
- Fields:
- field monitor: MetricsKey = MetricsKey.VAL_MEAN_DICE_PER_IMAGE¶
Metric to watch; propagated from SWEEP_CONFIG — do not set in YAML.
- pydantic model SkiNet.ML.configs.train_configs.train_config.CosineAnnealingConfig[source]¶
Bases:
BaseModelCosineAnnealingLR scheduler configuration. T_max is set to max_epochs at runtime when None.
- Fields:
- pydantic model SkiNet.ML.configs.train_configs.train_config.CheckpointConfig[source]¶
Bases:
BaseModelConfiguration for model checkpointing.
- Fields:
- field monitor: MetricsKey = MetricsKey.VAL_MEAN_DICE_PER_IMAGE¶
Metric to watch; propagated from SWEEP_CONFIG — do not set in YAML.
- pydantic model SkiNet.ML.configs.train_configs.train_config.EarlyStoppingConfig[source]¶
Bases:
BaseModelConfiguration for early stopping.
- Fields:
- field divergence_threshold: float | None = None¶
Stop immediately if the metric falls below this value.
- field monitor: MetricsKey = MetricsKey.VAL_MEAN_DICE_PER_IMAGE¶
Metric to watch; propagated from SWEEP_CONFIG — do not set in YAML.
- pydantic model SkiNet.ML.configs.train_configs.train_config.MLflowConfig[source]¶
Bases:
BaseModelConfiguration for MLflow logging.
- Fields:
- field fallback_to_local_mlflow: bool = False¶
Fall back to local MLflow when the remote server is unreachable.
- field tracking_uri: str | None = None¶
MLflow tracking server URI, e.g. ‘http://127.0.0.1:5000’.
- pydantic model SkiNet.ML.configs.train_configs.sweep_config.SweepConfig[source]¶
Bases:
BaseModelConfiguration for the optuna HPO sweep.
monitoranddirectionare the single source of truth for the optimisation objective.ExperimentConfigpropagatesmonitorintotrainconfig.early_stopping_config,trainconfig.checkpoint_config, andtrainconfig.lr_scheduler_configso all four fields are always in sync without manual YAML duplication.- Fields:
- field direction: str = 'maximize'¶
Optuna optimisation direction: ‘maximize’ or ‘minimize’.
- Constraints:
pattern = ^(maximize|minimize)$
- field monitor: MetricsKey = MetricsKey.VAL_MEAN_DICE_PER_IMAGE¶
Metric to optimise; the single source of truth, propagated into the early-stopping, checkpoint, and LR-scheduler configs.
- field num_workers: list[int] [Optional]¶
DataLoader worker-count candidates (GridSampler dimension).