Guide

A training job often needs 32 GPUs at the same time, because every worker waits on the others. Gang scheduling starts a group of workers together, or starts none of them. Without it, a job can take part of its GPUs and wait forever for the rest.

Concept

A gang is a group of pods that only makes sense if they all run. A scheduler decides which node each pod goes to. The default Kubernetes scheduler places pods one at a time, so it does not know that 32 pods belong together.

The big idea

Picture a group booking at a restaurant. The party of 32 needs 32 seats. If the restaurant seats 24 of them and holds those seats while the rest wait, the 24 sit idle and block other guests. Gang scheduling means the party sits down only when all 32 seats are free.

Walking through the deadlock

Here is the failure with a default scheduler.

StepWhat happensGPUs held
1Job A asks for 32 GPUs and the scheduler places pods one by one0
224 workers land on GPUs24
3The cluster has no room for the last 8, so those workers stay Pending24
4Job A cannot run, and the 24 held GPUs cannot serve any other job24 wasted

With a gang scheduler, steps 2 and 3 never happen. The job waits with zero GPUs held. It starts when all 32 fit.

Kueue and Volcano extend Kubernetes with queues, quotas and gang semantics. Slurm, the batch system many HPC groups use, works differently. It hands out a job's nodes as a unit with exclusive allocation.

Slurm vs Kubernetes

Choose Slurm whenChoose Kubernetes when
The organization is HPC-nativeThe same platform serves online inference
Jobs are batch-shaped and largeYou already run GitOps and cloud IAM on Kubernetes
Fair-share queues per account matter mostYou are willing to invest in Kueue or Volcano
Exclusive node allocation is the normYou want one control plane for many kinds of work

Trade-off

Slurm vs Kubernetes with Kueue or Volcano. Many organizations run both: Slurm for giant pretraining runs, and Kubernetes for serving and smaller jobs. They must share storage and identity, or the two pools drift apart.

Common mistakes

  • Assuming the default scheduler handles gangs. It does not. Add Kueue, Volcano or Slurm.
  • Running multi-GPU jobs without queues and quotas. One team can take every GPU.
  • Running two schedulers with separate storage and identity. Data and access then drift apart.

Check yourself

  1. What does gang scheduling prevent? Partial starts, where some workers hold GPUs while they wait for the rest of the job.
  2. When is Slurm the better fit? When the organization is HPC-native and runs large batch jobs with fair-share queues.

Key takeaways

  • A multi-GPU training job needs all its workers at once.
  • Default Kubernetes places pods one at a time, so it can deadlock a job.
  • Kueue, Volcano and Slurm provide gang semantics. Pick based on your existing platform.

Further learning

Next, see what happens when a GPU fails mid-run in GPU failures and checkpoints.