liveBook · Manning

Bfloat16

As explained in Deep Learning with R, Third Edition

bfloat16 is a 16-bit floating-point data type with an 8-bit exponent and a 7-bit mantissa, providing greater numerical range but lower precision than float16.

bfloat16 is a 16-bit floating-point type designed for efficient computation on modern GPUs and TPUs. Compared with float16, it uses more exponent bits and fewer mantissa bits: the wider exponent gives greater numerical range, while the shorter mantissa gives lower resolution. section 18.3.2

Its layout determines the main practical difference from float16:

  • bfloat16 uses 1 sign bit, 8 exponent bits, and 7 mantissa bits. section 18.3.2
  • float16 uses 1 sign bit, 5 exponent bits, and 10 mantissa bits. section 18.3.2
  • The extra exponent bits let bfloat16 represent a wider range of values, but its fewer mantissa bits reduce precision across that range. section 18.3.2

Choosing a reduced-precision format

When running inference on a newer GPU or TPU, try both float16 and bfloat16. Keep the option that delivers the better device-specific speed while providing an appropriate numerical range. section 18.3.2 section 16.4.1

Table 18.1 Difference between float16 and bfloat16
dtype
float16
bfloat16
Exponent bits
5
8
Mantissa bits
10
7
Sign bits
1
1

Compare the sign, exponent, and mantissa allocations for float16 and bfloat16. section 18.3.2

How Deep Learning with R, Third Edition covers it

How deep it goes
Explains bit allocation and range-versus-resolution trade-offs, but stops short of detailed floating-point implementation.
Examples
Uses a float16 comparison table and recommends testing both formats on the target device.
What it assumes
Assumes basic familiarity with floating-point values, precision, inference, and lower-precision computation.
What you can do after
Evaluate bfloat16 against float16 when selecting an inference precision for a newer GPU or TPU.
How it connects
Connects bfloat16 with float16, floating-point precision, inference, GPUs, and TPUs.

Also explained in

Compare how 3 books explain bfloat16 →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Deep Learning with R, Third Edition. The section links point to the parts of the book it draws on.