Rolling Median Detection of Straggler Ranks in Distributed Training

Last updated: November 29, 2026

Quick Overview

Given a stream of (step, rank, step_seconds) from a distributed training job, flag every (step, rank) whose step time exceeds a factor times the median of that rank's previous w step times, in O(log w) per sample.

Nebius
Coding & Algorithms
Software Engineer
Nebius
November 29, 2026
Software Engineer
Onsite
Coding & Algorithms
Hard

0

0

0 solved


Given a stream of (step, rank, step_seconds) from a distributed training job, flag every (step, rank) whose step time exceeds a factor times the median of that rank's previous w step times, in O(log w) per sample.

In a synchronous training job on a Nebius GPU cluster, one slow GPU or flaky InfiniBand link stalls every rank at the next collective, so straggler detection feeds the health and auto-drain tooling. The interviewer is testing a sliding-window median with two heaps and lazy deletion, plus judgment about why a median beats a mean for noisy timings.

What the Interviewer Expects
  • Explains why median is robust to the occasional slow checkpoint step
  • Uses two heaps with balanced sizes for the median
  • Implements lazy deletion with tracked logical sizes for window eviction
  • Compares against the previous window before inserting the new sample
  • States O(log w) amortized per sample
  • Mentions alternatives such as a sorted container or order-statistic tree
Key Topics to Cover
sliding window median
two heaps
lazy deletion
anomaly detection
distributed training
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
  • How would you detect a rank that is slow because it waits on another rank, not because it is itself slow?
  • What if the whole job slows down at once (for example a storage stall); how do you avoid flagging every rank?
  • How would you scale this to 10,000 ranks across many jobs in a central service?
  • Could you use an approximate quantile sketch instead, and what do you lose?
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

Per rank, keep the last w step times. When a new time t arrives and the window is full, flag it if t > factor * median(window). Then slide the window. Each rank is independent. Need better than ...

High-Level Design

Per rank: a deque for the window order and a rolling median structure. The median structure uses a max-heap lo and min-heap hi with lo holding the extra element. Removing an arbitrary value is d...


Submit Your Answer
Markdown supported

Related Questions