advanced25 min studyLesson 367 in Engineering

Accelerator resource fragmentation

Separate device count, per-device memory, partition profiles, and useful compute before attempting consolidation.

On this page

What you’ll understand

  • Explain why aggregate free accelerator memory may be unusable.
  • Distinguish allocation fragmentation from runtime allocator fragmentation.
  • Evaluate consolidation and sharing against supported hardware and workload behavior.

A fleet dashboard reports 24 GiB of free accelerator memory, yet an inference replica needing 20 GiB cannot start. The bytes may be split across devices the model cannot combine. Meanwhile another GPU can be fully allocated but spend much of its time waiting for inputs. Accelerator scheduling needs more than a device count or one utilization percentage: it needs the shape, location, and enforceable sharing contract of the available resources.

Capacity cannot always be combined

Per-device memory is a hard boundary for a workload that requires one device unless the application supports an appropriate distribution or offload mechanism. Adding the free bytes on unrelated GPUs does not create one larger allocation. Partitioned devices introduce supported profiles and placement geometry that depend on the hardware and driver stack. A total-memory test can pass while no compatible partition profile exists. Treat device type, profile, and topology as part of the request rather than assuming all fractional capacity is freely divisible.

Distinguish scheduler-level fragmentation from fragmentation inside a process’s memory allocator. The scheduler may see whole devices or resource claims, while a runtime sees allocations and reusable blocks within its assigned memory. A workload can fail from activation or temporary-workspace peaks even when model weights fit. Conversely, releasing a process’s unused cache may not return a scheduler-visible device allocation. Diagnose which layer owns the unusable capacity before trying a remedy that changes a different layer’s accounting.

∑ifi≥m⟹̸max⁡ifi≥m\sum_i f_i\geq m\quad\not\Longrightarrow\quad\max_i f_i\geq m
Free memory f_i and a single-device requirement m use the same units. Enough aggregate memory across devices does not imply any one device has the required contiguous allocation capacity; this model omits internal allocator details.↔ Scroll wide equations horizontally.

Sharing has multiple isolation dimensions

Time-sharing, spatial partitioning, and colocating multiple processes have different memory, compute, and isolation semantics. An advertised number of accelerator units does not by itself guarantee a particular memory fraction or throughput. Check the device-allocation API and runtime contract, including which resource quantities are enforced. Host CPU, input-pipeline throughput, and network communication can also dominate observed device activity. Avoid labeling every low compute-utilization sample as reclaimable accelerator capacity without inspecting memory residency and synchronization.

Gandiva explores profiling and runtime-aware scheduling for deep learning, including migration and sharing decisions. Its useful lesson here is to measure job behavior and movement costs rather than infer them from requested GPU count alone. Workloads can change phase, and a profile from one batch size or input length may not apply to another. Sharing training with latency-sensitive inference also requires tail-latency and interference measurements. A placement that raises average device activity can still reduce useful work or violate service objectives.

Tmove≥SBeffT_{\mathrm{move}}\geq\frac{S}{B_{\mathrm{eff}}}
Moving S bytes of required model or runtime state through an effective B_eff bytes-per-second bottleneck has this ideal lower bound in seconds. Checkpoint consistency, startup, synchronization, and shared-link contention add cost; this is not a migration latency prediction.↔ Scroll wide equations horizontally.

Defragment without hiding the disruption cost

Consolidation can create larger free device groups, but it may require stopping, checkpointing, migrating, or restarting workloads. Confirm that the resulting shape satisfies the waiting jobs and that the cost is worthwhile over the expected remaining run. Track stranded capacity by requested shape and compatible device class. A global free-memory percentage hides whether the pending queue needs one large device, a linked group, or many small independent instances. Changing the queue’s workload mix can alter fragmentation without changing installed capacity.

The vector lab isolates aggregate versus per-device free memory. Reset, set angle to 45 degrees and magnitude to 1, predict both components and their sum, then Step. Interpret the components as free memory on two devices in normalized units and require one full unit on a single device. For a fresh comparison, Reset and explicitly set angle to 0 degrees and magnitude to 1, predict the maximum component, then Step. This draws two numeric projections only, not GPU memory, partitions, or a consolidation algorithm.

Free memory on the wrong devices

Two eligible GPUs each have 12 GiB free. A replica needs 20 GiB on one GPU and does not support model parallelism or offload. A later consolidation releases enough memory for the first GPU to have 24 GiB free; ignore internal allocator constraints.

  1. Initially aggregate free memory is 12 + 12 = 24 GiB, but the largest eligible single-device amount is only 12 GiB. The 20-GiB replica cannot fit.

  2. After consolidation, 24 GiB on one eligible GPU exceeds the 20-GiB requirement and leaves four GiB of memory headroom under this simplified check.

  3. The consolidation is useful only if its disruption and movement costs are acceptable and all other resources fit. It did not increase the total installed memory or automatically make arbitrary device profiles compatible.

The result

Resource location and shape determine usefulness. An aggregate 24-GiB number is insufficient to establish single-device feasibility.

Explore the model

Interactive lab

Interactive lab · vectors

Summed memory is not one device’s memory

Reset, set angle = 45° and magnitude = 1, predict each component and their sum, then Step. Compare a new Reset with both angle = 0° and magnitude = 1. Treat projections as two normalized free-memory amounts; no GPU allocation or consolidation is simulated.

Summed memory is not one device’s memoryPlayback traces a fixed vector and its projections. Angle and magnitude set the geometry; the moving marker does not change them. Current readings: x component: 1.393; y component: 0.975; Magnitude: 1.7. All parameters are adjustable with the labeled controls below.−7.46−3.7303.737.46−3.5−1.7501.753.5xyvvₓ = 1.39
Vectorx / y projectionsTrace marker
x component
1.393
y component
0.975
Magnitude
1.7
t = 0 s

Playback traces a fixed vector and its projections. Angle and magnitude set the geometry; the moving marker does not change them. 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 forA sum above one can coexist with every individual device below a one-unit requirement.

Check your understanding

Two GPUs each have 10 GiB free, and a model requires 16 GiB on one device without supported distribution. What follows from the memory quantities alone?

Try it yourself

A consolidation must move 30 GB of decimal state through an effective 10 GB/s path. Calculate the ideal movement lower bound. If the expected remaining useful run is only two seconds, what does that comparison suggest, and what must still be measured?

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

Give me a hint

Compare durations while keeping the movement bound distinct from actual migration time.

Compare with the solution

The lower bound is 30/10 = three seconds, already longer than the two-second remaining run. That suggests this consolidation may not amortize its cost for this job, although benefits to other jobs could matter. Measure actual movement, pause and restart time, contention, consistency requirements, and the value of the newly feasible placement before making the decision.

Take it with you

  • Aggregate memory and device count do not establish per-device or profile feasibility.
  • Scheduler allocations and process allocator fragmentation belong to different layers.
  • Profiling and consolidation need interference, consistency, and disruption-cost evidence.

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.