We need to design a GPU scheduling policy for ML workloads with quotas and priorities. The problem statement is open-ended. We need to come up with a design that addresses scheduling of GPU resources among multiple jobs (ML workloads) with quotas (maybe per user or per job, or maximum usage limits) and priorities (maybe critical jobs have higher priority). Likely the design should be a policy/algorithm for a cluster scheduler.
We need to consider: How to allocate GPUs to jobs, how to enforce quotas, how to handle priorities, maybe preemption, fairness, waiting times, etc.
We might design a hierarchical scheduler: Combine priority queuing with quota enforcement. Possibly use a DRF-like approach (Dominant Resource Fairness) but incorporating quotas and priority. Could use a credit system or weighted fair sharing.
Alternatively, consider a two-level scheme: global scheduler decides which job to admit based on quotas and priorities; then within a node, schedule GPU resources.
Need to think about features: multi-tenancy, heterogeneous GPUs, maybe multi-node training (distributed). But we can keep it relatively simple: single GPU per job or multiple GPUs per job, with jobs requiring fixed number of GPUs.
Quotas: Possibly each user/team has a maximum number of GPUs they can use at any time (e.g., 8 GPUs). Or maybe soft quotas (they can exceed if resources idle) vs hard quotas.
Priorities: Some jobs are high priority (e.g., production inference, urgent training) and should be scheduled before lower priority ones. But we still want to avoid starvation of low priority jobs. Could use priority with aging or backfilling.
We also need to consider that ML workloads often have long-running tasks; also some jobs might be short (hyperparameter tuning) and others long (full training). So backfilling could be used to fill gaps.
Also consider that jobs may have different GPU memory requirements or compute capability requirements. Might need to consider resource demands.
Also consider elasticity: jobs that can scale with number of GPUs (data parallel). Scheduling policy should handle packing efficiently.
The design should be described clearly, perhaps with a pseudocode algorithm.
We could propose:
-
Use a priority queue for pending jobs. For each priority level, maintain a FIFO queue. Or maybe multiple priority classes.
-
Each user has a quota (hard limit) on concurrent GPUs. When a job of a user is running, it consumes from their quota; when it finishes, it frees quota. scheduler admits a job only if the user has enough remaining quota.
-
Additionally, global quota per resource (e.g., total GPUs) obviously.
-
Priorities: High priority jobs can preempt lower priority jobs if necessary (maybe only if the lower priority job is preemptible, i.e., checkpoints allowed). We can have two types: preemptible and non-preemptible. Or we could use a policy where preemption is allowed but we prefer to avoid it.
-
Use backfilling: when a high priority job arrives and cannot be scheduled immediately due to quota, we may look at lower priority jobs that are scheduled and preempt them if they are preemptible. Or we could not preempt but wait.
-
To prevent starvation of low priority jobs, implement aging: increase effective priority of jobs waiting too long.
We also need to consider that quotas might be soft/hard. Typically in HPC, there is a fair-share allocation based on past usage; but here explicit quotas.
Better to design a scheme where each user has a guaranteed share (quota) and also can use extra if idle.
Could combine with priority: priority classes have different weights? Or simply static priorities.
Maybe we can design a "Weighted Fair Queuing" with quotas: each user has a weight (or maximum share). And jobs within a user have priorities. But the problem says "with quotas and priorities". Likely quotas per user/tenant; priorities per job.
Thus, we could view the system as: There are multiple users. Each user i has a maximum number of GPUs Q_i they can use concurrently. Also each job j has an owner user u(j), a required number of GPUs r_j, a priority p_j (maybe integer, where higher number means higher priority), and maybe a preemptible flag.
Scheduler's goal: Allocate GPUs to jobs respecting: for each user u, sum_{j running, u(j)=u} r_j <= Q_u. And respect priorities: higher priority jobs should start before lower priority ones, all else equal.
But we also need to maximize resource utilization, so we want to fill idle GPUs with jobs, even if low priority, as long as quotas allow.
Thus we need an admission control: when a GPU becomes free (or when a job arrives), we select a pending job to schedule. We need a policy that considers both priority and quota.
One straightforward approach: Maintain a global priority queue (by job priority). But we must respect quotas: a job may be high priority but its user already reached their quota. In that case, we cannot schedule it even though it's high priority, unless we preempt another job of same user? Actually if user's quota is full, we can't exceed, so we must wait. But we could preempt a lower priority job of that same user? But the lower priority job would be from same user, so that would free a GPU from that user's quota? Actually if a user's quota is 8, and they have two jobs running: a high priority job requiring 4 GPUs and a low priority job requiring 4 GPUs, total 8. If another high priority job from same user arrives needing 4 GPUs, we could preempt the low priority job to make room. So within a user, priorities matter. So we need to allow preemption within a user's jobs, but not across users (since quotas are per user). Actually if we preempt a low priority job of the same user to run a higher priority job of that user, then the user's total allocation remains within quota. That's fine.
But could we preempt across users? That would break quota: if user A has quota 8 and is using 8, we cannot take away a GPU from A to give to user B, because that would exceed B's quota? Actually if we take a GPU from A (so A's usage drops to 7) and give to B, B's usage increases; we need to ensure B's usage <= its quota. If B's quota is, say, 8, then it's okay if B currently using less than 8. But stealing from A reduces A's usage below quota, which is okay? Yes, quotas are maximum, not minimum. So we could allow cross-user preemption if needed to satisfy high priority jobs? But that would cause fairness issues: a low priority job from a user with high quota might be preempted by a high priority job from a user with low quota. That might be acceptable if priorities are global (i.e., some jobs are globally higher priority irrespective of user). But then quotas become soft? The policy could allow preempting lower priority jobs regardless of user to make room for higher priority ones, as long as quotas are not exceeded after preemption. However, that could cause a user's low priority job to be preempted repeatedly by high priority jobs from other users, leading to starvation if that user never gets to run their own high priority jobs? But if priorities are per job, it's not user-specific; so high priority jobs from any user should be able to preempt low priority ones. But then quotas: after preemption, the preempted job's user usage decreases, the preempting job's user usage increases. Both must be within their quotas. If the preempting job's user is already at its quota, then it cannot increase beyond quota. So preemption would only be possible if the target user has slack quota (usage < quota). So we need to check that.
Thus a more general policy: Always try to schedule highest priority jobs that can be admitted within quotas. If no GPUs free, we can consider preempting running jobs that have lower priority than the pending job, but only if after preemption all users' used GPUs <= their quotas, and the total freed GPUs are enough for the new job. And we might want to preempt the lowest priority jobs first, possibly across users, but respecting that we cannot cause a user's usage to go below zero or exceed quota after the swap.
But careful: Preempting multiple low priority jobs to run one high priority job: we need to ensure that the total GPUs freed >= required, and that after assigning the new job, the users' quotas are not violated.
Actually, to schedule a new job with required GPUs r, we need to find a set of currently running jobs to preempt such that after removal of those jobs, we have at least r free GPUs, and we can assign the new job without exceeding the user's quota. That is: let current usage per user: U_u. New job belongs to user v, requires r. We need U_v + r <= Q_v. After preempting some set S of jobs, total freed GPUs = sum_{j in S} r_j. We need sum_{j in S} r_j >= r. Also after removal, each user u's usage becomes U_u - sum_{j in S, u(j)=u} r_j. There's no lower bound, can go below quota. That's fine. So the only constraint is that after adding the new job, its user v's usage <= Q_v. Also we must ensure that the preempted jobs are lower priority than the new job? Usually we only preempt lower priority jobs. So we need to choose S among jobs with priority less than the new job's priority.
We might also consider that preempting a job incurs overhead (checkpoint, restart). So we might want to minimize the number of preemptions or total GPU-hours lost. We could use a minimization: find the smallest set of preemptions (in terms of GPU count) that frees enough GPUs. Or maybe the lowest priority jobs.
Also we could have a policy that preemption is only allowed for jobs that are marked as preemptible (or checkpointable). Some jobs may be non-preemptible (e.g., no checkpoint). Then we cannot preempt them. That adds constraints: S must be subset of preemptible jobs.
Additionally, quotas might be soft: users can exceed if resources idle, but when high priority arrives, we need to enforce quota. Could be modeled as hard quotas always enforced; but to avoid waste, we might allow over-quota if no one else waiting? Not sure.
Simpler: enforce quotas strictly: at any time, each user's used GPUs <= their quota. That's a hard constraint. So if a user's quota is full, their jobs cannot start even if GPUs idle, because the idle GPUs are not allocated to them. That seems wasteful. Usually quotas are for fairness, but if there are idle resources and a user's quota is already used, they shouldn't be prevented from using more if no one else needs it. Actually in many systems, quotas are used to limit usage to prevent hogging, but if there is idle, you can exceed? Typically in cluster scheduling (e.g., Slurm with QoS), you can have a maximum number of nodes per user/account, but if nodes are idle, a user could still launch more jobs if their account limit is max? Actually Slurm's "MaxTRESPerUser" limits the number of TRES a user can have allocated at any given time. If they already have that many, they cannot start new jobs even if resources are idle. That's a hard limit. So it's strict. So we'll treat quotas as hard maximums.
Thus, if a user's quota is full, their jobs wait, even if GPUs idle, because the idle GPUs could be used by other users if they have pending jobs and quota. But if no other user has pending jobs that fit, the GPUs stay idle? That seems suboptimal. But perhaps quotas are set based on share of resources; total of all quotas might be less than total GPUs? Usually quotas sum to total, or exceed total but then effective max is total. But if some users' quotas sum to less than total GPUs, then some GPUs may be idle even if all users are at quota because there is no user with available quota to use them. That's not efficient. So typically quotas are set to reflect fair share; but if total quota < total GPUs, that means the cluster is overcommitted? Actually if sum of quotas > total GPUs, then the cluster is oversubscribed; but if sum < total, then there is capacity that no user is allowed to use? That seems odd. Usually quotas are set per user to limit their usage to a fraction of total, but total GPUs is the physical limit. So sum of quotas likely >= total GPUs? Not necessarily; maybe admin sets per-user limits that are fractions, but the sum may exceed total; then effective limit is total, but each user individually limited to their quota. If sum > total, then the system is oversubscribed; but at any time, total used cannot exceed total GPUs. So some users may be at their quota while others not; total may be less than sum. If sum < total, then total GPUs could be more than total quota; meaning there is capacity that no user can use because they've all hit their max? That would be wasted capacity, but maybe that's allowed if admin wants to reserve capacity for something else (e.g., system jobs). But more typical is sum of quotas = total, or > total but with fair share.
Anyway, we'll treat quotas as hard caps per user. So we must enforce.
Now, let's design a policy:
We'll have a set of pending jobs (arrived but not started). Each job has: user, required GPUs, priority, preemptible flag, maybe start time (for FIFO within same priority). We'll also have running jobs.
We need to decide when a GPU (or set) becomes free, which job to start.
We can consider event-driven: when a job finishes, GPUs free. Then we attempt to schedule pending jobs.
Algorithm when resources become available (or periodical):
-
Sort pending jobs by some criteria: primarily by priority (descending). For equal priority, perhaps by waiting time (to avoid starvation) or FIFO.
-
For each job in sorted order, check if the job can be scheduled given current resources and quotas. "Can be scheduled" means: the number of free GPUs (i.e., not allocated to any running job) is at least the job's required GPUs, and after allocating, the user's total used GPUs (running jobs + this job) <= their quota. Also, if the job requires multiple GPUs, they must be on the same node? This adds binpacking complexity. But we could assume GPUs are identical and any set of free GPUs can be used, maybe with fragmentation concerns. For simplicity, we could consider total free GPUs across cluster, ignoring fragmentation, or we could have a bin-packing per node. But we can state that we consider node-level allocation; need to find a node with enough free GPUs. So we need to maintain free GPU counts per node, and possibly job may require contiguous GPUs on a node? But many ML jobs can use multiple nodes anyway; but we'll keep it at cluster-level aggregated free GPUs for simplicity, or we can note that we consider each node independently but scheduling is like multi-resource bin packing. Since the question likely expects a higher-level policy, we can abstract away the packing details.
Thus, when checking if job can be scheduled, we need to check if there exists a set of nodes where total free GPUs >= required, and each node's free GPUs are enough for partial allocation? Actually jobs can be multi-node; they might need, say, 4 GPUs across 2 nodes with 2 each. That gets complicated. We could assume jobs are single-node (require GPUs on one node). That's common for many training jobs but large ones use multiple nodes. However, we can design for both: we could treat each GPU as an independent resource, but then inter-node communication may require all GPUs on same node? For data parallelism, each worker on a node might have multiple GPUs. Usually you allocate whole nodes to a job. So perhaps we assume jobs request whole nodes with a certain number of GPUs per node. But not specified.
Given it's a design question, we can discuss that our policy can handle both single-node and multi-node jobs by considering nodes as resource units. But we can keep it simpler: treat GPUs as a homogeneous resource, and schedule based on total free GPUs, but then later map to nodes via bin packing. It's fine.
We'll say: we maintain per-node free GPU counts. To schedule a job with required r GPUs, we need to find a combination of nodes that sum to at least r (or exactly r) and each node can allocate a certain number to the job (like allocate whole GPUs). This is a bin packing problem; we could use a best-fit algorithm. But the core scheduling decision is based on order.
We could have a global queue sorted by priority; we attempt to pack each job as resources become available. This is essentially a priority-based best-effort scheduler.
But we must also consider quotas: each user's total allocated GPUs cannot exceed quota. So when selecting a job, we must ensure that after allocation, user usage <= quota. That can be checked easily.
Now what about preemption? If there are no free GPUs, we could consider preempting some running jobs to make room. The idea: if there is a pending job with high priority that cannot be scheduled due to lack of free GPUs and/or quotas, we may preempt lower priority jobs. Preemption decisions: select a set of preemptible, lower priority jobs whose total GPU count >= required, such that after preemption and allocating the new job, all users' usage <= quotas. Also we want to minimize disruption: choose preemption set that minimizes total GPU-hours of preempted work (or number of preemptions). We can formulate as: Among running jobs with priority < new job's priority and preemptible=true, select a subset to preempt that frees enough GPUs and also does not cause the new job's user to exceed quota. Note: If new job's user is already at quota, preempting jobs from other users will free GPUs but also reduce their usage, which is fine. But we need to ensure that after adding new job, the user's usage <= quota. So if user's current usage U_v, and we need r, we require U_v + r <= Q_v. If not, even after preempting other users' jobs, we cannot schedule. However, we could also preempt some of this user's own lower priority jobs to make room? But if user is at quota, they are using exactly Q_v. To schedule another job of size r, we would need to free r GPUs from that user. That is possible by preempting some of their own running jobs (if any are lower priority and preemptible). So preemption can include the same user's jobs. So we consider all running jobs with lower priority (including possibly same user) that are preemptible.
But we need to be careful: if we preempt a job from a user, that user's usage decreases; that could allow allocating to another user. So it's fine.
Thus, the condition for preemption:
- The pending job can be scheduled after preempting some set S of running jobs, such that:
- For each job j in S, p_j < p_new (or <=? typically strictly lower, or maybe <= if same priority we might not preempt? We'll assume strictly lower).
- For each job j in S, preemptible flag = true.
- sum_{j in S} r_j >= r_new.
- After removal: For each user u, new usage = U_u - sum_{j in S, u(j)=u} r_j.
- After adding new job: For user v = u(new), usage = (U_v - sum_{j in S, u(j)=v} r_j) + r_new <= Q_v.
- For other users u != v: usage = U_u - sum_{j in S, u(j)=u} r_j (which is <= previous, so remains <= Q_u if they were within before; but if they were already at quota, subtracting is fine, they go below, still within). So no issue.
- The preempted jobs must be stoppable (maybe send kill signal, they checkpoint and exit).
We also need to consider that preemption should be done in a way that minimizes impact. A simple heuristic: preempt the lowest priority preemptible jobs first, preferring those with smallest resource consumption? Actually we want to minimize total wasted GPU time. If we preempt a job that has already used a lot of time, that's waste. So we might prefer to preempt jobs that have run the least time, or that have smallest runtime cost? But often we don't know remaining runtime. Simpler: preempt the job with the lowest priority, and among those, the one that uses the fewest GPUs? Actually if we need to free r GPUs, we might preempt a few large jobs or many small ones. To minimize number of preemptions (which cause overhead), we might prefer to preempt larger jobs. But preempting a large job may waste more compute. It's a trade-off.
We could use a simple rule: preempt the lowest priority jobs first, and when choosing among same priority, choose those with the smallest runtime so far (to minimize waste) or the ones that are more checkpointable? Alternatively, we could not preempt at all and just use priority with backfilling without preemption. Many cluster schedulers (like Slurm) support preemption but with priorities.
We could propose a tiered priority system: High, Medium, Low. Within each tier, use fair-share quotas. But the question says quotas and priorities, so both.
Alternatively, use a "deficit round robin" per user with priority weighting. But quotas are max, not weight.
Let's think about an approach that integrates quotas and priorities elegantly:
- Use a global priority queue sorted by (priority, arrival time). But enforce quotas: when selecting the head job, if its user's quota is already full, skip it and consider the next job that can be scheduled without exceeding quota and with available GPUs. This is like "quota-aware priority scheduling". This might cause high priority jobs to be blocked if their user's quota is full, while lower priority jobs from other users with available quota could run, even if they are lower priority. That seems plausible: quotas are constraints; if a user has exhausted their quota, they must wait, regardless of priority. Only when they have quota (maybe because some of their jobs finished or were preempted) can they schedule new ones. But what if a high priority job from user A arrives and user A is at quota, but there is a lower priority job from user B with available quota. We would run B's job even though A's job is higher priority. Is that acceptable? Possibly yes, because quotas are meant to enforce fairness across users; a user cannot exceed their limit, even if they have high priority jobs. That is consistent: quotas are hard caps; they cannot be exceeded. So high priority jobs might be delayed because the user already used their allocation. That's fair if quotas are allocated per user based on some share. So high priority does not override quota; it's just a relative order among jobs that can be scheduled within quotas.
But what about preemption across users? Suppose user A has high priority job but is at quota, and user B has lower priority job running. Could we preempt B's job to make room for A? That would reduce B's usage, freeing quota for A to use? But A's quota is already full. To schedule A's new job, we need to free GPUs that A can use, but A's total cannot exceed quota. If A is already at quota, adding a new job would exceed quota unless we also reduce A's existing usage. That could happen if we preempt one of A's own lower priority jobs. So cross-user preemption would not help A's quota issue because the problem is that A's total used is already at quota. Preempting B will free GPUs but not reduce A's usage; so after giving those GPUs to A's new job, A's usage would increase, exceeding quota. So cross-user preemption cannot help when the user is at quota. Only preempting A's own jobs can make room.
But what if A's usage is less than quota? Then they have slack. If there are no free GPUs, we could preempt some lower priority jobs (maybe from other users) to get free GPUs, then allocate to A, as long as A's usage + new job <= quota. That is allowed. So cross-user preemption can help if A has remaining quota. So preemption across users is possible if the high priority job's user has remaining quota.
Thus, we need to consider both scenarios.
Now, what if there is a very high priority job that cannot be scheduled because all users are at their quotas? Then even preempting lower priority jobs would not free quota for that user if it's at its max. But if we preempt a lower priority job from the same user, we could free quota for that user, but we might preempt a lower priority job of that user and then schedule the new high priority one. That would keep that user's total <= quota. That's possible if that user has some lower priority jobs running. So essentially, high priority jobs can preempt lower priority ones, but only within the same user's quota? Actually if the user is at quota, they have some running jobs (maybe all high priority already, or some low). Preempting a low priority job from that same user would reduce that user's usage, freeing quota for the new job. So that's allowed. So preemption across users is not necessary to handle the case where the high priority job's user is at quota; we can just preempt within that user's jobs, if any lower priority. But if that user has only high priority jobs running and all are at max priority, then maybe they can't schedule new high priority because no lower priority to preempt. That's a scenario where the high priority job must wait until some of their existing jobs finish.
Thus, preemption policy: when a high priority job arrives and cannot be scheduled due to lack of free GPUs, we look for preemptible lower priority jobs to evict. The candidate set includes any running jobs with priority less than the new job. Among those, we need to select a subset that frees enough GPUs such that after adding the new job, the user's usage <= quota. However, we must also ensure that the preempted jobs are preemptible. Also we might want to avoid preempting jobs that are almost finished. But we don't know.
We could design a two-level approach: maintain per-user queues of jobs sorted by priority. Then the scheduler tries to satisfy each user's demand up to their quota, but also has a global priority that can preempt.
Alternatively, we could adopt a "priority-based fair sharing" where each user gets a weighted share, and we allocate resources based on priority weights across users. That is more complex.
Given the open-ended nature, we can propose a design that includes:
-
Data structures: pending queue sorted by priority (and arrival time for tie-breaking), per-user quota tracking, per-node free GPU counts.
-
Scheduling loop: when resources free (job completion or new job arrival), attempt to schedule as many pending jobs as possible in priority order, respecting quotas and packing. Use a best-fit bin packing for nodes.
-
Preemption: if a high priority job cannot be scheduled due to insufficient free GPUs, attempt to preempt lower priority preemptible jobs. This could be done by selecting victims based on lowest priority, and if multiple, choose those that minimize total resource freed (i.e., match exactly needed) or minimize number of victims. Possibly also consider the amount of work already done (if known). If preemption is successful, evict those jobs (gracefully, allowing checkpoint), free resources, and schedule the new job. Then the evicted jobs go back to pending queue with their priority unchanged? Or maybe they get a penalty? Typically evicted jobs re-enter the pending queue.
-
To prevent starvation of lower priority jobs, we can implement aging: if a job has waited beyond a threshold, temporarily boost its priority (or reduce effective priority of others?). Or we can guarantee a minimum share: e.g., each priority class gets a minimum allocation over time. But simpler: use a backfilling approach that allows lower priority jobs to run if they fit within the resources that will be freed by higher priority jobs at known times (if we have runtime estimates). But we may not have estimates.
We could also use a "lottery scheduling" with priorities as tickets, but that may be overkill.
We can describe the policy as an extension of the classic "priority scheduler with quota enforcement and preemption". Provide algorithm steps.
We should also consider that ML workloads often have specific requirements: they might need GPUs with specific memory or compute capability. We can mention that our policy can incorporate resource constraints (e.g., GPU type) by filtering jobs and nodes.
Let's structure the answer:
-
Problem definition and goals: Efficient GPU utilization, fair sharing via quotas, priority differentiation, low latency for high-priority jobs, avoid starvation.
-
System model: Cluster of nodes each with GPUs. Jobs request a number of GPUs, may be single or multi-node. Each job has attributes: user, required GPUs, priority (integer), preemptible (bool), maybe deadline.
Users have quota Q_u (max concurrent GPUs). Also maybe global quota.
-
Data structures:
- Pending jobs: priority queue ordered by (priority descending, arrival_time ascending). For equal priority, FIFO.
- Running jobs: per-node mapping, also maintain per-user used GPU count.
- Preemptible flag per job (could be default true for some job types, false for others).
- Optionally keep track of job's start time, runtime estimate for aging or backfilling.
-
Core scheduling algorithm:
When resources become available (i.e., job completion frees GPUs, or new job arrival triggers check), we run:
a. Update free GPU counts per node.
b. While there exists a pending job that can be scheduled (i.e., its required GPUs can be allocated from free GPUs across nodes, respecting that GPUs on same node can be allocated to same job, and after allocation user usage <= quota), pick the highest priority such job and allocate.
- To check feasibility: find a set of nodes with enough free GPUs (e.g., via a best-fit decreasing algorithm). Also ensure that the user's current usage + required <= quota.
- If found, allocate (reserve) those GPUs to the job, move job to running, update per-user usage.
c. The loop continues until no more pending job can be scheduled with current free resources.
This is greedy.
This algorithm essentially is a priority-based bin packing with quota constraint.
-
Handling insufficient free GPUs: Preemption mechanism.
- When a new job arrives with priority p_new, if it cannot be scheduled by step 4 (i.e., not enough free GPUs to satisfy its demand given quotas), we consider preempting lower priority running jobs.
- We compute the set of candidate preemptible jobs: all running jobs with priority < p_new and preemptible=true. Also, we could consider that even if priority equal, we might not preempt (or only if same priority but with smaller runtime?). We'll stick to strictly lower.
- We need to decide which subset to preempt to make room. Solve: find minimal set (by total GPU count) of candidate jobs such that after removing them, we have enough free GPUs to schedule the new job, and also the new job's user quota constraint is satisfied (i.e., its usage after adding new job <= quota). Note that removing candidate jobs frees GPUs and also reduces usage of those users. This may indirectly help if the new job's user is at quota: if we also preempt some of the same user's lower priority jobs, that reduces that user's usage, allowing new job. So we must consider that candidate set can include jobs from the new job's user as well.
- This is a knapsack-like problem. For simplicity, we can use a greedy: among candidate jobs, sort by increasing priority difference (or by priority ascending, then by GPU count descending? Or by GPU count ascending? Actually we want to free enough GPUs, but minimize waste. If we preempt a job with large GPU count, we might free more than needed but we preempt a big job causing more disruption. But if we preempt many small jobs, we might have to evict many, causing many jobs to be interrupted. There's a trade-off. We could aim to minimize the number of preempted jobs (to reduce overhead) by picking larger jobs first. Or minimize total GPU-time wasted: if we know runtime, we could pick jobs with least "progress" (time executed). Without that, we could just pick based on priority: preempt the lowest priority jobs first. Since they are lower priority, they are less important. So we can just pick the lowest priority jobs until we free enough GPUs. That might lead to preempting many small low priority jobs to free enough for one high priority job, but those small jobs are less important anyway. That's acceptable.
Now, we need to produce a final answer: a design description, perhaps with bullet points, algorithm steps, and justification.
Let's produce a well-structured answer:
- Introduction: what we are designing.
- System model and assumptions.
- Key components: job attributes, user quotas.
- Scheduling policy overview: priority-based with quota check, preemption for high priority jobs, aging.
- Detailed algorithm: initialization, event handling (job submission, job completion), scheduling decision procedure (including preemption selection).
- Handling of multi-node and heterogeneous resources (briefly).
- Discussion of trade-offs and possible extensions.
- Conclusion.
We'll write in a clear, technical style.
We should also mention that we assume checkpointing capability for preemptible jobs.
Let's craft the answer.
GPU Scheduling Policy for ML Workloads with Quotas and Priorities
1. System Model and Assumptions
- Cluster: A set of compute nodes, each equipped with one or more GPUs. GPUs may be homogeneous or heterogeneous (e.g., different memory sizes, architectures).
- Workloads: Each ML job
j is submitted with:
user(j): owner of the job.
gpu_req(j): number of GPUs required.
priority(j): integer (higher = more urgent).
preemptible(j): boolean – whether the job can be checkpointed and safely killed.
- Optional:
node_constraints (e.g., requires GPUs with ≥16 GB), duration_estimate.
- Quotas: Each user
u has a hard limit quota(u) on the total number of GPUs they may occupy concurrently. The sum of all quotas may be larger than total GPUs (the physical limit is always respected).
Jobs may be single-node or multi-node; scheduling must pack GPUs respecting node boundaries.
2. Design Goals
- Priority differentiation: High‑priority jobs should start as soon as possible.
- Quota enforcement: No user may exceed their allocated quota at any time.
- High utilization: Idle GPUs should be used whenever possible, even by low‑priority jobs, provided quotas allow.
- Starvation avoidance: Low‑priority and long‑waiting jobs eventually get a chance to run.
- Limited disruption: Preemptions are minimized and only applied to preemptible jobs.
3. High‑Level Policy
The scheduler maintains a global priority queue of pending jobs (ordered by priority descending, then FIFO). Running jobs are tracked with their resource consumption. The core decision loop repeatedly attempts to admit the highest‑priority pending job that can be accommodated either by using currently free GPUs or by preempting lower‑priority preemptible jobs. Quotas are checked before any admission.
The policy is event‑driven: after a job finishes (freeing GPUs) or a new job arrives, the scheduler runs the admission loop. If a job cannot be admitted directly, preemption is considered. Aging (waiting‑time boost) is applied to pending jobs to prevent indefinite postponement.
4. Scheduling Algorithm
Data Structures
pending : priority queue (max‑heap) of jobs, key = (priority, arrival_time)
running : set of currently executing jobs
node_free[node] : number of free GPUs on each node (updated on allocation/free)
user_usage[user] : total GPUs allocated to the user
Helper Functions
Main Scheduling Loop
When an event occurs (job completion or new submission):
function schedule_event():
# 1. Replenish free GPUs from any finished jobs (already done by event handling)
# 2. Attempt to schedule pending jobs
made_progress = true
while made_progress:
made_progress = false
for job in pending (in priority order):
if can_allocate(job):
allocate(job) # reserves GPUs on nodes, updates user_usage
move job from pending to running
made_progress = true
break # restart from top because resources changed
else:
# try preemption
S = find_preemption_set(job)
if S != null:
preempt(S) # gracefully stop those jobs, free their GPUs
# preempted jobs are re‑queued (see below)
allocate(job)
move job from pending to running
made_progress = true
break
# end for
# apply aging to pending jobs (see below)
Aging (Starvation Prevention)
Each pending job maintains waiting_time. Periodically (e.g., on each scheduling iteration) we increase waiting_time and compute an effective priority:
effective_priority = base_priority + α * waiting_time
where α is a small aging factor. The priority queue is reordered according to effective_priority. This ensures that jobs waiting long enough will rise above newer higher‑priority jobs, guaranteeing eventual service.
Preemption Details
- Preempted jobs are terminated after checkpointing (if supported). They are placed back into the pending queue with their original
priority (or optionally with a temporary priority reduction to avoid thrashing).
- Preemption is only attempted when a higher‑priority job (strictly greater) is blocked. This prevents ping‑pong effects.
- The system may limit the number of preemptions per scheduling round or impose a minimum priority gap (e.g., only preempt if the new job’s priority exceeds the victim’s by at least 2) to reduce churn.
5. Handling Multi‑Node and Heterogeneous Resources
- The packing step (
can_allocate) uses a best‑fit decreasing bin‑packing algorithm across nodes, considering node‑level free GPU counts and any job‑specific constraints (GPU type, memory).
- For multi‑node jobs, the algorithm searches for a combination of nodes whose free GPUs sum to at least
gpu_req, optionally requiring that each node contributed at least a minimum per‑node allocation (e.g., 2 GPUs per node for NCCL).
- Heterogeneous GPUs are treated as separate resource dimensions; quotas can be defined per GPU type. The same algorithm works in multiple dimensions.
6. Correctness and Properties
- Quota safety:
user_usage is updated only after passing the quota check; preemption never increases a user’s usage beyond its quota because delta_user guarantees that the victim set includes enough GPUs from that user.
- Priority ordering: The pending queue is always served in descending effective priority; a job is only skipped if it cannot be scheduled even after maximal allowed preemption. Hence, if a job can be admitted without violating constraints, it will eventually run.
- No deadlock: Aging ensures that even if all higher‑priority jobs are infinite, low‑priority jobs will eventually acquire enough effective priority to be scheduled when resources free.
- Termination: Each loop iteration makes progress by either scheduling a job or exhausting the pending list.
7. Extensions and Optimizations
- Backfilling: With accurate runtime estimates, the scheduler could allow lower‑priority jobs to “backfill” into gaps created by higher‑priority jobs’ reservations without affecting their start times.
- Fair‑share weighting: Quotas could be derived from a fair‑share allocation model and updated dynamically based on usage history.
- Preemption cost model: Preempt jobs with the least “wasted” compute (e.g., shortest elapsed time, or smallest remaining time estimate) rather than pure priority.
- Gang scheduling: For multi‑node jobs that require strict simultaneous start, the scheduler could use a gang‑scheduling extension that atomically reserves resources for all jobs in a gang.
8. Summary
The proposed policy combines priority queuing, hard quota enforcement, and targeted preemption to meet the competing demands of urgency, fairness, and utilization in ML GPU clusters. It is greedy, event‑driven, and incorporates aging to prevent starvation. The design can be extended to handle heterogeneous resources and multi‑node jobs via a bin‑packing allocator.