advanced27 min studyLesson 24 in Engineering

Accelerators and scheduling

Place accelerator workloads using multidimensional resource requests, topology, fairness, and interruption costs.

On this page

What you’ll understand

  • Recognize memory, bandwidth, and placement as scheduling constraints.
  • Explain why aggregate free devices do not guarantee a schedulable job.
  • Calculate allocation efficiency while preserving fairness and recovery needs.

A cluster can show idle accelerators while a training job waits. Perhaps the job needs four linked devices on one node and every node has only two free. Perhaps device memory, CPU preprocessing, or a tenant quota is the real constraint. Scheduling translates workload requirements into an allocation over time. To judge it, measure useful completed work and waiting time alongside utilization.

Describe a workload as a resource vector

An accelerator request includes device type and count, memory needs, CPU, host memory, storage throughput, and communication expectations. Some are consumable quantities; others are compatibility constraints. A binary built for one device capability may not run on another. Kubernetes exposes accelerators through device plugins or applicable allocation mechanisms. For device-plugin GPU resources, requests and limits must match when both are set; an omitted request defaults to the limit. The scheduler does not infer a model's memory peak.

Requests guide placement and reservations; utilization is what the program actually consumes over time. Under-requesting CPU can starve data loading even when the accelerator is reserved. Over-requesting whole devices creates waste when safe partitioning would suffice, but sharing introduces memory, bandwidth, and isolation concerns. Do not assume a reported percentage of device activity is equivalent to useful arithmetic efficiency. Collect application throughput and stall information to distinguish a well-used device from a busy wait or repeated failed work.

∑jxjnrjk≤Cnkfor every node n and resource k\sum_j x_{jn}r_{jk}\le C_{nk}\quad\text{for every node }n\text{ and resource }k
xjn is 1 when job j is assigned to node n, rjk is its requested amount of resource k, and Cnk is node capacity. Every resource dimension uses matching units. This basic packing constraint omits topology, time, affinity, and shared-link interference.↔ Scroll wide equations horizontally.

Place communicating workers together deliberately

Data-parallel jobs synchronize gradients, while tensor-parallel layers may communicate several times during one forward pass. A placement that is acceptable for one can be poor for the other. Model fast interconnect groups and cross-rack links explicitly. Scheduling all necessary workers together avoids reserving three devices indefinitely while waiting for a fourth. Gang scheduling is a policy and implementation choice; simply creating several independent pods does not prove simultaneous start or topology-aware placement.

Fragmentation occurs when free resources cannot satisfy the shape of waiting requests. Eight free devices spread across four nodes are different from eight free devices within one fast group. Repacking can improve fit but interrupts running work, so evaluate checkpoint age, restart time, and queue fairness before preemption. Reserve capacity for latency-critical inference and for recovering essential services. Allowing training to occupy every available slot can make a small production failure impossible to repair quickly.

Balance fairness with productive utilization

Fairness requires a declared unit: devices, device-seconds, a weighted share, or a dominant resource share. Equal job counts are misleading when one job requests one accelerator and another requests sixty-four. Priorities, quotas, queue aging, and preemption rules should be visible to users. Backfilling a small job into an otherwise idle gap can improve utilization, provided its expected duration and interruption policy do not indefinitely delay the large job that created the gap.

Track waiting time by workload class, useful accelerator-hours, completion time, failed allocations, and work lost to preemption. A scheduler can improve reported occupancy by admitting jobs that immediately contend for the same network. Compare against workload-level objectives instead. The following allocation efficiency is an accounting metric: it penalizes reserved idle time, but it does not establish fairness, numerical efficiency, or successful completion. Use it as one diagnostic alongside those outcomes.

ηalloc=useful accelerator-secondsreserved accelerator-seconds\eta_{\mathrm{alloc}}=\frac{\text{useful accelerator-seconds}}{\text{reserved accelerator-seconds}}
Both numerator and denominator have units of device-seconds, so the ratio is dimensionless. Define useful work consistently; this lesson excludes loading and failed computation from the numerator and does not equate this ratio with hardware FLOP utilization.↔ Scroll wide equations horizontally.

Spot a placement constraint hidden by totals

Two nodes each have eight accelerators. Each currently runs a five-device job. A new job requires four devices on a single node. Assume existing jobs cannot shrink and the new job cannot span nodes.

  1. Count aggregate free capacity: each node has three free devices, giving six free devices in total.

  2. Check the actual placement constraint: the four-device job needs one node with at least four free devices. Neither node qualifies.

  3. Do not report this as a lack of total devices. It is fragmentation under the single-node constraint. The feasible options include waiting, changing the job topology if supported, or preempting an eligible existing job.

  4. If one five-device job is preempted, its node has eight free devices and the waiting job fits. Compare the discarded or checkpointed work with the benefit of earlier completion before choosing that action.

The result

Six idle devices do not imply that a four-device job can start. Schedulability depends on the shape and location of capacity.

Explore the model

Interactive lab

Interactive lab · queue

Explore a waiting-job backlog

Vary the arrival and service rates of equal-sized jobs in a fluid queue starting with four jobs. The separate M/M/1 mean assumes Poisson arrivals and exponential service. Real accelerator jobs have resource shapes and topology constraints that this scalar queue deliberately cannot represent.

Explore a waiting-job backlogFluid backlog starts at 4 and follows max(0, 4 + (λ − μ)t). The separate M/M/1 residence-time formula assumes Poisson arrivals, exponential service and λ < μ. Current readings: Fluid backlog: 4; Net rate · λ − μ: −1 /s; M/M/1 mean residence: 1 s. All parameters are adjustable with the labeled controls below.02.557.51001.534.56Elapsed time · sFluid backlogλ < μ
Fluid backlogCurrent time
Fluid backlog
4
Net rate · λ − μ
−1 /s
M/M/1 mean residence
1 s
t = 0 s

Fluid backlog starts at 4 and follows max(0, 4 + (λ − μ)t). The separate M/M/1 residence-time formula assumes Poisson arrivals, exponential service and λ < μ. Parameter changes pause playback and recompute the model at the current elapsed time. Reset restores both parameters and returns time to zero. Playback starts paused. Adjust either parameter, then choose Play or Step.

Look forQueue capacity is necessary, but a stable scalar queue does not prove that individual resource requests can be placed.

Check your understanding

A cluster has twelve free accelerators, but a job requiring eight on one node cannot start. What should you inspect first?

Try it yourself

A job reserves four accelerators for 45 minutes. Loading takes five minutes and useful computation takes 35 minutes; the final five minutes are idle before cleanup. Find allocation efficiency. Would shortening loading alone prove higher model FLOP utilization?

Take a moment to make a prediction or work it out on paper. Open a hint when you need one.

Give me a hint

Multiply both useful and reserved durations by the same device count. Separate reservation efficiency from efficiency while kernels are running.

Compare with the solution

Reserved time is 4 × 45 = 180 accelerator-minutes; useful time is 4 × 35 = 140. Allocation efficiency is 140/180 ≈ 77.8%. Faster loading can improve reservation efficiency without changing kernel-level FLOP utilization. Also verify that the useful computation produces valid results, rather than treating all busy time as productive.

Take it with you

  • Declare every resource and placement constraint that matters to the job.
  • Fragmentation and topology can strand substantial aggregate capacity.
  • Fairness and completed useful work must accompany utilization metrics.

Read further

Original sources and deeper explanations to follow at your own pace.

Optional progress, saved in this browser when available. Revisit any lesson at any time.

Lesson not marked complete.