After an overnight fine-tuning run is interrupted, you reload the weights and see the loss continue to fall. That does not prove the run has picked up its original training trajectory. Resetting momentum or reading batches from the beginning can turn a seemingly successful resume into a new training run. When running MLX on a cloud Mac, validating your checkpoint protocol with a small experiment before using it for a long job is more effective than waiting until fine-tuning finishes to inspect the results.
Define what a resumed run must preserve
This test checks continuity of training state, not whether a weights file can be opened. Six uninterrupted updates should produce final parameters that match, within tolerance, those from three updates followed by saving, reloading, and another three updates.
At a minimum, a checkpoint must contain the model parameters, the optimizer's internal state, the number of completed updates, and the position of the next data batch. If you use a learning-rate schedule, random shuffling, or random augmentation, you also need to record the corresponding state and the data version. If the training configuration changes, explicitly treat it as a new phase rather than continuing to call it a resumption of the original run.
A weights snapshot that supports inference is not necessarily a checkpoint that supports continued training. The file existing, loading without errors, and producing a falling loss are three different levels of validation.
Fix the update boundary
Save only after a complete parameter update, and define step as the number of updates already completed. Saving partway through gradient accumulation also requires saving the accumulated gradients and the effective sample count. This experiment does not cover that case: all saves happen after accumulation is complete.
Build an experiment that needs no model download
Set up a native Apple Silicon Python environment, install MLX in a virtual environment, and record the version actually installed. The experiment below loads no external model and uses no random initialization, keeping network dependencies, tokenizers, and sampling noise out of the results.
python3 -m venv .venv
. .venv/bin/activate
python -m pip install mlx
python -m pip freeze > requirements.lock
Save the following code as resume_check.py. It trains a scalar linear model and uses an explicit momentum calculation instead of a full optimizer, making the state that must be persisted easy to inspect. Two fixed batches alternate according to the update count.
from pathlib import Path
import mlx.core as mx
batches = (
(mx.array([1.0, 2.0]), mx.array([2.0, 4.0])),
(mx.array([3.0, 4.0]), mx.array([6.0, 8.0])),
)
def advance(w, v, start, stop):
for step in range(start, stop):
x, y = batches[step % len(batches)]
grad = mx.mean(2.0 * x * (w * x - y))
v = 0.9 * v + grad
w = w - 0.01 * v
mx.eval(w, v)
return w, v
expected_w, expected_v = advance(
mx.array(0.0), mx.array(0.0), 0, 6
)
w, v = advance(mx.array(0.0), mx.array(0.0), 0, 3)
folder = Path("checkpoints")
folder.mkdir(exist_ok=True)
pending = folder / "step-3.pending.npz"
target = folder / "step-3.npz"
mx.eval(w, v)
mx.savez(str(pending), w=w, v=v, step=mx.array(3))
pending.replace(target)
state = mx.load(str(target))
start = int(state["step"].item())
actual_w, actual_v = advance(
state["w"], state["v"], start, 6
)
checks = (
mx.allclose(expected_w, actual_w, atol=1e-6, rtol=1e-6),
mx.allclose(expected_v, actual_v, atol=1e-6, rtol=1e-6),
)
if not all(bool(check.item()) for check in checks):
raise RuntimeError("Resume state mismatch")
Run python resume_check.py. It exits normally on success and raises an exception on failure. The tolerances are acceptance thresholds for this small experiment, not universal precision requirements for every model.
Deliberately break the state and confirm that the test fails
A passing positive test is not enough. Temporarily replace state["v"] in the resume call with mx.array(0.0) and run the script again. It should fail. If it still passes, first check that the test really compares the resumed result rather than accidentally using the baseline variables.
Next, keep the momentum intact but temporarily change the resume starting point to zero. This performs extra updates and changes the batch sequence, so the final state should again differ. Breaking one condition at a time tells you what the test actually protects.
A real data loader cannot always derive its cursor from the step count as this example does. With filtering, variable-length batches, or skipped corrupt samples, you need to record the next sample position or a resumable iterator state. Do not simply guess it as “step count times batch size.”
Move from the small experiment to real fine-tuning
For a real model, use the state interface provided by your current MLX optimizer and save the complete nested structure. Do not mistake the example's single momentum array for a universal format; adaptive optimizers may maintain multiple sets of statistics and internal counters.
MLX uses lazy evaluation. Explicitly evaluate the parameters and optimizer state before saving so that the update boundary is clear and verifiable. The example writes a temporary file in the same directory and then replaces the target, reducing the chance that a reader encounters a partially written file. This does not, however, guarantee durability after a power failure.
If a checkpoint spans multiple files, write them to a separate generation directory first, then publish a completion marker only after every write succeeds. The resume process must select only completed generations. It must not independently choose the “latest weights” and the “latest optimizer,” which could combine state from different update steps.
Validate randomness separately
Resetting the initial seed is not the same as restoring the point of interruption. If the random stream has been consumed a different number of times, subsequent results will change. Identify the random sources actually used and save their resumable state. If full restoration is not possible, document that limitation and validate against task-quality metrics instead of claiming step-by-step equivalence.
Complete final validation in a separate process
The script above tests a serialization round trip, but it still runs within a single process. Before integrating the protocol into a real job, split saving and resuming into two processes: the first saves and exits; the second must read only the checkpoint and must not inherit any in-memory variables.
Keep a validation record with at least these four items:
- Environment and training configuration: Python and MLX versions, data version, and batching rules.
- Resume position: completed update count, next batch identifier, and scheduler state.
- Comparison results: errors in the final parameters and optimizer state, along with the tolerances used.
- Failure paths: missing files, mismatched step counts, or incomplete generations must cause the resume attempt to be rejected.
If a small model can complete these checks locally, there is no need to rent a larger configuration just to test the protocol. Only after the protocol passes is it worth moving a long-running job to a cloud Mac. When choosing an instance, check the console for the configurations currently available. The goal is not merely to get the job “running again,” but to explain exactly which step it resumes from and what state it carries forward.
Frequently asked questions
Are model weights enough to resume training accurately?
Usually not. Restore optimizer state, completed update count, and the next batch position too. Random operations and learning-rate schedules also require their relevant state. Loading weights alone starts a new training phase.
Why does the example omit random-number state?
It uses fixed initialization, fixed data, and a deterministic batch order without random operations. Shuffle, dropout, or random augmentation require additional state capture and a resume test in a separate process.
Check memory before deciding whether to rent
If your local machine can’t handle the model, compare the three unified memory options: M4 16GB, M4 24GB, and M4 Pro 64GB. If your current device is enough, there’s no need to rent. Every plan includes a dedicated physical machine, not a virtual machine.