Skip to content
← Implement-from-Scratch Coding / 26
hardNewNVIDIAAMDMeta

Write a numerically safe row softmax kernel in CUDA C, with an online max and sum merged by warp shuffles.

Subtracting the max is the line everyone writes. The kernel is decided by the masked row: one missing guard turns -inf minus -inf into NaN, and a later check turns that NaN into a row of zeros without raising anything.

Updated Oct 2026 · Worked answers on inference mechanisms, with calculations, implementation details, and follow-up questions.

Subtracting the max is the line everyone writes. The kernel is decided by the masked row: one missing guard turns -inf minus -inf into NaN, and a later check turns that NaN into a row of zeros without raising anything.

10 answers per topic instead of 5, plus saved progress and bookmarks · costs nothingor unlock all 213 remaining answers · $25

Every worked answer and derivation in all 12 topics, every concept page, the full practice-test bank, and every code drill’s edge-case tests and reference solution.

6 months · One payment · No auto-renewal

UP NEXT ON YOUR JOURNEY
DISCUSSION · 0

Nobody has commented on this answer. Add a correction or another way to work it.