This is an IntvML Pro interview question. Upgrade to Pro to unlock the full prompt, diagrams, and solution.
Tag: Infra
DL0257 MoE Inference Nondeterminism
This is an IntvML Pro interview question. Upgrade to Pro to unlock the full prompt, diagrams, and solution.
DL0252 CUDA Timing Lies
This is an IntvML Pro interview question. Upgrade to Pro to unlock the full prompt, diagrams, and solution.
DL0248 Dataloader Bottleneck Triage
Training GPUs sit at 30% utilization. Walk me through how you localize the data-pipeline bottleneck: what do you check, and in what order?

The Problem: An image team trains ResNet-50 on 8 A100s at batch 256 per GPU, reading 1.28M JPEGs from shared NFS with num_workers=4 and pin_memory=False, and every GPU reports 30% utilization with 0.32 s steps. A teammate wants to set num_workers=64, and you have to say which of the five suspects to check first and in what order.
Answer
Low utilization is a symptom, so the first check is whether the input pipeline causes it at all. Replay one batch that already sits on the GPU in a loop: if utilization jumps to about 95%, the loader is guilty, and if it stays near 30% the cause is a host sync point, a small batch, or communication. Next compare two rates, the loader’s throughput measured alone with no model and the GPU’s demand of batch size over synthetic step time, which tells you exactly how much speedup you need. Then sweep num_workers while watching CPU state, because the resource that saturates names the bottleneck. Workers pinned at 100% user CPU mean decode or augmentation is CPU-bound, workers blocked in I/O wait mean storage, and a single busy main process means collate or host-side work. Only after that do you tune the overlap plumbing (pin_memory with non_blocking copies, prefetch_factor, persistent_workers), whose signatures are periodic stalls rather than a uniform slowdown.
(1) Prove It Is The Loader: A synthetic-batch replay splits the hypothesis space in one run, separating data starvation from sync points, launch overhead, and collective communication.
(2) Measure Rates, Not Utilization: nvidia-smi utilization is the sampled fraction of time any kernel runs, not SM occupancy. Log per-step data-wait time and compare loader-only throughput with the GPU’s demand.
(3) Scale Workers To The Core Budget: Sweep num_workers and watch throughput rise linearly, then flatten. Under DDP every rank owns its own loader, so the ceiling is cores per GPU minus one, and going past it oversubscribes the CPU.
(4) Read The CPU State: 100% user CPU points to decode or augmentation, high %iowait with workers in the D state points to storage, and one saturated main process points to collate or the pin-memory thread.
(5) Break Down Per-Sample Cost: Time read, decode, augment, and collate inside one worker. JPEG decode usually dominates, so pre-resized storage, GPU decode, or shipping uint8 beats adding processes.
(6) Tune Overlap Last And Re-Measure: pin_memory, prefetch depth, and persistent workers fix stalls only after capacity matches demand, and the binding constraint moves after every fix.Mathematical Formulation:
Where:
is the per-GPU sample rate the model consumes,
is the per-GPU batch size, and
is the step time measured with a GPU-resident synthetic batch.
is the worker-limited rate, with
workers per GPU rank and
the per-sample CPU time summed over read, decode, augment, and the collate share.
is the storage-limited rate, where
is measured storage bandwidth shared by the
GPUs on the node and
is the mean bytes per sample.
is the delivered loader rate and
the implied utilization, assuming prefetching fully overlaps loading with compute so only the slowest stage matters.
is the fraction of each step spent blocked waiting for the next batch, with
when the loader is the bottleneck.
Worked Triage Example (8 GPUs, 64 cores, NFS at 2.5 GB/s):
The synthetic replay runs a step in 0.10 s, so each GPU needs 2,560 img/s. Iterating the loader alone gives 800 img/s, which reproduces the observed 0.32 s step exactly (256 / 800), so the loader is confirmed as the cause. htop shows the workers at 100% user CPU with almost no iowait, and a per-stage timer splits the 5.0 ms per image into 0.4 ms read, 3.1 ms decode, 1.2 ms crop and flip, and 0.3 ms normalize. Raising workers to the core budget of 7 per rank (64 cores across 8 ranks, one core kept for each training process) only reaches 1,400 img/s, about 55%. Storing pre-resized JPEGs cuts decode to 1.2 ms and cropping to 0.9 ms, and normalizing on the GPU removes the last 0.3 ms, which lifts capacity to 2,800 img/s and makes the job GPU-bound. NFS serves only 0.70 GB/s today, but at full speed full-size files would need 2.25 GB/s, 90% of the ceiling, so storage becomes the next constraint unless the smaller pre-resized files restore headroom.

Figure 1: Loader capacity per GPU as num_workers grows on the 64-core, 8-GPU node. Today’s 5.0 ms/sample pipeline scales linearly only up to the core budget of 7 workers, stalls at 1,400 img/s (about 55%), and loses throughput when oversubscribed. Only cutting per-sample cost to 2.5 ms lifts capacity above the 2,560 img/s GPU demand, and it lands just under the 2,841 img/s NFS ceiling.
Storage deserves its own check even when the CPU picture looks clear. It is the suspect when workers sit in the D (uninterruptible I/O) state with high %iowait and low user CPU, or when epoch 2 runs much faster than epoch 1 because the page cache now holds the files. On shared filesystems the limit is often metadata operations per second rather than bytes, which is why millions of 110 KB files hurt more than their total size suggests and why sharding them into large sequential files helps. The overlap plumbing comes last because its failures look like periodic stalls. pin_memory=True stages batches in page-locked host memory so .to(device, non_blocking=True) overlaps with compute, and shipping uint8 instead of fp32 shrinks a 256-image batch from 154 MB to 38.5 MB. prefetch_factor (default 2 batches per worker) absorbs bursty sample costs, and persistent_workers=True stops the DataLoader from tearing down and respawning every worker at each epoch boundary.

Figure 2: Timeline shapes from a profiler trace name different causes. A gap every step (a) means the loader is too slow, an isolated stall every few steps (c) means the prefetch queue drains on slow samples, a long gap at each epoch start (d) means workers are respawned, and gaps that survive synthetic data (e) are host sync points rather than the loader.
The table below maps each observable signal to its diagnosis, the measurement that confirms it, and the fix that matches it. Reading it top to bottom is the triage order, because each row is cheap to test and rules out a whole branch before the next one.
Observed signal Likely cause Confirming check Matching fix Synthetic replay still near 30% Not the loader: sync points, small batch, launch overhead, collectives Profiler shows stream synchronizes from .item() or .cpu() between steps Remove host syncs, larger batch, CUDA graphs, overlap communication Throughput scales with workers, cores idle Too few workers (num_workers=0 loads in the main process) Loader-only sweep over 2, 4, 8 workers per rank Raise to cores per GPU minus one, never beyond All workers at 100% user CPU Decode or augmentation is CPU-bound Per-stage timer in one worker; decode dominates Pre-resize offline, GPU decode, uint8 transfer with GPU normalize Workers in D state, high %iowait Storage bandwidth or metadata rate iostat await, NFS ops per second, epoch 1 vs epoch 2 speed Shard into large files, stage to local NVMe, larger reads Main process at 100%, workers idle Heavy collate_fn or host-side batch work py-spy dump of the training process Move work into workers, simplify collate Stall every k steps or at epoch start Prefetch queue drains, or workers respawn GPU timeline shape in Nsight Systems or torch.profiler Raise prefetch_factor, set persistent_workers=True Pageable HtoD copy blocks each step No pinned memory, fp32 batches on the host Profiler shows Memcpy HtoD (Pageable) on the critical path pin_memory=True with non_blocking=True, ship uint8 Login to view more contentDL0212 LLM Serving Frameworks: vLLM, SGLang, TensorRT-LLM
This is an IntvML Pro interview question. Upgrade to Pro to unlock the full prompt, diagrams, and solution.
MSD0150 Insurance-Claims Document Agent
This is an IntvML Pro interview question. Upgrade to Pro to unlock the full prompt, diagrams, and solution.







