0Pricing
CUDA Academy · Lesson

Mixed Precision: FP16, BF16, TF32

Trading precision for throughput.

Mixed Precision: FP16, BF16, TF32 is a free CUDA Academy lesson on CoddyKit — lesson 2 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.

Trading Bits for Speed

Tensor Cores get their speed from mixed precision: feeding smaller number formats in so the hardware can push far more math per cycle. ⚡

What FP32 Costs

Standard FP32 uses 32 bits per value. It is accurate but heavy, so moving and multiplying many FP32 numbers eats bandwidth and time.

Meet FP16

FP16 uses just 16 bits: a smaller exponent and fewer mantissa bits. Half the size means more values move and multiply at once.

FP16 Has a Small Range

FP16 saves space but its narrow exponent gives a tiny dynamic range. Very large or very small values can overflow or vanish to zero.

Meet BF16

BF16 is also 16 bits but keeps FP32's full exponent, trading mantissa bits instead. It matches FP32's range with less precision.

Why BF16 Wins for Training

Because BF16 shares FP32's wide range, gradients rarely overflow. That makes BF16 a favorite for training large neural networks safely.

Meet TF32

TF32 is a 19-bit Tensor Core format: FP32's exponent with a trimmed mantissa. It speeds up math while looking like FP32 to your code.

The Accumulator Stays Wide

No matter the input format, Tensor Cores usually accumulate partial sums in FP32. The speed is in the inputs; the safety is in the running total.

Range vs Precision

The big idea: FP16 and BF16 cost the same 16 bits but split them differently. One favors precision, the other favors range.

Picking a Format

Use BF16 or TF32 when range matters, FP16 when you can manage scaling. The right format depends on your data, not just on speed.

Declaring Half Precision

In CUDA C++ the FP16 type has a short name. This line declares one half value ready for Tensor Core math.

__half x = __float2half(1.5f);

Quick Check

Which format keeps FP32's full exponent range in only 16 bits?

Recap

You saw how mixed precision trades bits for throughput: FP16 favors precision, BF16 favors range, and TF32 speeds FP32-style math. Wide accumulation keeps results safe. ✨

Frequently asked questions

Is the “Mixed Precision: FP16, BF16, TF32” lesson free?

Yes — the full text of “Mixed Precision: FP16, BF16, TF32” 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 “Mixed Precision: FP16, BF16, TF32”?

Trading precision for throughput. 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 2 of 4, so you can start here or from the beginning and move at your own pace.

How long does the “Mixed Precision: FP16, BF16, TF32” 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