Skip to content
L

LOOPZ

Never lose loop progress again.

Created on 4th May 2026

•

L

LOOPZ

Never lose loop progress again.

The problem LOOPZ solves

Every ML engineer, data scientist, and CS student has felt this exact moment. You are 6 hours into a training run. Loss is dropping. Accuracy is climbing. Then your Colab session disconnects, your laptop dies, or your server restarts — and you are back at epoch 1. Again.
This is not a rare edge case. This is the daily reality of anyone training models on free-tier cloud GPUs, shared university servers, or underpowered personal machines. Millions of GPU-hours are wasted every year re-doing work that was already done — not because the model was wrong, but because the infrastructure failed and there was no safety net.
loopz is that safety net.
It is a Python library that adds automatic crash recovery to any loop with a single decorator. You do not rewrite your training logic. You do not add boilerplate. You add @loopz.track(...) above your function and from that point every checkpoint is saved atomically. Crash at step 60,000 out of 100,000 — run the same script again and it resumes from exactly step 60,000.
For ML training, loopz saves and restores the complete training state: model weights, optimizer, learning rate scheduler, random seeds for deterministic resume, and any custom loop variables like running loss or best accuracy. The crash never happened as far as your training loop is concerned.
This project has no flashy frontend — and that is intentional. The interface for a developer tool is the terminal, the decorator, and the status output. The real deliverable is a working, published library that solves a problem every developer in this community has personally felt. It is live on PyPI right now — pip install loopz — built by a solo developer from India who lost one too many hours of Colab training.

Who it helps:

  • ML students running experiments on Colab that disconnects
  • Data engineers processing large datasets that can crash midway
  • Researchers training models overnight on laptops that might die
  • Anyone running any long Python loop that cannot afford to restart

What makes loopz different:
Unlike manual checkpointing which requires writing complex save/load logic inside your loop, loopz requires zero changes inside your loop body. It automatically saves your loop position, model weights, optimizer state, LR scheduler, GradScaler, random seed state, and custom accumulators — and restores all of them on the next run deterministically.

pip install loopz — that is the entire setup.

Challenges I ran into

Atomic writes without corruption. The scariest failure mode was not a crash — it was a crash during a checkpoint write. If loopz is saving your model at epoch 30 and the system dies mid-write, you get a corrupt file. Next time you resume, you load broken weights and get silently wrong results — which is worse than starting over. The fix was atomic writes: loopz writes to a temporary file first, then renames it. A file rename is atomic on every major OS, so the checkpoint is either fully written or completely untouched. Never half-broken.
Restoring random state for deterministic resume. Saving model weights and optimizer state is the obvious part. The non-obvious part is random seeds. If Python, NumPy, and PyTorch random states are not restored exactly, the resumed training takes a different random path than it would have without the crash — meaning your results are no longer reproducible. loopz captures and restores the full random state across all three so the resumed run is identical to an uninterrupted one.
Primitive loop variables cannot be tracked by reference. If a user writes loss = 0.0 and updates it as loss += value, loopz cannot track that mutation — Python creates a new float object on every assignment. This was a real API design problem. The solution was a documented pattern: wrap primitives in a list (loss = [0.0]), which is mutable and trackable. Simple fix, but it took real thought to arrive at a solution that did not make the API ugly or confusing.
Supporting PyTorch DDP and DataParallel. These wrappers store the actual model under a .module attribute instead of directly. loopz had to detect these wrappers, unwrap the underlying module to save the state dict correctly, and restore it cleanly — without the user needing to know or do anything differently.

Discussion

Builders also viewed

See more projects on Devfolio