Skip to content
LaunchHelm
Documentation — Hugging Face and Lightning

Hugging Face and Lightning

Both integrations are single callbacks that wire the launchhelm.torch surface (metrics, controls, checkpoints) into the framework's own training loop.

Hugging Face Trainer

pip install "launchhelm[hf]" (pulls transformers and accelerate).

args = TrainingArguments(
    output_dir="/tmp/lh-hf-example",
    num_train_epochs=1,
    per_device_train_batch_size=4,
    logging_steps=1,
    save_strategy="no",
    report_to=[],  # LaunchHelm is the only logger
    disable_tqdm=True,
    run_name="hf-example",
)
trainer = Trainer(
    model=Tiny(),
    args=args,
    train_dataset=Rows(),
    callbacks=[LaunchHelmCallback("quickstart")],
)
trainer.train()

python-hf_trainer.py · verbatim from sdks/python/examples/hf_trainer.py

The callback: opens the run at train start (project falls back to run_name; the full TrainingArguments dict is stored as run config), logs on every logging_steps boundary, applies dashboard commands at on_step_end — which is the collective control point, safe under DDP — uploads each checkpoint save as an artifact, and finishes the run at train end. LaunchHelmCallback(project, controls=...) narrows which built-in controls register (default: lr, weight_decay, grad_clip, dropout, checkpoint). rollback is not offered here: these trainers keep their own step and data position, which a restore in place would leave behind; resume from a checkpoint instead.

PyTorch Lightning

pip install "launchhelm[lightning]".

trainer = Trainer(
    max_epochs=1,
    callbacks=[LaunchHelmCallback("quickstart", name="lightning-example")],
    enable_progress_bar=False,
    enable_model_summary=False,
    logger=False,
    default_root_dir="/tmp/lh-lightning-example",
)
trainer.fit(Module(), train_dataloaders=DataLoader(Rows(), batch_size=4))

python-lightning_trainer.py · verbatim from sdks/python/examples/lightning_trainer.py

The same protocol applies after each optimizer step (on_train_batch_end), on every rank. self.log calls flow through to LaunchHelm streams.

When to use these vs lht directly

The callbacks are the right default when the framework owns the loop. Use lht.init/tr.step directly when you control the loop and want explicit safe points, tunables, or log_reduced aggregates — see pytorch and distributed.