Priority GPU Job Scheduler With Non-Preemptive Workers
Last updated: November 29, 2026
Quick Overview
Video generation jobs arrive with an id, arrival time, duration and priority tier (lower runs first). With k identical GPUs that never preempt, simulate the scheduler and return each job's finish time, breaking ties by earlier arrival then id.
Luma AI
November 29, 20260
0
0 solved
Video generation jobs arrive with an id, arrival time, duration and priority tier (lower runs first). With k identical GPUs that never preempt, simulate the scheduler and return each job's finish time, breaking ties by earlier arrival then id.
Paid tiers and API customers expect faster turnaround than free users while every video job ties up a GPU for tens of seconds, so priority queueing over a fixed GPU pool is central to Luma's serving. The interviewer checks event simulation with two heaps and correct clock handling when the pool sits idle.
What the Interviewer Expects
- Separate the GPU-free heap from the waiting-job heap
- Advance the clock to the next arrival when nothing is waiting
- Admit every job that has arrived by the dispatch time before choosing
- Correct tie-breaking order
- O(n log n) complexity
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 add aging so free-tier jobs cannot starve?
- What changes if jobs can be preempted and checkpointed?
- How would you estimate a user's queue position and ETA from this model?
- How would you handle heterogeneous GPUs (some jobs need 80 GB)?
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Practice DSA ProblemsSample Answer
Requirements
Jobs (id, arrival, duration, priority). Each GPU runs one job to completion. When a GPU frees up, it takes the waiting job with smallest (priority, arrival, id). Return {id: finish_time}....
High-Level Design
Two min-heaps: free_at holds when each GPU is next idle, waiting holds arrived jobs keyed by priority. Repeatedly take the earliest-free GPU. If nothing is waiting, the dispatch time is the later ...