cd /news/machine-learning/i-kept-copy-pasting-the-same-checkpo… · home › topics › machine-learning › article
[ARTICLE · art-182756] src=dev.to ↗ pub= topic=machine-learning verified=true sentiment=↑ positive

I kept copy-pasting the same checkpoint/resume code into every Hugging Face Trainer script. So we fixed it.

The Efficio project released version 0.3.0, adding Hugging Face Trainer and PyTorch Lightning callbacks that bring time-budgeted checkpointing and cross-platform resume to framework-managed training loops. The callbacks let users set a time budget and remote storage target, then resume from the saved checkpoint, addressing session limits on Colab and Kaggle free-tier GPUs. The adapters are single-process only and raise an error under torchrun or DDP, with multi-GPU support and automatic OOM recovery planned.

key takeaway

Efficio 0.3.0's HFTrainerCallback and Lightning callback add time-budgeted checkpointing and resume to Trainer loops, but only in single-process runs—torchrun or DDP raises instead of silently misbehaving.

by read1 min views2 publishedDec 6, 2026

If you've trained anything with transformers.Trainer on Colab or Kaggle, you know the drill: your session has a time limit, there's no guarantee you'll finish, and the second it dies you're stuck re-reading your own trainer_state.json trying to figure out where you actually left off — assuming you remembered to save one at all. We'd already solved this for plain PyTorch training loops in Efficio (time-budgeted checkpointing, smaller checkpoint modes, resume across Colab ↔ Kaggle). But the moment someone used Trainer.train() or Lightning's Trainer.fit() instead of a raw loop, none of that applied — those frameworks manage their own checkpointing, so bolting Efficio on meant reimplementing budget tracking and resume logic by hand.

0.3.0 fixes that with two callbacks:

``` python

from efficio.adapters import HFTrainerCallback

efficio_cb = HFTrainerCallback(budget="2h", storage="hf://you/your-repo")

args = TrainingArguments(output_dir="out", fp16=True, save_strategy="no")

trainer = Trainer(model=model, args=args, train_dataset=ds, callbacks=[efficio_cb])

trainer.train(resume_from_checkpoint=efficio_cb.resume_from(trainer))

efficio_cb.report()

```

Same idea for Lightning, as a Callback + a checkpoint_io plugin.

checkpoint_io plugin. Single-process only for now. torchrun or strategy="ddp" raises rather than silently doing the wrong thing — multi-GPU support for the adapters is on the roadmap, right after we ship automatic OOM recovery with auto micro-batch sizing in the next release.

Tested on a real Colab T4: budget stop mid-epoch, then resume, with both frameworks.

``` bash

pip install "efficio[hf]"

pip install "efficio[lightning]"

```

Repo: github.com/HuNTer8272/Efficio

Would love feedback, especially from anyone running longer HF Trainer or Lightning jobs on free-tier GPUs.

── more in #machine-learning 4 stories · sorted by recency
── more on @efficio 3 stories trending now
sponsored brought to you by zahid.host 4,200+ EU-deployed projects
reading about agents? ship yours in a single git push.

Run your AI side-project on zahid.host

EU-based hosting, git-push deploys, automatic HTTPS, no cold starts. Free tier with a custom domain — perfect for shipping the agent you just read about.

$git push zahid main
→ Live at https://your-agent.zahid.host ✓
Get free account → Pricing
from €0/mo · no card required
LIVE [news/i-kept-copy-pasting-…] indexed:0 read:1min 2026-12-06 · —