Best-Fit GPU Host Allocator With Release
Last updated: November 29, 2026
Quick Overview
Design an allocator over hosts with free GPU counts that supports allocate(n), placing all n GPUs on a single host using best fit (the host with the fewest free GPUs that still fits), and release(allocation_id).
Nebius
November 29, 20260
0
0 solved
Design an allocator over hosts with free GPU counts that supports allocate(n), placing all n GPUs on a single host using best fit (the host with the fewest free GPUs that still fits), and release(allocation_id).
Placement is core to a GPU cloud: packing small jobs tightly keeps whole 8-GPU nodes free for the large training customers Nebius serves. The interviewer checks whether you pick an ordered structure that makes best fit logarithmic and whether you reason about fragmentation trade-offs.
What the Interviewer Expects
- Explains why best fit preserves large free blocks compared to first fit or worst fit
- Uses a sorted structure keyed by (free, host) for O(log H) lookup
- Keeps the index consistent on both allocate and release
- Returns None or an error when no single host fits
- Discusses tie-breaking and determinism
Key Topics to Cover
How to Approach This
- Clarify input constraints and edge cases before writing code.
- Walk through your approach verbally and confirm with the interviewer before coding.
- Start with a brute force solution, then optimize. Mention time and space complexity.
- Test your solution with examples, including edge cases like empty input or duplicates.
- Consider common patterns: sliding window, two pointers, hash map, BFS/DFS, dynamic programming.
Possible Follow-up Questions
- How would you support a request spanning multiple hosts on the same InfiniBand leaf?
- How would you add anti-affinity so two replicas of one service never share a host?
- Best fit can still fragment; how would you detect when to trigger defragmentation or live migration?
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Practice DSA ProblemsSample Answer
Requirements
Hosts have free GPU counts (typically 0 to 8). allocate(n) must place all n GPUs on one host, choosing the host with the smallest free count that is at least n, breaking ties by host id. `releas...
High-Level Design
Keep free[host] and a sorted list of (free, host). Allocation is a lower-bound search for (n, ""). Every mutation removes the host's old tuple and inserts the new one. In production use a balanc...