Split Model Layers Into Pipeline Stages Minimizing Bottleneck

Last updated: November 29, 2026

Quick Overview

Given per-layer compute costs in model order and k GPUs, assign contiguous runs of layers to at most k pipeline stages so that the most expensive stage is as cheap as possible. Return that minimal bottleneck cost and the layer indices where new stages begin.

NVIDIA
Coding & Algorithms
Software Engineer
NVIDIA
November 29, 2026
Software Engineer
Onsite
Coding & Algorithms
Medium

0

0

0 solved


Given per-layer compute costs in model order and k GPUs, assign contiguous runs of layers to at most k pipeline stages so that the most expensive stage is as cheap as possible. Return that minimal bottleneck cost and the layer indices where new stages begin.

Asked by NVIDIA teams on Megatron-style training frameworks and inference serving, where pipeline parallel throughput is set by the slowest stage. The interviewer looks for binary search on the answer with a greedy feasibility check, plus a solid argument for why the greedy check is correct.

What the Interviewer Expects
  • Identifies the answer range [max(cost), sum(cost)]
  • Writes a monotone greedy feasibility check that packs layers until the limit would be exceeded
  • Binary searches for the smallest feasible limit
  • Reconstructs stage boundaries at the optimal limit
  • States O(n log S) complexity and mentions memory constraints as a second dimension
Key Topics to Cover
binary search on answer
greedy
partitioning
pipeline parallelism
How to Approach This
  1. Clarify input constraints and edge cases before writing code.
  2. Walk through your approach verbally and confirm with the interviewer before coding.
  3. Start with a brute force solution, then optimize. Mention time and space complexity.
  4. Test your solution with examples, including edge cases like empty input or duplicates.
  5. Consider common patterns: sliding window, two pointers, hash map, BFS/DFS, dynamic programming.
Possible Follow-up Questions
  • Each GPU also has a memory cap per stage. How does the check change?
  • What if GPUs differ in speed?
  • Solve it with DP instead and compare complexity.
Sharpen Your Skills on Codemia

Practice similar problems with our interactive workspace, get AI feedback, and track your progress.

Practice DSA Problems
Sample Answer
Requirements

Input: costs (positive numbers, one per layer) and k. Stages are contiguous and cover every layer. Minimize the maximum stage sum. Using fewer than k stages is allowed because adding a split never...

High-Level Design

The bottleneck lies between max(costs) (one layer cannot be split) and sum(costs) (one stage). For a candidate limit L, a greedy pass that keeps adding layers to the current stage until the next o...


Submit Your Answer
Markdown supported