Model and Inference EngineeringTraining execution and recoveryStaff
How do pipeline depth and microbatch count affect training throughput and idle time?
By Amit Kumar3 min readWorked answer includedReviewed 28 Sept 2026
The question
Interview question
A training job increases pipeline depth from four to eight stages to fit a larger model. Global batch and sequence length remain fixed, but throughput falls and stage traces show idle gaps. Explain the fill-and-drain mechanism, estimate its cost for a simple balanced schedule with four microbatches, and compare feasible repairs without silently changing the optimization recipe.
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
Pipeline parallelism assigns consecutive parts of a model to different workers. A microbatch must reach an earlier part before it can reach a later one. With four microbatches, the simplified useful-time fraction is 4/(4+4-1)=4/7, about 57 percent, for four balanced stages. At eight stages it is 4/11, about 36 percent. The extra-to-ideal-time ratios are respectively 3/4 and 7/4, while idle fractions of total time are 3/7 and 7/11. Those denominators answer different questions.
The stages form a pipeline only while there are microbatches in flight. At the start, later stages wait for the first microbatch. At the end, earlier stages wait while the last backward passes finish. We flush before the next optimizer step to preserve the intended batch update. Splitting layers across more GPUs reduces work and memory per stage, but it also deepens the pipeline that has to fill and drain.
For a simple balanced flush schedule with p stages and m microbatches per optimizer step, the extra bubble time relative to the ideal busy time is (p − 1) / m. Equivalently, ignoring communication and imbalance, useful utilization is roughly m / (m + p − 1). With four microbatches and eight stages, that idealized utilization is 4 / 11, only about 36%. This is a simplified scheduling estimate, not a prediction of real GPU utilization. NVIDIA's Megatron explanation lays out the pipeline fill and drain and the 1F1B and interleaved schedules. The common mistake is to call (p − 1) / m a percentage of actual wall time even when it exceeds one. Its denominator there is the ideal compute time.
I would draw the measured schedule from traces, not infer it from a single throughput number. Count microbatches per step, forward and backward time per stage, point-to-point transfers, tensor parallel collectives, activation recomputation, and time waiting at the flush boundary. Find the slowest stage. If stage 5 contains an expensive embedding or MoE layer, balancing by layer count will not balance work. A scheduler can also expose extra idle time from uneven sequence lengths or communication across slower interconnects.
Adding microbatches can amortize the bubble, but ask what stays fixed. If the global batch remains constant, making each microbatch smaller can turn efficient matrix multiplies into tiny ones and change communication overhead. If we simply increase the number of same-sized microbatches, we change the global batch or accumulation schedule, and that can change optimization. Interleaved virtual stages can reduce bubble at the cost of more communication. Activation recomputation may recover memory to allow a better microbatch shape while adding compute. Sometimes a different tensor, sequence or data parallel split gives a better end-to-end balance. These are measurements, not a rule to always use fewer pipeline stages.
The interviewer may say, “But we only care about fitting the larger model.” Fair, fitting is a hard constraint. The decision then is the fastest valid configuration under that constraint, with an acceptable training recipe. I would benchmark several p and m pairs at the actual sequence lengths, report tokens per second per GPU and total step time, and verify the same loss semantics and checkpoint behavior. A configuration that saves memory but leaves most stages empty is usable only if no better feasible partition exists.
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