AI Job Orchestration II: Kubernetes, NVIDIA GPU Operator, and Volcano / Kueue
Why vanilla Kubernetes deadlocks distributed GPU training—and how NVIDIA GPU Operator, Volcano, and Kueue unlock atomic gang scheduling at scale.

Series: Part 23 of GPU Architecture, Scale-Up Interconnects, and AI Datacenter Infrastructure Series | (Previous) AI Job Orchestration I: Slurm for Large-Scale Distributed Training
Summary
In Part 22, we saw why Slurm remains the gold standard for single-tenant, bare-metal supercomputers. Yet modern hyperscalers and AI enterprises rarely run training in a vacuum: they need a single, elastic control plane capable of running multi-node pretraining overnight, serving real-time LLM inference during peak traffic, and orchestrating data preprocessing pipelines on the exact same fleet of H100 and Blackwell nodes. Kubernetes was built for that cloud-native elasticity—but out of the box, vanilla Kubernetes is blind to GPU silicon topology and actively hostile to distributed deep learning.
This post dissects the two architectural layers required to turn Kubernetes into a production AI supercomputer:
- Node-Level Hardware Automation: How the NVIDIA GPU Operator, Network Operator, Multi-Instance GPU (MIG) partitioning, Dynamic Resource Allocation (DRA), and DCGM Exporter automate kernel drivers, CUDA runtime injection, GPUDirect RDMA NICs, and hardware telemetry without touching the host OS.
- Cluster-Level Gang Scheduling & Multi-Tenant Queueing: Why Kubernetes’ default pod-by-pod
kube-schedulertriggers catastrophic resource deadlocks that strand tens of thousands of dollars in idle GPUs, and how Kueue (cluster-wide admission, quotas, and cohort borrowing) pairs with Volcano (PodGroupatomic coscheduling and topology-aware placement) to eliminate deadlocks entirely.
To prove the impact quantitatively, we conclude with a zero-dependency Python 3 cluster simulator comparing vanilla kube-scheduler against a Volcano + Kueue stack across 64 concurrent multi-node training jobs on a 128-GPU cluster.
Prior Reading Material
To get the most out of this deep dive, we recommend reviewing these foundational posts from the series:
- AI Job Orchestration I: Slurm for Large-Scale Distributed Training: Contrasts HPC bare-metal scheduling, static node allocations, and Slurm’s gang-native design against cloud-native orchestration.
- Scale-Up Interconnects: NVLink, NVSwitch, and Ultra-High-Bandwidth Node Fabrics: Explains why keeping distributed workers inside the same NVLink domain is critical for tensor parallelism and why topology-blind schedulers destroy throughput.
- Scale-Out Networking I: InfiniBand NDR/XDR, Quantum Switches, and In-Network Computing: Details the GPUDirect RDMA fabrics that the NVIDIA Network Operator must expose directly into Kubernetes pods.
- Rack-Scale Supercomputing: NVL72, Unified Memory Domains, and Liquid Cooling Architecture: Covers multi-node GB200 NVL72 domains that require Kubernetes Dynamic Resource Allocation (DRA) and IMEX domain scheduling.
Bridging Cloud-Native and AI: Why Kubernetes, and Where Vanilla K8s Breaks
If Slurm already solves HPC job scheduling so cleanly, why are AI labs, cloud providers, and Fortune 500 engineering organizations investing heavily in Kubernetes for GPU orchestration?
The answer is fleet fungibility. A modern AI platform does not just run static 1,024-GPU pretraining jobs for six weeks straight. It runs a dynamic mix of:
- Latency-sensitive LLM inference (such as vLLM and llm-d deployments that autoscale based on token-per-second load and KV-cache pressure).
- Post-training, RLHF, and evaluation pipelines that spin up bursty 16-GPU to 64-GPU jobs on demand.
- CPU-heavy ETL, tokenization, and vector indexing alongside GPU workloads.
- Multi-tenant isolation with RBAC, namespaces, declarative GitOps, container image immutability, and automated self-healing when a node drops off the network.
Kubernetes excels at stateless microservices because microservices are loosely coupled. If a web service asks for 10 replicas and the cluster only has room for 7 right now, scheduling those 7 pods immediately is a win—they start serving 70% of your HTTP traffic right away.
Distributed deep learning violates every assumption behind that microservice model. When you launch a 64-GPU PyTorch DistributedDataParallel (DDP) or FSDP training job via the Kubeflow Training Operator, all 8 worker pods (each holding 8 GPUs) must execute an all-reduce synchronization barrier over NCCL before the very first forward pass can begin. If 7 pods are Running and the 8th pod is stuck Pending, you do not get 87.5% training throughput. You get 0% throughput, while 56 expensive GPUs sit pinned at 0% SM utilization waiting for a peer that never arrives.
flowchart TD
A["1. Engineer submits PyTorchJob / JobSet (suspend: true)"] --> B["2. Kueue LocalQueue routes workload to ClusterQueue"]
B --> C["3. Kueue verifies full GPU quota & cohort borrowing"]
C --> D["4. Kueue admits job atomically (flips suspend: false)"]
D --> E["5. Volcano PodGroup binds all worker pods simultaneously"]
E --> F["6. GPU Operator & Network Operator inject GPUs + RDMA NICs"]
F --> G["7. All workers pass NCCL rendezvous & train at full goodput"]
G --> H["8. Job completes; Kueue releases quota for next queued job"]
style A fill:#0d2b45,stroke:#38bdf8,stroke-width:2px,color:#ffffff
style B fill:#1a1f4a,stroke:#818cf8,stroke-width:2px,color:#ffffff
style C fill:#24194a,stroke:#a78bfa,stroke-width:2px,color:#ffffff
style D fill:#163042,stroke:#22d3ee,stroke-width:2px,color:#ffffff
style E fill:#0f3438,stroke:#2dd4bf,stroke-width:2px,color:#ffffff
style F fill:#0f382c,stroke:#34d399,stroke-width:2px,color:#ffffff
style G fill:#0c3b2e,stroke:#10b981,stroke-width:2px,color:#ffffff
style H fill:#1e293b,stroke:#94a3b8,stroke-width:2px,color:#ffffff
Figure 1: End-to-end lifecycle of a distributed AI training job on an enterprise Kubernetes cluster powered by Kueue, Volcano, and the NVIDIA GPU Operator.
To bridge this gap, we first have to teach Kubernetes how to manage GPU silicon and RDMA networking at the node level—and then replace its scheduling philosophy at the cluster level.
Under the Hood: NVIDIA GPU Operator, MIG, DRA, and Network Operator
Managing GPU software on bare-metal Linux servers is notoriously fragile. Every node needs an exact match between the host kernel headers, the NVIDIA kernel driver (nvidia.ko), the GPUDirect RDMA peer memory module (nvidia-peermem), the container runtime hooks, and hardware telemetry agents. Maintaining that stack manually via Ansible or golden VM images across hundreds of nodes turns every driver upgrade into a multi-day maintenance outage.
The NVIDIA GPU Operator eliminates host-level drift by treating the entire GPU software stack as declarative Kubernetes DaemonSets orchestrated through a single ClusterPolicy custom resource.
Figure 2: Inside an AI-Ready Kubernetes Node — How the NVIDIA GPU Operator, Network Operator, MIG Manager, and DCGM Exporter stack vertically to turn bare-metal GPU servers into multi-tenant cloud-native compute. Source: Adapted from NVIDIA GPU Operator & Network Operator Architecture Documentation.
Let’s walk up the five layers shown in Figure 2 to see what actually happens when a fresh GPU server joins the cluster:
1. Node Feature Discovery (NFD) & Containerized Kernel Drivers
As soon as a node registers, Node Feature Discovery (NFD) scans its PCIe bus, detects NVIDIA PCI vendor IDs, and automatically stamps Kubernetes node labels (GPU architecture, VRAM capacity, CUDA compute capability, and PCIe generation). Matching those labels, the GPU Operator deploys the Driver DaemonSet, which compiles or loads pre-compiled nvidia.ko and nvidia-peermem kernel modules from inside a privileged container—keeping the underlying host OS completely clean and enabling rolling driver upgrades via standard Kubernetes updates. (For a deeper look at how the host driver interacts with CUDA streams and graphs, see The CUDA Revolution III.)
2. Container Runtime & NVIDIA Container Toolkit (CDI)
Standard containerd only knows how to isolate CPU, RAM, and Linux namespaces; it has no idea how to expose a GPU. The NVIDIA Container Toolkit DaemonSet configures containerd using the Container Device Interface (CDI) specification. When a pod starts, the toolkit dynamically injects only the assigned /dev/nvidia* device nodes and mounts the host’s user-space CUDA driver libraries into the container. That way, researchers can build portable Docker images containing PyTorch and CUDA runtime libraries without ever baking brittle host drivers into their containers.
3. Device Plugin, MIG Partitioning, and Dynamic Resource Allocation (DRA)
Once the driver and runtime are live, the NVIDIA Device Plugin reports allocatable nvidia.com/gpu integers to kubelet. However, integer GPU counts break down in two opposite directions:
- Too coarse for small workloads (MIG): Giving an entire 80 GB H100 to a lightweight embedding model or Jupyter notebook wastes 90% of the silicon. The GPU Operator’s MIG Manager automates Multi-Instance GPU (MIG) hardware partitioning, carving a single physical GPU into up to seven isolated hardware slices (such as
1g.10gbor3g.40gb), each with dedicated Streaming Multiprocessors, L2 cache, and HBM memory bandwidth. Unlike software time-slicing—where noisy neighbors can stall each other’s kernels—MIG enforces true hardware-level fault and memory isolation. - Too blind for rack-scale topologies (DRA): Classic Device Plugins treat GPUs as interchangeable counters. They cannot express “give this pod 4 GPUs on the same PCIe root complex” or “provision an IMEX (Internode Memory Exchange) channel across a 72-GPU GB200 NVL72 domain.” Kubernetes Dynamic Resource Allocation (DRA) replaces integer counters with structured
ResourceClaimandDeviceClassobjects, allowing the NVIDIA DRA driver to advertise rich hardware attributes (NVLink switch domain, MIG profile, memory bandwidth) directly to the scheduler.
4. Network Operator (GPUDirect RDMA) & DCGM Telemetry
Fast GPUs starve without fast networking. Paired with the GPU Operator, the NVIDIA Network Operator automates OFED drivers, SR-IOV device plugins, and Multus CNI secondary network interfaces. Instead of routing NCCL gradient exchanges through slow kernel TCP/IP bridges, pods receive dedicated virtual or physical InfiniBand or RoCEv2 NICs with direct GPUDirect RDMA access into GPU HBM.
Simultaneously, the DCGM Exporter DaemonSet scrapes low-level hardware telemetry—SM occupancy, Tensor Core utilization, HBM bandwidth, NVLink throughput, ECC memory errors, and fatal Xid faults—exposing them to Prometheus. Combined with Node Problem Detector, clusters can automatically cordon and drain a node the instant an uncorrectable Xid error or dropped NVLink lane appears, preventing silent training hangs.
The Gang Scheduling Deadlock Problem
With the GPU Operator and Network Operator installed, our nodes can now run CUDA and RDMA at bare-metal speed. So what happens when we let Kubernetes’ default kube-scheduler orchestrate a busy, multi-tenant training cluster?
Disaster.
Because kube-scheduler schedules one pod at a time, it has zero concept of a multi-pod job. Imagine a simplified 8-GPU cluster (or an 8-node, 64-GPU cluster—the exact same math scales up) that receives two simultaneous distributed training submissions: Job A needs 6 GPUs, and Job B needs 6 GPUs.
- Both controllers create 6
Pendingpods in the Kubernetes API server. kube-schedulerpicks pods off its scheduling queue one by one—often interleaving pods from Job A and Job B.- Job A gets bound to GPUs 0, 1, 2, and 3. Job B gets bound to GPUs 4, 5, 6, and 7.
- All 8 GPUs are now 100% allocated. Job A still has 2 pods stuck
Pending. Job B still has 2 pods stuckPending. - Neither job can complete its NCCL initialization barrier. Both jobs hang indefinitely.
Figure 3: Pod-by-Pod Scheduling Deadlock vs. Atomic Gang Scheduling — Why vanilla kube-scheduler strands 100% of a cluster in partial allocations, and how Volcano PodGroup + Kueue admission eliminate deadlocks.
This is a textbook circular-wait resource deadlock. Your Prometheus dashboard shows 100% GPU allocation, making the cluster look completely full, while your DCGM Exporter shows 0% SM utilization. On an H100 or Blackwell cluster costing roughly $3.00 to $4.00 per GPU-hour, a single deadlocked 128-GPU cluster burns over $400 every single hour doing nothing except waiting for a human operator—or a crude activeDeadlineSeconds timeout—to kill one of the jobs.
Even when a deadlock does not lock 100% of the cluster, pod-by-pod scheduling causes large-job starvation: whenever a 64-GPU pretraining job waits for 8 full nodes to become free, smaller 8-GPU evaluation pods constantly slip into every newly freed node, starving the flagship pretraining run indefinitely.
Volcano & Kueue Deep Dive: Solving Gang Scheduling and Multi-Tenant Queueing
To fix both resource deadlocks and multi-tenant starvation, the Kubernetes AI ecosystem converged on two complementary CNCF / Kubernetes-SIG projects: Volcano and Kueue. Understanding the boundary between them is the key to architecting a rock-solid AI platform.
Volcano: Atomic PodGroup Coscheduling & Topology Awareness
Volcano is a battle-tested batch scheduling engine that replaces or runs alongside kube-scheduler. Its foundational primitive is the PodGroup custom resource.
Instead of evaluating pods in isolation, Volcano wraps all worker pods of a distributed training job into a single PodGroup with a minMember threshold (for example, minMember: 8 for an 8-node, 64-GPU PyTorchJob). During each scheduling cycle, Volcano runs a pluggable pipeline of actions (enqueue, allocate, backfill, preempt) and plugins (gang, drf for Dominant Resource Fairness, binpack, and network-topology):
- All-or-Nothing Atomic Binding: If only 6 of the 8 required nodes are available, Volcano refuses to bind any pod in the
PodGroup. All 8 pods remain unbound until all 8 nodes can be reserved atomically in the same cycle—making partial-allocation deadlocks mathematically impossible. - Topology-Aware Placement: Volcano’s topology plugins understand hierarchical datacenter labels (NVLink domain -> leaf switch -> spine switch), packing all pods of a
PodGrouponto the same InfiniBand or RoCEv2 leaf switch to minimize cross-spine hops during collective all-reduce traffic.
Kueue: Job-Level Admission Gating, Quotas, and Cohort Borrowing
While Volcano operates at the pod placement layer, Kueue (a Kubernetes SIG-Scheduling project) operates one level higher as a job-level queueing and admission controller.
Instead of letting hundreds of submitted jobs flood the Kubernetes API server with thousands of Pending pods, Kueue intercepts jobs at creation time and holds them with suspend: true. Zero pods are created while a job waits in line. Kueue organizes cluster capacity through three clean abstractions:
LocalQueue(Namespace-Scoped): Each engineering team (e.g.,pretraining,post-training,evals) submits itsPyTorchJob,JobSet, orRayJobto its own namespaceLocalQueue.ClusterQueue&ResourceFlavor(Cluster-Scoped): Maps logical quotas to physical hardware flavors (h100-sxm5,gb200-nvl72,l40s-inference). EachClusterQueuedefines a guaranteed nominal quota and optional borrowing/lending limits.- Cohorts & Preemption: Multiple
ClusterQueues belonging to the same Cohort can elastically borrow each other’s idle GPUs. If the Pretraining team is idle overnight, the Post-Training team can automatically burst beyond its nominal quota to consume the spare H100s. The moment Pretraining submits a high-priority run in the morning, Kueue gracefully preempts the borrowed workloads (allowing them to save a checkpoint and re-queue) and hands the GPUs back to their owner.
Figure 4: The Two-Tier Kubernetes AI Orchestration Stack — Separating cluster-level multi-tenant queueing (Kueue) from node-level atomic gang placement and topology awareness (Volcano). Source: Adapted from Kubernetes SIG-Scheduling (Kueue) & CNCF Volcano Documentation.
When to Combine Kueue + Volcano
In production clusters beyond 64–128 GPUs, platform teams increasingly deploy both in a two-tier architecture (Figure 4):
| Capability | Default kube-scheduler | Volcano Alone | Kueue Alone | Kueue + Volcano (Recommended) |
|---|---|---|---|---|
| Pod-Level Atomic Gang Binding | No (Pod-by-Pod) | Yes (PodGroup) | Partial (via Admission) | Yes (PodGroup + Admission) |
Zero Pending Pod Storms (suspend: true) | No | No | Yes | Yes |
| Multi-Tenant Cohort Borrowing & Preemption | No | Basic Queue Weights | Full Native Support | Full Native Support |
Heterogeneous GPU ResourceFlavor Routing | Manual NodeSelectors | Manual | Native Flavor Fallback | Native Flavor Fallback |
| NVLink / Leaf-Switch Topology Packing | Limited | Native Plugins | Topology-Aware Scheduling (TAS) | Full End-to-End Topology Packing |
Kueue acts as the cluster bouncer—protecting etcd from Pending pod storms, enforcing fair-share cohorts, and deciding which job gets admitted next. Once Kueue flips suspend: false, Volcano (or Kubernetes scheduler-plugins coscheduling) acts as the floor manager, binding all worker pods atomically onto the tightest physical NVLink and leaf-switch topology.
Quantitative Simulation: Default kube-scheduler vs. Volcano + Kueue
To see how quickly pod-by-pod scheduling collapses under realistic multi-tenant load, we built a deterministic, zero-dependency Python 3 simulator (scripts/k8s_gang_scheduling_sim.py).
Simulation Setup
- Cluster: 16 HGX nodes × 8 GPUs per node = 128 GPUs total, simulated across a 120-hour (5-day) operating window (
15,360total cluster GPU-hours). - Workload: 64 concurrent distributed training jobs drawn from four realistic profiles: 64-GPU pretraining runs (8 nodes), 32-GPU RLHF runs (4 nodes), 16-GPU fine-tuning runs (2 nodes), and 8-GPU evaluation runs (1 node).
- Deadlock Watchdog: To be generous to vanilla
kube-scheduler, we even gave it an automated 2-hour watchdog timeout that evicts stuck partial allocations so the cluster does not stay frozen for all 120 hours. - Cost Baseline: Illustrative cloud GPU cost of $3.00 per GPU-hour.
Verified Simulation Results
| Metric (128-GPU Cluster, 120h Window) | Default kube-scheduler (Pod-by-Pod) | Volcano + Kueue (Atomic Gang) | Engineering Impact |
|---|---|---|---|
| Total Jobs Completed | 8 / 64 (12.5%) | 64 / 64 (100.0%) | 8.0× higher job throughput |
| 64-GPU Pretraining Jobs Completed | 1 / 11 (10 starved) | 11 / 11 (100.0%) | Eliminates large-job starvation |
| Productive GPU-Hours (Goodput) | 1,096.0 hrs (7.1%) | 9,362.0 hrs (61.0%) | 8.5× more actual training work |
| Stranded GPU-Hours (Deadlocked) | 12,352.0 hrs (80.4%) | 0.0 hrs (0.0%) | 100% elimination of stranded GPUs |
| Deadlock Eviction Events | 703 evictions (115.75h deadlocked) | 0 evictions (0.00h) | Zero thrashing or lost checkpoints |
| Mean Queue Wait (Started Jobs) | 2.91 hrs (only 8 started) | 18.95 hrs (all 64 finished) | Predictable, bounded queueing |
| Stranded Cloud GPU Spend ($3/GPU-hr) | $37,056 wasted | $0 wasted | $37,056 saved in just 5 days |
Look closely at those numbers: under default kube-scheduler, 80.4% of the entire cluster’s GPU capacity (12,352 GPU-hours) was burned sitting in partial allocations waiting at the NCCL barrier—even with a 2-hour watchdog constantly evicting stuck pods! Only 1 of the 11 flagship 64-GPU pretraining jobs ever started (the very first one before contention hit); the other 10 starved completely.
Switching the exact same job arrival trace to Volcano + Kueue atomic gang scheduling dropped stranded GPU-hours from 12,352.0 to 0.0, completed all 64 jobs (including all 11 64-GPU runs), and saved $37,056 in wasted GPU spend over a single 5-day window on a modest 128-GPU cluster. Scale that to a 2,048-GPU cluster, and gang scheduling is the difference between a functional AI lab and half a million dollars a week evaporating into Pending pods.
Click to expand runnable code script
Save as scripts/k8s_gang_scheduling_sim.py and run with python3 scripts/k8s_gang_scheduling_sim.py (standard library only, zero external packages required):
#!/usr/bin/env python3
"""
Kubernetes AI Job Orchestration Simulator:
Default kube-scheduler (Pod-by-Pod) vs. Volcano/Kueue Gang Scheduling.
Zero external dependencies (Python 3 standard library only).
Models a 16-node, 128-GPU cluster (8 GPUs/node) running concurrent
multi-node distributed training jobs (8, 16, 32, and 64 GPUs).
"""
from dataclasses import dataclass
import random
from typing import Dict, List, Optional
CLUSTER_NODES = 16
GPUS_PER_NODE = 8
TOTAL_GPUS = CLUSTER_NODES * GPUS_PER_NODE
SIM_HOURS = 120.0
DT = 0.25 # 15-minute simulation tick (in hours)
WATCHDOG_TIMEOUT_HOURS = 2.0 # Timeout before watchdog evicts deadlocked partial pods
GPU_HOURLY_COST_USD = 3.00 # Illustrative H100/B200 cloud GPU-hour cost
@dataclass
class JobSpec:
job_id: int
submit_time: float
nodes_required: int
runtime_hours: float
tenant: str
@property
def gpus_required(self) -> int:
return self.nodes_required * GPUS_PER_NODE
@dataclass
class JobState:
spec: JobSpec
allocated_nodes: int = 0
first_alloc_time: Optional[float] = None
start_time: Optional[float] = None
finish_time: Optional[float] = None
status: str = "queued" # queued, partial, running, completed
evictions: int = 0
def generate_workload(seed: int = 42, num_jobs: int = 64) -> List[JobSpec]:
"""Generate a deterministic multi-tenant distributed training workload."""
rng = random.Random(seed)
profiles = [
(8, 6.0, 10.0, 0.20, "pretraining-64gpu"),
(4, 3.0, 6.0, 0.25, "rlhf-32gpu"),
(2, 1.5, 4.0, 0.30, "finetune-16gpu"),
(1, 0.75, 2.5, 0.25, "eval-8gpu"),
]
weights = [p[3] for p in profiles]
jobs: List[JobSpec] = []
t = 0.0
for i in range(1, num_jobs + 1):
t += rng.choice([0.0, 0.25, 0.5, 0.75, 1.0, 1.5])
if t > SIM_HOURS - 12.0:
t = rng.uniform(0.0, SIM_HOURS - 16.0)
nodes, lo, hi, _, tenant = rng.choices(profiles, weights=weights, k=1)[0]
runtime = round(rng.uniform(lo, hi) * 4) / 4.0
jobs.append(
JobSpec(
job_id=i,
submit_time=round(t * 4) / 4.0,
nodes_required=nodes,
runtime_hours=runtime,
tenant=tenant,
)
)
jobs.sort(key=lambda j: (j.submit_time, j.job_id))
return jobs
def simulate_vanilla_kube_scheduler(workload: List[JobSpec]) -> Dict[str, float]:
"""
Simulate default kube-scheduler (pod-by-pod binding, no gang awareness).
Pods grab free nodes one by one; jobs cannot start training until all
required nodes are bound simultaneously (NCCL rendezvous barrier).
"""
states = [JobState(spec=j) for j in workload]
free_nodes = CLUSTER_NODES
productive_gpu_hours = 0.0
stranded_gpu_hours = 0.0
deadlock_evictions = 0
deadlock_ticks = 0
t = 0.0
while t < SIM_HOURS:
for st in states:
if st.status == "running" and st.start_time is not None:
if t >= st.start_time + st.spec.runtime_hours:
st.status = "completed"
st.finish_time = t
free_nodes += st.allocated_nodes
st.allocated_nodes = 0
eligible = [
st for st in states
if st.spec.submit_time <= t and st.status in ("queued", "partial")
]
while free_nodes > 0 and eligible:
progressed = False
for st in list(eligible):
if free_nodes == 0:
break
needed = st.spec.nodes_required - st.allocated_nodes
if needed > 0:
st.allocated_nodes += 1
free_nodes -= 1
progressed = True
if st.first_alloc_time is None:
st.first_alloc_time = t
if st.allocated_nodes == st.spec.nodes_required:
st.status = "running"
st.start_time = t
eligible.remove(st)
else:
st.status = "partial"
if not progressed:
break
partial_jobs = [st for st in states if st.status == "partial"]
if partial_jobs and free_nodes == 0:
deadlock_ticks += 1
for st in partial_jobs:
if st.first_alloc_time is not None and (t - st.first_alloc_time) >= WATCHDOG_TIMEOUT_HOURS:
free_nodes += st.allocated_nodes
st.allocated_nodes = 0
st.first_alloc_time = None
st.status = "queued"
st.evictions += 1
deadlock_evictions += 1
for st in states:
if st.status == "running":
productive_gpu_hours += st.allocated_nodes * GPUS_PER_NODE * DT
elif st.status == "partial":
stranded_gpu_hours += st.allocated_nodes * GPUS_PER_NODE * DT
t = round(t + DT, 4)
return summarize_results("Default kube-scheduler (Pod-by-Pod)", states, productive_gpu_hours, stranded_gpu_hours, deadlock_evictions, deadlock_ticks)
def simulate_volcano_kueue_gang(workload: List[JobSpec]) -> Dict[str, float]:
"""
Simulate Kueue (ClusterQueue admission with head-of-line reservation)
+ Volcano (PodGroup atomic all-or-nothing coscheduling).
"""
states = [JobState(spec=j) for j in workload]
free_nodes = CLUSTER_NODES
productive_gpu_hours = 0.0
stranded_gpu_hours = 0.0
t = 0.0
while t < SIM_HOURS:
for st in states:
if st.status == "running" and st.start_time is not None:
if t >= st.start_time + st.spec.runtime_hours:
st.status = "completed"
st.finish_time = t
free_nodes += st.allocated_nodes
st.allocated_nodes = 0
queued = [
st for st in states
if st.spec.submit_time <= t and st.status == "queued"
]
if queued:
head = queued[0]
head_wait = t - head.spec.submit_time
for st in queued:
if free_nodes >= st.spec.nodes_required:
if st is not head and head.spec.nodes_required >= 4 and head_wait >= 2.0:
continue
st.allocated_nodes = st.spec.nodes_required
free_nodes -= st.spec.nodes_required
st.status = "running"
st.start_time = t
for st in states:
if st.status == "running":
productive_gpu_hours += st.allocated_nodes * GPUS_PER_NODE * DT
t = round(t + DT, 4)
return summarize_results("Volcano + Kueue (Atomic Gang)", states, productive_gpu_hours, stranded_gpu_hours, 0, 0)
def summarize_results(
name: str,
states: List[JobState],
productive_gpu_hours: float,
stranded_gpu_hours: float,
deadlock_evictions: int,
deadlock_ticks: int,
) -> Dict[str, float]:
total_cluster_gpu_hours = TOTAL_GPUS * SIM_HOURS
completed = [st for st in states if st.status == "completed"]
large_jobs = [st for st in states if st.spec.nodes_required == 8]
large_completed = [st for st in large_jobs if st.status == "completed"]
waits = [
(st.start_time - st.spec.submit_time)
for st in states
if st.start_time is not None
]
large_waits = [
(st.start_time - st.spec.submit_time)
for st in large_jobs
if st.start_time is not None
]
return {
"name": name,
"jobs_submitted": len(states),
"jobs_completed": len(completed),
"large_jobs_total": len(large_jobs),
"large_jobs_completed": len(large_completed),
"productive_gpu_hours": round(productive_gpu_hours, 1),
"stranded_gpu_hours": round(stranded_gpu_hours, 1),
"goodput_pct": round(100.0 * productive_gpu_hours / total_cluster_gpu_hours, 1),
"stranded_pct": round(100.0 * stranded_gpu_hours / total_cluster_gpu_hours, 1),
"deadlock_evictions": deadlock_evictions,
"deadlock_hours": round(deadlock_ticks * DT, 2),
"mean_wait_hours": round(sum(waits) / len(waits), 2) if waits else 0.0,
"large_mean_wait_hours": round(sum(large_waits) / len(large_waits), 2) if large_waits else 0.0,
"wasted_spend_usd": round(stranded_gpu_hours * GPU_HOURLY_COST_USD, 0),
}
def main() -> None:
workload = generate_workload(seed=42, num_jobs=64)
vanilla = simulate_vanilla_kube_scheduler(workload)
gang = simulate_volcano_kueue_gang(workload)
print(f"Cluster: {CLUSTER_NODES} nodes x {GPUS_PER_NODE} GPUs = {TOTAL_GPUS} GPUs | Horizon: {SIM_HOURS:.0f}h")
print(f"Workload: {len(workload)} distributed training jobs (8, 16, 32, and 64 GPUs)\n")
for res in (vanilla, gang):
print(f"=== {res['name']} ===")
print(f" Jobs Completed: {res['jobs_completed']} / {res['jobs_submitted']}")
print(f" 64-GPU Jobs Completed: {res['large_jobs_completed']} / {res['large_jobs_total']}")
print(f" Productive GPU-Hours: {res['productive_gpu_hours']:.1f} ({res['goodput_pct']:.1f}% cluster goodput)")
print(f" Stranded GPU-Hours: {res['stranded_gpu_hours']:.1f} ({res['stranded_pct']:.1f}% of cluster capacity)")
print(f" Deadlock Eviction Events: {res['deadlock_evictions']} (cluster deadlocked for {res['deadlock_hours']:.2f}h)")
print(f" Mean Queue Wait (All): {res['mean_wait_hours']:.2f}h")
print(f" Mean Queue Wait (64-GPU): {res['large_mean_wait_hours']:.2f}h")
print(f" Stranded Cloud GPU Spend: ${res['wasted_spend_usd']:,.0f} (at ${GPU_HOURLY_COST_USD:.2f}/GPU-hr)\n")
if __name__ == "__main__":
main()
Frequently Asked Questions
1. Can I just use Kueue without Volcano for gang scheduling?
Answer
Kueue handles job-level admission—meaning it will not unsuspend a workload until the cluster's logical ClusterQueue quota has enough free GPUs for the entire job. In a clean cluster with homogeneous, healthy nodes, Kueue alone prevents most deadlocks. However, Kueue does not replace pod-to-node binding: if cluster fragmentation, node taints, or sudden hardware failures prevent one pod from binding after admission, pairing Kueue with Volcano (or Kubernetes scheduler-plugins coscheduling) guarantees strict atomic pod placement and topology-aware packing onto the same NVLink or InfiniBand leaf switch.
2. When should I use MIG hardware partitioning versus GPU time-slicing?
Answer
Use MIG (Multi-Instance GPU) in production whenever multiple tenants share a physical H100, H200, or Blackwell GPU for inference or small fine-tuning jobs and require predictable latency, strict HBM memory isolation, and hardware fault containment. Use time-slicing only for low-stakes development environments (such as interactive Jupyter notebooks) where developers need over-subscribed GPU access and occasional noisy-neighbor latency spikes or out-of-memory crashes are acceptable.
3. Why is Kubernetes Dynamic Resource Allocation (DRA) replacing the legacy NVIDIA Device Plugin?
Answer
The legacy Device Plugin API only exposes GPUs as opaque integer counters (nvidia.com/gpu: 4). It cannot describe multi-node NVLink fabrics, GB200 NVL72 IMEX domains, or dynamic MIG reconfiguration at pod startup. DRA introduces structured ResourceClaim and DeviceClass APIs so the scheduler can reason about exact hardware attributes, fabric topology, and multi-pod shared devices natively.
4. How does Kubernetes recover when a GPU hits a fatal Xid error mid-training?
Answer
The GPU Operator's DCGM Exporter and Node Problem Detector continuously monitor hardware health and Xid error codes. When a fatal Xid error (such as uncorrectable HBM ECC failure or NVLink drop) occurs, a node remediation controller taints and cordons the faulty node, evicts the affected pod, and triggers the training controller (such as PyTorchJob or JobSet) to relaunch the job onto a healthy replacement node from the latest asynchronous checkpoint.
What’s Next?
We now have a complete picture of how both Slurm (Part 22) and Kubernetes + GPU Operator + Volcano/Kueue (Part 23) orchestrate static, gang-scheduled GPU jobs. Yet many modern AI workflows—reinforcement learning rollouts, agentic data synthesis, hyperparameter sweeps, and heterogeneous CPU-plus-GPU pipelines—do not look like rigid static grids of identical worker pods. They are dynamic, stateful distributed Python graphs.
In Part 24: AI Job Orchestration III: KubeRay and Distributed Python Workloads, we will explore how Ray and KubeRay layer dynamic actor graphs, fractional GPU scheduling, and unified training-to-serving pipelines right on top of Kubernetes.
