Skip to content
tezvyn:
Menu

How would you speed up slow single-GPU training?

Source: interviewMediumHow cards are made

Summary

knowledge of scaling training.

Key points

vertical scaling to bigger or multi-GPU instances, then data-parallel or model-parallel distributed training across nodes.

WHAT THIS TESTS This checks that you distinguish scaling up from scaling out and understand the trade-offs of distributed deep learning, not just that bigger hardware is faster.

A GOOD ANSWER COVERS Two distinct strategies. First, vertical scaling: move to a larger instance with more or faster GPUs, enable mixed-precision training to use tensor cores, and increase batch size to keep the accelerators saturated. This is the simplest change and often the quickest win. Second, horizontal scaling with distributed training. Data parallelism replicates the model on each GPU, splits the batch, and synchronizes gradients each step via all-reduce; it suits most models. Model parallelism or pipeline parallelism shards a model that cannot fit in one GPU's memory across devices. A strong candidate notes the communication cost and that the learning rate usually must scale with the effective batch size.

COMMON WRONG ANSWERS Only suggesting a faster single GPU. Assuming N GPUs give exactly Nx speedup with no synchronization overhead. Confusing data parallelism with model parallelism. Ignoring data-pipeline bottlenecks where the GPU starves waiting on input.

LIKELY FOLLOW-UPS How does all-reduce work? When do you choose model over data parallelism? How do you keep the input pipeline from becoming the bottleneck? What about spot instances for cost?

ONE CONCRETE EXAMPLE On Azure ML or SageMaker you launch a cluster of GPU nodes and run PyTorch DistributedDataParallel with NCCL all-reduce over high-bandwidth interconnect. You enable automatic mixed precision, scale the learning rate with a warmup, and prefetch data with multiple workers so the GPUs stay busy. For a model too large for one device, you instead shard layers with pipeline parallelism such as DeepSpeed or Megatron.

Interview question

In data-parallel distributed training, what is the main reason adding more GPUs rarely gives perfectly linear speedup?

  • a.The model gets larger as GPUs are added
  • b.Each GPU trains on the entire dataset independently
  • c.Mixed precision must be disabled when scaling out
  • d.Gradient synchronization across GPUs adds communication overheadCorrect
Why?

Data parallelism must all-reduce gradients every step, and that network communication grows with GPU count, capping speedup. Each GPU processes only a shard of the batch, mixed precision still applies, and the model size is unchanged.

Just read this? Test yourself on what you have been reading.

Read the original → learn.microsoft.com

Put your scrolling time to good use

Learn one idea, try a quiz and save useful cards for revision. Tezvyn makes it easy to learn and stay current in your tech field, a few minutes at a time.

The iPhone app is on the way

We are building it. Until it lands, nothing here is held back from you: every interview card, your saved cards, streaks and the job board all work in Safari, plus hundreds of free practice quizzes of thirty questions each. Sign in and it all carries over to the app the day it arrives.

Want it as an icon? Tap Share at the bottom of Safari, then Add to Home Screen. It opens full screen and the cards you have read stay available offline.

Get it on Google PlayiPhone app coming soon

We are hiring for this. Every open role lists the topics its interview covers, so you can prepare for the real thing rather than guessing.

See open roles