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
Coding & Algorithms
Software Engineer
Luma AI
November 29, 2026
Software Engineer
Onsite
Coding & Algorithms
Medium

0

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
Priority queues
Discrete event simulation
Scheduling
Starvation
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 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 Problems
Sample 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 ...


Submit Your Answer
Markdown supported

Related Questions