0Pricing
CUDA Academy · Lesson

Numerical Stability Tradeoffs

Where lower precision needs care.

Numerical Stability Tradeoffs is a free CUDA Academy lesson on CoddyKit — lesson 4 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the CUDA Academy learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.

Speed Has a Cost

Lower-precision Tensor Core math is fast, but fewer bits mean rounding errors. Numerical stability is the art of keeping results trustworthy. ⚖️

What Rounding Error Is

Each low-precision value is rounded to the nearest representable number. That tiny rounding error is harmless once but can pile up over many steps.

FP16 Underflow

FP16's narrow range lets small numbers fall to zero, called underflow. Gradients and tiny weights can simply disappear during training.

FP16 Overflow

The same narrow range causes overflow: a large value becomes infinity. One bad sum can then poison everything downstream.

Loss Scaling to the Rescue

A common fix is loss scaling: multiply values up before FP16 math so they leave the underflow zone, then scale back down afterward.

Why Wide Accumulation Helps

Tensor Cores accumulate in FP32 for a reason. That wider accumulator stops thousands of small additions from drifting badly.

BF16 Sidesteps Range Issues

Because BF16 keeps FP32's exponent, it rarely overflows or underflows. Its weakness is lower precision, not a shrunken range.

Catastrophic Cancellation

Subtracting two close numbers wipes out leading digits, called cancellation. Low precision makes the surviving error far more visible.

Keep Critical Parts in FP32

A safe pattern is mixed precision: do bulk multiplies in FP16 or BF16 but keep sensitive sums, norms, and updates in FP32.

Always Validate Accuracy

Never assume a fast kernel is correct. Compare against an FP32 reference and check the error stays within an acceptable tolerance.

Measuring the Error

A simple check is the absolute difference against a trusted result. Compare this error to a small threshold you choose.

float err = fabsf(gpu_result - cpu_result);

Quick Check

Why do Tensor Cores accumulate partial sums in FP32 even with FP16 inputs?

Recap

You learned the precision tradeoffs: watch for FP16 overflow and underflow, use loss scaling and FP32 accumulation, and always validate against a reference. 🎯

Frequently asked questions

Is the “Numerical Stability Tradeoffs” lesson free?

Yes — the full text of “Numerical Stability Tradeoffs” is free to read here on the web, and the CUDA Academy course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the CUDA Academy course, upgrade to CoddyKit PRO.

What will I learn in “Numerical Stability Tradeoffs”?

Where lower precision needs care. You practise CUDA Academy with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.

Do I need any experience to start CUDA Academy?

No prior experience is required. CUDA Academy on CoddyKit is structured for beginners through advanced learners; this is — lesson 4 of 4, so you can start here or from the beginning and move at your own pace.

How long does the “Numerical Stability Tradeoffs” lesson take?

Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.

Can I write and run code in this CUDA Academy lesson?

Yes. Every CUDA Academy lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.

All lessons in this course

  1. What Tensor Cores Compute
  2. Mixed Precision: FP16, BF16, TF32
  3. The WMMA Fragment API
  4. Numerical Stability Tradeoffs
← Back to CUDA Academy