blog
We killed the same training run 40 times
27 November 2026 · Jonathan Vecchione
A training run on rented GPUs dies more often than anyone plans for: a spot reclaim, a host that vanishes, an out-of-memory crash in the middle of a save. What happens next is usually a restart “from a good place”: reload the weights, maybe the optimizer, and carry on. The run continues and the loss curve looks fine. But the learning-rate schedule, the random state and the order of the data have quietly started somewhere else, and it is no longer the run you started.
We wanted to see how big that difference is, and to show that it can be zero. So we took one small training run and killed it 40 times.
The experiment
A character-level GPT (two transformer blocks, width 64) learns a small text for 2,000 steps with AdamW, a warm-up and a cosine schedule. We ran it three ways:
- Never stopped, as the reference.
- With Ravex: one decorator on the training function, a checkpoint every 50 steps, killed 40 times at random steps and started again with the same command each time.
- With a hand-written resume: every 50 steps it saves the model, the optimizer and the step number with
torch.save, and on a restart it loads them. It does not save the LR scheduler or the random state, which is the usual omission. Killed at the same 40 steps.
The kills alternate between SIGKILL, where the process is gone with no warning, like a host that disappears, and SIGTERM, where it gets a moment to react, like a spot reclaim. On SIGTERM Ravex finishes the current step, writes a checkpoint and exits; on SIGKILL nothing runs, and the steps since the last checkpoint are trained again.
# What most training scripts do on a restart
state = torch.load("last.pt")
model.load_state_dict(state["model"])
optimizer.load_state_dict(state["optimizer"])
step = state["step"]
# ...and the LR scheduler, the RNG and the data order start over.@ravex.train_loop(max_steps=2000, checkpoint_every=50)
def train():
data, model, optimizer, scheduler = build(2000)
while ravex.step() < 2000:
train_step(data, model, optimizer, scheduler)The result
| Run | Restarts | Steps with the reference's exact loss | Largest difference | Steps trained twice | Final weights |
|---|---|---|---|---|---|
| Ravex | 40 | 2000 / 2000 | 0 | 370 | identical, bit for bit |
| Hand-written resume | 40 | 50 / 2000 | 0.503 | 1073 | different |
With Ravex every one of the 2,000 losses is the same number as in the run that was never stopped, and the final weights hash to the same value. The 370 steps trained twice are the ones a SIGKILL threw away; they were trained again and came out the same, because the random state and the data position came back too.
The hand-written resume matches only up to step 50. The first kill came at step 92, a SIGKILL; the restart loaded the checkpoint of step 50 and trained on from there, with the scheduler back at the start of its warm-up and other batches. The gap is plain during the first 250 steps, where the loss is still falling. After that the curves look the same to the eye, and this is why the problem goes unnoticed: nothing crashes and nothing warns, the run just is not the one you configured.
What a resume has to put back
Weights and optimizer are the obvious part. A run that continues exactly also needs the LR scheduler, the AMP loss scale if there is one, the random generators of Python, NumPy, torch and CUDA, and the position in the data: which epoch, how many batches of it were already seen, in what order. Ravex finds the model, optimizer, scheduler, scaler and data loader as the training function builds them, and saves and restores all of it. State that is not a torch object, such as an EMA kept in a dict or an early-stopping counter, is declared with one line, ravex.track(state=...).
What this does not show
- It is one process on a CPU, with a small model. It says nothing about speed on a GPU or about several GPUs.
- Exact equality on a GPU also needs the training itself to be deterministic: some CUDA kernels add in a different order from one run to the next, and then even two runs that never stop differ. Ravex restores the state either way; it cannot make a non-deterministic kernel repeat itself.
- Under the Hugging Face Trainer and Lightning the state comes back exactly too, but with shuffling or dropout on the resumed run draws different random numbers, since the framework drives the data loader and the RNG.
Several processes are covered by Ravex's own tests, which hold DDP and FSDP to the same bit-for-bit standard. A run of the same kind on GPUs is next, and will be written up here.
Run it yourself
On Linux or macOS (on Windows the two signals are the same hard stop), with Python 3.11 or later. It takes a few minutes on a laptop and needs no GPU.
pip install "ravex[moonclip]" matplotlib
curl -O https://gpuzero.dev/blog/40-kills/kill_resume.py
python kill_resume.py --kills 40 --steps 2000 --every 50 --out resultsThe script is kill_resume.py. It prints the table above and writes the losses as CSV and a chart. Our run used Ravex 0.21.0, Moonclip 0.4.3 and torch 2.15.0 on CPU, in a Linux container with one thread per process. If you get a different number, we would like to know: open an issue.
Ravex and Moonclip are open source under Apache-2.0. We build them, and GPU Zero on top of them.