Training loss draws a sharp saw-tooth at every epoch boundary: diagnose.
Same topic, related formats. Practice these next.
Same topic, related formats. Practice these next.
An SFT run shows a striking pattern: loss drops smoothly within each epoch, then jumps back UP at the moment a new epoch starts, producing a sharp saw-tooth aligned exactly with epoch boundaries. Training is otherwise stable. Identify the most likely cause, why the jumps happen specifically at epoch boundaries, and what one-line fix usually resolves it. Also name the secondary suspect to rule out.
The data loader repeats the same batch order each epoch, so loss restarts at the same hard-batch sequence. Fix: per-epoch shuffling with an epoch-dependent seed, plus sampler.set_epoch under DDP or FSDP.
Picture practising a piano programme of twenty pieces in the same fixed order every day. Within a day you warm up on the first piece, get smoother by the tenth, and play the last few beautifully. Tomorrow you start again on piece one, which is hard from cold, and your score for that piece looks worse than where you ended yesterday. The score chart looks like a saw, jumping up every morning. The fix is to shuffle the order each day so you do not always restart on the same cold piece. In a training run, the same trick is to reshuffle the data on every full pass so the first chunks are not always the same hard ones.
Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example. Click to expand.
Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example.
Everything important, quickly.
4 min: identifying the saw-tooth as a data-order artifact + why same batch order produces same curve + the one-line shuffle fix + the DistributedSampler.set_epoch gotcha + curriculum and cosine-restart suspects to rule out + why it is a measurement issue, not a training issue.
Real products, models, and research that use this idea.
What an interviewer would ask next. Try answering before peeking at the approach.
Red flags and common mistakes that signal junior thinking. Click to expand.
Chasing this as a training-instability bug. It is a data-order artifact, the model is still learning, the loss curve is just being measured on a non-stationary sample order. Look at the loader, not the optimiser.
The night-before-the-interview bullets. Scan these on the way to the call.
Primary sources. Skim if you want the original framing.