training_stage
training_stage
¶
Callback for epoch-based training-stage transitions.
TrainingStageCallback
¶
Bases: Callback
Apply ordered training stages on top of the cached base regime.
The callback assumes stage ordering, optimizer-group references, and
loss_weights paths were already validated in versatil.validation.
At runtime it only:
- caches the base optimizer / trainability / loss state once
- picks the stage active for
trainer.current_epoch - applies that stage as a delta over the cached base regime
- restores the base regime during gaps between stages
Loss overrides are routed purely through the generic
loss_module.weights / set_weights / update_weights API. The
callback does not know about concrete loss classes or composite internals.
When group_lrs is used together with a scheduler, staged learning rates
are interpreted as new scheduler base rates. The current scheduler factor
is preserved; the callback does not reset scheduler progress.
Initialize the training stage callback.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
stages
|
list[TrainingStage]
|
Ordered runtime stages from |
required |
learning_rate_schedule_active
|
bool
|
Whether the Lightning module configured a scheduler. Used to fail fast when staged learning rates cannot update scheduler base rates. |
False
|
Source code in src/versatil/training/callbacks/training_stage.py
on_train_start
¶
Cache the base regime and apply the stage active at resume epoch.
Source code in src/versatil/training/callbacks/training_stage.py
on_train_epoch_start
¶
Apply a newly active stage, or restore modes for the current stage.