advanced24 min studyLesson 540 in Engineering

Prove where a training step waits for its input

Use correlated host and device traces, controlled comparisons, and useful-work metrics to distinguish data starvation from compute, communication, and memory limits.

On this page

What you’ll understand

  • Identify input waits on the actual training critical path.
  • Design controlled input-path comparisons without silently changing the workload.
  • Bound the benefit of removing a measured wait and distinguish device-side limits.

A dashboard shows low accelerator utilization and the team increases loader workers. Training does not improve because the visible gap was a collective synchronization wait, not a missing batch. Diagnosis starts by locating the critical path in a representative step and correlating input delivery with host work, transfers, device execution, and rank synchronization. One aggregate percentage cannot distinguish those causes. The goal is to identify a specific limiting mechanism, change it under controlled conditions, and verify more useful training work per unit time.

Locate the wait before naming the cause

Collect a short representative trace after separating startup, compilation, and cache warmup from steady execution. Mark batch acquisition, preprocessing, host-to-device transfer, model work, and synchronization with consistent timing semantics. Asynchronous device launches mean a fast host function can enqueue work that finishes much later, so host durations alone are insufficient. TensorFlow's input analysis guide uses IteratorGetNext-related events to inspect whether batch acquisition waits. Event names and profiler details depend on framework version and execution mode. Interpret them within that trace instead of assuming every long step has the same cause.

Inspect each rank in synchronous training. One rank's expensive record or slow read can delay peers at a collective, making their visible wait look unrelated to input. Conversely, a ready input queue with long device memory or communication operations points elsewhere. Measure queue emptiness, decode time, remote requests, transfer overlap, and per-rank variation alongside the device timeline. Sampling and tracing impose overhead and may perturb scheduling, so compare with a lower-overhead baseline. Keep identities or safe summaries sufficient to connect slow batches with length and source without logging private training content unnecessarily.

Tstep=Tcritical input+TremainingT_{\mathrm{step}}=T_{\mathrm{critical\ input}}+T_{\mathrm{remaining}}
For this accounting, the two nonnegative times in seconds partition one observed step’s critical path. Input work already overlapped with other work is not added again; this is a diagnostic decomposition, not a claim that all pipeline stages execute serially.↔ Scroll wide equations horizontally.

Use a controlled comparison and preserve workload meaning

A bounded run using already prepared batches can test how much the input path contributes, provided shapes, dtypes, batch semantics, transfer path, and distributed execution remain comparable. Repeating one small cached batch may remove realistic memory pressure or change length distribution, so describe its limits. If the test accelerates, it supports investigating removed input work; it does not identify whether storage, decoding, collation, or transfer was responsible. Next change one stage or instrument its waits. If it does not accelerate, revisit communication, compute, memory, and measurement boundaries before adding loader capacity.

Report useful tokens or examples per second and the corresponding objective, not only allocated tokens or worker output. Skipping slow corrupt records, shortening sequences, relaxing output ordering, or freezing augmentation may improve a timing metric by changing the experiment. Validate sample multiplicities and distribution after a performance change. Compare representative cold and warm states when caches matter, and retain topology and configuration. A successful optimization should reduce the identified critical-path wait while satisfying the experiment's declared identity, visitation, masking, and restart contracts.

Smax=TstepTstep−Tcritical input,0≤Tcritical input<TstepS_{\mathrm{max}}=\frac{T_{\mathrm{step}}}{T_{\mathrm{step}}-T_{\mathrm{critical\ input}}},\qquad 0\leq T_{\mathrm{critical\ input}}<T_{\mathrm{step}}
This dimensionless ideal speedup removes only the measured nonoverlapped input component while holding the remaining path fixed. Shared-resource interactions, changed workloads, and newly exposed bottlenecks can invalidate the counterfactual or reduce the actual gain.↔ Scroll wide equations horizontally.

Distinguish data starvation from a device-side ceiling

Even with ready input, an accelerator kernel can be limited by its own memory traffic rather than arithmetic throughput. A bandwidth ceiling inside the device is different from waiting for a remote training record. Communication, launch overhead, or small kernels can also leave arithmetic units underused. Use the relevant device counters and timeline to choose the next hypothesis, and avoid translating a hardware utilization gauge directly into a loader recommendation. The tf.data framework and service papers describe pipeline resource and placement tradeoffs, but their reported systems results are not performance predictions for an unrelated model or cluster.

The roofline lab supplies a separate device-side ceiling example. For each view, Reset, set both bandwidth B=100 GB/s and operational intensity I, predict, then inspect. At I=2 FLOP/byte the synthetic roof is 200 GFLOP/s; at I=20 it is capped at 1000 GFLOP/s. Playback traces the selected roof without measuring a kernel. The model has no input queue, storage system, or rank communication and cannot diagnose starvation. Its role is to show why low arithmetic throughput can arise from a device-memory limit even when training batches are already available.

Bound the gain from a measured exposed wait

A fictional representative step takes 100 ms. A correlated trace attributes 20 ms to nonoverlapped input waiting and 80 ms to the remaining critical path. Assume removing the wait leaves all other work and semantics unchanged.

  1. The exposed input fraction is 20/100=20%. Do not add overlapped preprocessing time to this fraction again.

  2. The ideal new step time is 100−20=80 ms, yielding a speedup ceiling 100/80=1.25 times for this specific intervention.

  3. A controlled prepared-batch run can test the counterfactual, while stage measurements locate the cause. If workload shapes, transfer behavior, or rank timing change, the comparison needs qualification rather than treating 1.25 as a universal forecast.

The result

Removing the specified exposed input wait gives an ideal 1.25-times speedup under the fixed-remaining-path assumption. Further gains require addressing other measured work.

Explore the model

Interactive lab

Interactive lab · roofline

Separate a device-memory ceiling from input availability

For each view: Reset, set both B=100 GB/s and I, predict, then inspect. Compare I=2 and I=20 FLOP/byte: the synthetic ceilings are 200 and 1000 GFLOP/s. Play traces the roof only. This is not a profiler, a measured device benchmark, or a training-input simulator.

Separate a device-memory ceiling from input availabilitySynthetic roofline ceiling min(1000, B·I), in GFLOP/s, with B in decimal GB/s and I in FLOP/byte. Playback traces the roof without changing the selected kernel. This upper-bound model is not a measured throughput prediction, hardware comparison or price model. Current readings: Attainable ceiling: 640 GFLOP/s; Ridge intensity: 12.5 FLOP/byte; Ceiling regime: Memory-bound ceiling. All parameters are adjustable with the labeled controls below.Hypothetical roofline upper bound: 640 GFLOP per second at operational intensity 8 FLOP per byte and bandwidth 80 gigabytes per second.0.1110641101001000Operational intensity · FLOP/byte · log scaleCeiling · GFLOP/s · log scalePeak: 1000
Attainable ceiling / kernelBandwidth roof / traceCompute ceiling
Attainable ceiling
640 GFLOP/s
Ridge intensity
12.5 FLOP/byte
Ceiling regime
Memory-bound ceiling
t = 0 s

Synthetic roofline ceiling min(1000, B·I), in GFLOP/s, with B in decimal GB/s and I in FLOP/byte. Playback traces the roof without changing the selected kernel. This upper-bound model is not a measured throughput prediction, hardware comparison or price model. 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 forReady batches do not guarantee compute-bound kernels. Diagnose the actual critical path before assigning low arithmetic utilization to the loader.

Check your understanding

Input batches are ready, but device traces show kernels at a memory-bandwidth ceiling. Which next step best fits the evidence?

Try it yourself

A representative step takes 120 ms, with 30 ms of measured nonoverlapped input wait. Under an unchanged remaining path, compute the ideal step time and speedup if that wait disappears.

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

Give me a hint

Subtract only the exposed input portion, then compare old and new times.

Compare with the solution

The ideal step time is 90 ms and speedup 120/90=4/3≈1.33 times. This is conditional on unchanged work and remaining-path timing; an actual intervention can expose another bottleneck or change resource contention.

Take it with you

  • Correlate batch delivery with the actual host, device, and rank critical path.
  • Control workload semantics when testing input-path changes.
  • Separate exposed input waits from device compute, memory, and communication limits.

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.