Build a Training Job Scheduler for Shared GPU Clusters


distributed-systems cloud-infrastructure cost-optimization

AI System Design Deep Dive

Shared GPU Cluster Scheduler

256 GPUs, 5 teams, one queue: keep the cluster full without starving anyone.

⏱ 14 min read 📐 Advanced ⚙️ Training Infra

Picture an airport with 256 gates and five airlines. Every airline owns some gates and has flights that need two, four or eight adjacent gates for a wide-body. If the tower hands out gates first come first served, a regional jet parks in the middle of the wide-body concourse, and a 777 circles for hours while 20 gates sit empty one at a time. If the tower walls the concourse off per airline, the gates are never blocked, but one airline queues planes on the apron while another’s gates sit dark. A shared GPU cluster is that airport, except the planes are training jobs that cannot take off with half their gates.

The cluster is 32 p5.48xlarge nodes: 256 H100 GPUs in four racks of eight nodes, shared by five teams with quotas of 96, 64, 48, 32 and 16 GPUs. At $55.04 per node-hour that is $6.88 per GPU-hour, $1,761.28 per cluster hour and $42,270.72 per day. About 43 jobs arrive per day, from 1-GPU debug runs to 64-GPU gangs that run for 20 hours, and together they ask for 93 percent of the raw capacity. Everything that follows is about the other 7 percent, and about the much larger loss hiding inside the 93.

A job on this cluster is a gang: all of its GPUs start together or none do, because a synchronous training step blocks on every rank. That one property breaks the simple scheduler. First-come-first-served wastes GPUs because the head of the queue is a 64-GPU job that cannot start while a 1-GPU job could. Greedy GPU-level placement splits an 8-GPU job across two nodes and it runs 1.35x slower on the network instead of NVLink. Static quotas never fragment and never share, so one team’s backlog grows while another’s GPUs idle. In our simulation of a 21-day trace, FIFO delivers 56.1 percent useful GPU time, FIFO with backfill 58.7 percent, static partitions 67.8 percent, and the design below 78.3 percent. At $6.88 per GPU-hour that is the difference between $11.72 and $8.79 for each useful GPU-hour, about $254,000 over an 18-day window.

We need to solve for gang placement (all GPUs, in the right rack, or none), fair sharing (each team gets its quota, idle capacity is lent out, and borrowers give it back) and bounded waiting (a 64-GPU job cannot be starved forever by a stream of small ones) simultaneously.

Requirements and Constraints

Functional requirements

  • Accept job specs with a GPU count, a class (prod, research, besteffort), a runtime estimate and a checkpoint location.
  • Admit jobs against per-team quotas and reject specs the cluster can never place.
  • Start every job as a gang: either every GPU is bound or none is, with no partial holds.
  • Place jobs topology aware: one node for up to 8 GPUs, whole nodes in one rack for larger gangs.
  • Lend idle quota to other teams, and take it back by preempting borrowers when the owner submits.
  • Record every state change and every GPU-second charged to a team.

Non-functional requirements

  • Throughput: 43 jobs per day, 256 GPUs, scheduler decisions in under 10 ms per pass at 1,000 pending jobs.
  • Latency: p95 queue wait for prod jobs under 3 hours, median wait for jobs of 8 GPUs or fewer under 5 minutes, both at 93 percent offered load.
  • Quality: goodput (GPU-time spent on useful training steps, divided by cluster capacity) of at least 75 percent at 93 percent offered load.
  • Cost: under $9.00 per useful GPU-hour at $6.88 per allocated GPU-hour, so at most 31 percent of spend is idle or wasted.
  • Capacity: pending queue up to 5,000 jobs, 1,000 concurrent running jobs, ledger writes under 100 per second.
  • Safety: zero oversubscribed GPUs and zero partial gangs, enforced by invariants on every pass.

Constraints

  • Hardware: p5.48xlarge nodes, 8 H100 80 GB, NVLink inside the node, 400 Gb/s class networking between nodes. A rack is 8 nodes, so one rack is exactly one 64-GPU gang.
  • Training frameworks restart from checkpoints. Every job checkpoints every 30 minutes and restarts in 2 minutes after an eviction.
  • Out of scope: multi-cluster federation, spot capacity, fractional GPUs and MIG, and the training code itself. The price is $55.04 per p5.48xlarge hour in us-east-1 (third party trackers, last updated 15 October 2026).
Key Insight

The metric that matters is goodput, not utilization: FIFO with backfill keeps 98.6 percent of GPUs allocated and still delivers only 58.7 percent useful work, because about 40 percent of that allocated time is spent running slower on badly placed gangs.

High-Level Architecture

Think of a hospital operating-room board. Surgeries have a length estimate, a required team and a priority. The board keeps rooms full by sliding short procedures into gaps, holds a room for a long surgery that has been waiting the longest, and bumps an elective case when an emergency arrives. The scheduler has the same six parts, arranged as a submission plane, a single-leader scheduling loop and the GPU pool it commands.

Architecture of the training job scheduler: five teams submit through an admission API into a fair share pending queue and a usage ledger, a single leader scheduler loop runs reservation and backfill, a rack aware placement engine and a preemption controller, binding leases onto four racks of eight p5.48xlarge nodes, with a checkpoint store receiving SIGTERM driven checkpoints

A job travels like this. The admission API validates the spec and tags it with whether it fits inside the team’s remaining quota. The pending queue ranks jobs by class, then by decayed usage divided by quota, then by submit time. The scheduler loop takes the ranked list and tries to place the head. If the head fits it starts. If not, the reservation engine computes the earliest time the head could start from the runtime estimates of running jobs, and the backfill pass lets smaller jobs start only if they cannot delay that reservation. If the head is in quota and still blocked, the preemption controller looks for borrowers to evict, and does a dry run first so it never evicts a job without freeing a place for the gang.

Every bind is a lease: the job holds its nodes until it finishes, is evicted, or its lease expires without a heartbeat. The usage ledger is charged on release, so fair share always reflects GPU-seconds actually held.

  • Admission API: validates specs, tags quota status, rejects impossible gangs.
  • Pending queue: fair-share ranking by class, decayed usage over quota, and age.
  • Reservation and backfill engine: computes the shadow time for the blocked head and admits only harmless small jobs.
  • Placement engine: chooses nodes with best fit inside one node or one rack.
  • Preemption controller: evicts borrowers with checkpoint-aware victim ordering and a dry run.
  • Usage ledger and lease table: durable record of who held which GPUs for how long.
Key Insight

One leader makes every decision from one in-memory free map: a gang scheduler needs a consistent view of all 256 GPUs, and a pass takes 0.03 ms on average in the simulator, so there is nothing to gain from distributing the decision.

The Fair-Share Queue

The queue’s job is to decide who goes first without letting any team run away with the cluster.

The non-obvious part is that quota is not a ceiling and fair share is not a counter. A team at quota 96 can use 200 GPUs on an idle cluster, and the question is only who gets pushed back when everyone wants their share. We rank by usage / quota, where usage is GPU-seconds consumed with an exponential half-life of 24 hours. Fair share works like a bar tab with a short memory: the team that drank most recently waits at the back of the line, and last week’s tab is mostly forgiven.

With a half-life of 24 hours the decay time constant is 86,400 / ln 2 = 124,649 seconds. A team that holds exactly its quota in steady state carries a ratio of 124,649 seconds, so ratio / 124,649 reads directly as “share of quota consumed” and 1.0 means the team is at quota. Teams below 1.0 sort ahead of teams above it, which is the whole fairness mechanism.

# Fair-share ordering from the simulator: class first, then decayed usage over quota, then age.
def order(self):
    if self.policy == "fair":
        o = sorted(self.pending, key=lambda j: (RANK[j.cls], self.usage[j.team] / QUOTA[j.team], j.submit))
        if self.sticky in o and o[0].cls != "prod":      # keep the reservation from flip-flopping
            o.remove(self.sticky); o.insert(0, self.sticky)
        return o
    return sorted(self.pending, key=lambda j: j.submit)

The two sticky lines pin the reservation holder to the front of the queue and are explained under the reservation engine. The decay is applied on every event, so the ledger never needs a cron job:

# Exponential decay applied to every team's usage on each event (from Sim.run).
for k in self.usage: self.usage[k] *= 0.5 ** (dt / HALF_LIFE_S)

Premium Content

Unlock the full article along with everything else in the archive — all in one place.

In-depth analysis Expert insights Full archive access
Unlock Full Article