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.

原文来源:dev.to