Best-Fit GPU Allocator for Eight-GPU Bare-Metal Nodes
Last updated: November 29, 2026
Quick Overview
Implement allocate(job_id, k) and release(job_id) over a fleet of 8-GPU nodes: jobs with k <= 8 must land on one node chosen by best fit, and jobs with k > 8 must be a multiple of 8 and take whole idle nodes.
Coreweave
November 29, 20260
0
0 solved
Implement allocate(job_id, k) and release(job_id) over a fleet of 8-GPU nodes: jobs with k <= 8 must land on one node chosen by best fit, and jobs with k > 8 must be a multiple of 8 and take whole idle nodes.
Fits the scheduling side of a Kubernetes and Slurm based GPU cloud, where fragmentation directly turns into GPUs that cannot be sold to a large training job. The interviewer wants a data structure that avoids an O(nodes) scan per request and a clear story for why best fit keeps whole nodes free.
What the Interviewer Expects
- Explains why best fit preserves fully idle nodes for multi-node jobs
- Uses buckets by free count so lookup is O(G log n) rather than a full scan
- Handles all-or-nothing allocation with rollback for multi-node jobs
- Makes release idempotent and rejects duplicate job ids
- Discusses lazy deletion correctness
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
- Multi-node jobs must also sit under the same InfiniBand leaf switch; how does the structure change?
- How would you add preemption of low-priority jobs to satisfy a high-priority request?
- What metric would you report to show fragmentation over time?
- How would this behave if nodes can go unhealthy mid-job?
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Practice DSA ProblemsSample Answer
Requirements
N nodes, each with G = 8 GPUs. allocate(job, k) returns the node list or None. Single-node jobs (k <= 8) go on the node with the fewest free GPUs that still fits (ties by lowest id). Multi-node jo...
High-Level Design
Keep free[node] and G+1 buckets, one min-heap of node ids per free count. Moving a node between buckets pushes it onto its new heap and leaves the old entry behind; _peek discards entries whose bu...