Design Ordered CUDA Reduction
Applied IntuitionMachine Learning Engineer · Technical ScreenLast updated
This question evaluates understanding of parallel GPU programming, deterministic reduction ordering, and numerical stability in floating-point arithmetic, within the domain of parallel algorithms, GPU/CUDA programming, and numerical computing for a Software Engineering Fundamentals / Machine Learning Engineer role.
In CUDA, a parallel reduction can produce different results if the combination order is not fixed, especially for floating-point arithmetic where addition is not perfectly associative.
Design an algorithm for a deterministic reduction that guarantees a well-defined reduction order. The interviewer suggests that the idea is similar to prefix sum.
Address the following:
- How would you organize the reduction within a CUDA block?
- How would you combine results across blocks without relying on nondeterministic atomics?
- How does the approach relate to prefix-scan algorithms?
- What guarantees can and cannot be provided for floating-point reductions?
- What are the time and memory tradeoffs?
Solution walkthrough is for members
Get the full walkthrough with reference code and complexity analysis, plus Kitty Coach at 300 messages a day. Hints, the code runner and community answers stay free.