POSSMMultitaskPretrain#
- class pretrain.models.POSSMMultitaskPretrain(cfg, rank, world_size)[source]#
Bases:
core.trainer.BaseTrainerMulti-task pretrainer for POSSM.
Trains a single POSSM model on multiple decoding tasks simultaneously, using its
MultitaskReadout. Per-task targets are gathered by the model’sinput_fn(no per-sample dataset target extraction). Supports per-task eval metrics, configurable best-model selection (loss or metric), held-out test, and full ckpt resume.- setup(ckpt)[source]#
Set up the trainer.
This method is called after setting up distributed, loading the checkpoint, and setting up logging.
- compute_multitask_loss(pred_dict, batch)[source]#
Aggregate per-task losses into a single training scalar.
Returns the unweighted
task_lossesfor logging / metrics, plus a weighted sumsum_t (task_weights[t] * task_losses[t])as the backward signal. Weighted-sum (not weighted-mean) is intentional: scaling a task’s weight up directly increases its gradient contribution, matching how POSSM’s recommended task_weights are usually written down.
- val_epoch()[source]#
Perform a validation epoch.
Called every val.every_n_epochs epochs, and at the end of training.
- Returns:
bool, True if early stopping should be triggered, False (or falsey) otherwise.
- Return type:
early_stop