§ 7. Floating Point and the Tensor Core¶
The accelerator of chapter 6 works in 8-bit integers. Training a network, and much of science, needs numbers with a moving point: floating point. This chapter builds IEEE floating-point hardware from gates, puts it into the RV32IM processor as RISC-V's F extension, and builds the unit that made Volta's GPUs fast at neural networks: the tensor core, a 4 × 4 matrix multiply-add per step in FP16 with FP32 sums.
Three ideas carry the chapter.
- One exact reference first. Before any gate, a bit-exact model in integer C++ fixes every rule (five rounding modes, five flags, subnormals, NaNs) and is checked against the processor the site is built on (7.1). Every unit is then checked against it.
- Moving bits costs more than adding them. A float unit is mostly shifters, leading-zero counters and a rounder around one adder or multiplier (7.2); the fused multiply-add (7.4) shows it best.
- Faithful, not ideal. The tensor core follows what a V100 was measured to do, truncations included (7.8); 7.9 measures what that costs in accuracy.
Contents¶
| Section | What it covers |
|---|---|
| 7.1. Formats and the Reference | FP16 and FP32, the rules, the bit-exact reference and its check against the host |
| 7.2. Building Blocks | Leading-zero counter, alignment and normalization shifters, rounder |
| 7.3. Adder and Multiplier | The two basic operations, rounded once |
| 7.4. Fused Multiply-Add | ±A × B ± C with one rounding; its pipelined form with Volta's latencies |
| 7.5. Comparisons and Conversions | Compare, min/max, classify; float ↔ integer; FP16 ↔ FP32 |
| 7.6. Divide and Square Root | One bit per clock edge |
| 7.7. RV32F on the CPU | The F extension in the five-stage core |
| 7.8. The Tensor Core | Volta's dot-product unit and the 4 × 4 × 4 tensor core |
| 7.9. Experiments | Campaign 2: the cost and accuracy of floating point |
Reading this chapter¶
Component sections follow the pattern of the earlier chapters: IO pins → behavior → implementation → examples → source and tests. Every part exists as gates; each unit's compact form is its own compiled gate list, exact for every input and timed from those gates, and the larger parts (the execute unit, the F core, the 4 × 4 × 4 tensor core) are built from compact parts. Each example table is generated from a recorded scenario, and the same scenario opens in the simulator below it. The scenarios are in the simulator's Floating point menu group, after the AI accelerator.
The units are generated from the format (exponent bits E, fraction bits F), so FP16 and FP32 come from one builder each; the examples are mostly FP16, small enough to follow bit by bit.