Model and Inference EngineeringTraining execution and recoveryStaff
How should a learning-rate schedule account for changing valid tokens per optimizer update?
By Amit Kumar3 min readWorked answer includedReviewed 28 Sept 2026
The question
Interview question
Warmup lasts 1,000 optimizer updates assuming eight million valid training tokens. A new packing/filtering path delivers only four million by that point. Explain the changed exposure schedule, define counters for raw/input/supervised tokens, and compare step-based and token-based scheduling, checkpoint restoration and an intentional mid-run recipe change.
Draft your approach first
Take a few minutes before you read the answer. Name the constraint that matters most, the failure you are designing for and how you would know it worked.
Reveal the worked answerWorked answer
An optimizer step is not a fixed amount of data unless the number of valid training tokens per step is fixed. The recipe says warm up over 1,000 steps, assuming eight million nonpadding tokens in that interval. A new packing and filtering pipeline delivers only four million valid targets by step 1,000. The learning-rate scheduler is behaving exactly as configured. The schedule in token exposure has changed. Hugging Face's optimizer schedules take a number of warmup and total steps, while its trainer state tracks steps and can track input tokens separately.
I would count three quantities, since they answer different questions: raw tokens read, input positions processed, and nonignored target tokens that contributed to loss. Padding and masked prompt spans can make them diverge sharply. Compare these per optimizer update and cumulatively across both runs, along with sequence lengths, gradient accumulation, world size and skipped optimizer steps. If the job uses a custom token-based scheduler, verify what it calls a token and when it advances its counter.
The fix depends on the intended recipe. If the scientific comparison is by processed training tokens, define warmup, decay and checkpoints in that unit, and make the conversion to steps explicit for the actual batch distribution. If the optimizer update count itself is the controlled variable, keep the step schedule but stop claiming equivalent token exposure. Changing tokens per update may also change gradient noise and task mixture, so matching one counter alone does not make the runs identical.
Could we simply double the number of warmup steps after noticing the gap? For a fresh run, that is a testable recipe change. Halfway through a run, it changes the remaining learning-rate path and needs a new experiment record, not a silent patch. The optimizer skipped a step. Why did the learning rate schedule advance? covers a scheduler advancing when an optimizer step was skipped. This question assumes steps really happened, but each step contained fewer useful tokens than the schedule designer assumed.
Under the hypothetical averages, the old recipe supplies 8,000 valid targets per update and the new one 4,000. Reaching eight million targets would take about 2,000 updates at the new fixed average. Simply retaining the 1,000-update warmup exposes the model to half the intended target count before reaching the planned learning rate. These are recipe calculations, not a claim that token-based warmup necessarily converges better.
A token counter also needs a distributed ownership rule. Sum the intended local counts across data-parallel workers, avoiding double-counting replicated inputs on tensor-parallel ranks. Decide whether progress means tokens processed or targets contributing to completed optimizer updates, and record skipped-update behavior separately. Restore that counter with the optimizer and scheduler state. A run that resumes the right global step with a reset token counter can silently repeat warmup or shift decay.
For instruction tuning, masked prompt tokens consume compute even when they are not supervised targets. Choosing one denominator for the optimization schedule and another for compute reporting is reasonable if both are explicit. Calling them both tokens without a definition makes comparisons irreproducible.
Related questions
Keep practising model and inference engineering
Follow another question in this area, or search the complete library.
Get my essays on AI engineering and distributed systems by email. Subscribe to ArchCrux