GPU kernels (simulated) practice problems

23 problems · 0 solved

GPU programming is about keeping thousands of small cores busy while moving as little data as possible. Most slow kernels are slow because they wait on memory, not because they run out of compute. These problems simulate GPU behaviour in plain Python, so you can learn the rules without needing a GPU. Picture a warp as a row of workers who must all do the same step at once; anything that splits them up wastes time. You will count memory transactions for a warp's loads, measure warp divergence from branch outcomes, count shared-memory bank conflicts, calculate SM occupancy from threads, registers and shared memory, predict attainable FLOPs with the roofline model, compare global loads for naive and tiled matmul, simulate a parallel tree reduction and a work-efficient prefix sum, and implement online softmax, the trick inside FlashAttention. Start with the Easy problems on the roofline model, reductions and memory transactions. Then do occupancy and tiled matmul, and finish with prefix sums, bank conflicts and online softmax. Kernel and inference optimisation skills are in high demand, and interviewers often test these exact concepts.

Easy 8

Medium 10

Hard 5

Related topics

All practice problems