Skip to content

Add Callback API for Training Lifecycle EventsΒ #25

@kapil27

Description

@kapil27

Problem Statement:

Training Hub currently lacks a callback mechanism for extending training behavior at runtime. HuggingFace Transformers provides TrainerCallback that allows users to hook into training lifecycle events (epoch start/end, step end, evaluation, etc.). Training Hub should provide similar extensibility.

Without callbacks, users cannot inject custom logic during training without modifying Training Hub internals or relying on external file polling workarounds.

Desired API

A callback system similar to HuggingFace Transformers:

from training_hub.algorithms.sft import sft
from training_hub.callbacks import TrainingCallback

class MyCallback(TrainingCallback):
    def on_step_end(self, args, state, control, **kwargs):
        # Custom logic here
        pass

sft(..., callbacks=[MyCallback()])

Use Cases

  1. Progress tracking and monitoring
  2. Integration with experiment tracking platforms (MLflow, Weights & Biases)
  3. Custom training behaviors (early stopping, dynamic learning rates)
  4. Real-time updates to external systems

Reference

HuggingFace Transformers TrainerCallback: https://huggingface.co/docs/transformers/main_classes/callback

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions