Skip to content

§ 7.8. The Tensor Core

Volta added a unit beside its FP32 lanes that does a small matrix multiply-add in one step: D = A × B + C on 4 × 4 tiles, with FP16 A and B and an FP32 sum. Its numbers are not those of a chain of IEEE FMAs. This section builds it to behave exactly as the V100's was measured to behave.

Component Description Structural Behavioral
DotProductUnit<K> One row: K FP16 products plus an FP32 addend, Volta's numerics Yes Yes (compiled gate list)
TensorCore<N,N,N> N × N dot-product units between registers: one N × N × N step per edge Yes No (compact children)

Catalog: tensor.dot-product.K (K = 2, 4), tensor.core.N (N = 2, 4). Volta's tensor core is the 4 × 4 × 4 one; the 2 × 2 × 2 one is small enough to watch at gate level.

What the V100 does

Fasi, Higham, Mikaitis and Pranesh probed a V100's tensor cores with carefully chosen inputs ("Numerical behavior of NVIDIA tensor cores", MIMS EPrint 2020.10; PeerJ Computer Science, 2021). For an element d = a₁b₁ + a₂b₂ + a₃b₃ + a₄b₄ + c with FP16 a, b and FP32 c, d:

Finding
Products Exact (an FP16 × FP16 product fits in FP32's precision), kept in full
Alignment Every summand is aligned to the largest one, and the bits that fall below binary32 precision there are cut off: no guard digits, no sticky bit
Normalization Only the final sum is normalized; the accumulator has extra carry bits
Rounding The final result is rounded toward zero
Subnormals Supported in inputs and outputs
Monotonicity The sum is not monotonic: c = 1 − 2⁻²⁴ plus four 2⁻²⁴ gives 1 + 2⁻²³, but c = 1 gives 1

The model fp::voltaDotProduct (7.1) follows these findings and reproduces every probe of the paper with the outputs it reports for the V100 (FloatReferenceTest). The paper does not say what happens on overflow; the model gives the largest finite value, as rounding toward zero does. NaN and ∞ follow IEEE.

7.8.1. DotProductUnit<K>

IO pins

Pin Direction Width Meaning
A_0 … A_{K−1} Input 16 each FP16 row of A
B_0 … B_{K−1} Input 16 each FP16 column of B
C Input 32 FP32 addend
D Output 32 FP32 result

Behavior

Combinational: D = Σ Aᵢ × Bᵢ + C with Volta's numerics. There are no flags (a GPU has none). NaN, ∞ × 0 or +∞ − ∞ give the canonical NaN; an exact zero is +0 unless every summand is −0.

Implementation

  1. Each product exactly (an 11 × 11 multiplier tree), normalized by its leading zeros; its leading bit's exponent in FP32's bias. C is normalized likewise.
  2. The largest of the K + 1 exponents, by a tree of comparisons.
  3. Every summand shifted right to it in a 24-bit frame (an AlignShifter) whose sticky bit is not used: the bits below binary32 precision are lost, as on the V100.
  4. A signed sum, 24 bits plus carry bits and a sign.
  5. The shared normalizer and one rounding toward zero.
Part Type Inputs Outputs What it does
TERM_0 … TERM_{K−1} DotProductTerm A, B (16 each) FRAME (24), TOP (11), SIGN, ZERO, NAN, INFINITE Step 1 for one product: two FloatUnpack<FP16> steps, a SignificandMultiplier<11>, a LeadingZeroCounter<22> and a NormalizeShifter<22>, the top exponent ea + eb + 98 − lz (the most negative value for a zero product, an absent summand), NaN (a NaN factor or ∞ × 0)
ADDEND DotProductAddend C (32) the same Step 1 for C (FloatUnpack<FP32>, normalized by its leading zeros)
LARGEST DotProductMax<K> TOP_0 … TOP_K LARGEST (11) Step 2: a chain of signed comparisons and word selects
SUM DotProductSum<K> LARGEST, each summand's FRAME, TOP, SIGN MAGNITUDE (27), NEGATIVE, T, MAGNITUDE_ANY Steps 3–4: one AlignShifter<24> per summand (its sticky bit unused), the conditional inversion and adder per summand, the magnitude of the signed sum
SPECIALS DotProductSpecials<K> each summand's NAN, INFINITE, ZERO, SIGN, and MAGNITUDE_ANY NAN, INFINITY, NEGATIVE_INFINITY, ZERO, ZERO_SIGN NaN (any NaN, or +∞ against −∞), ±∞, an exact zero (−0 only when every summand is −0)
NORMALIZE, ROUND_BITS, MODE, RESULT shared (§ 7.2.5) Step 5; MODE decodes the fixed code for rounding toward zero

The compact form is the unit's compiled gate list.

Examples

The paper's probes, each with the tensor core's result and, for comparison, the exactly rounded one:

All 8 recorded rows of DotProductUnit4ScenarioTest, in checkpoint order. Outputs are test expectations verified against the simulation. Time is the absolute settled checkpoint time in simulator units, not milliseconds or CPU cycles.

Default scenario profile: fidelity-gate-v1 / structural (ed03f70afe360dba). Changing fidelity or the circuit can change these times.

Checkpointzero-based number · timeline label Timesimulator units A_0Input · 16 bit A_1Input · 16 bit A_2Input · 16 bit A_3Input · 16 bit B_0Input · 16 bit B_1Input · 16 bit B_2Input · 16 bit B_3Input · 16 bit CInput · 32 bit DExpected output · 32 bit
#0plain162 0x3C00 0x4000 0x4200 0x4400 0x3800 0x3400 0x4000 0xBC00 0x41200000 0x41500000
#1exact-products296 0x3BFF 0x3BFF 0x0000 0x0000 0x3BFF 0x3BFF 0x0000 0x0000 0x00000000 0x3FFFC004
#2toward-zero426 0x3C00 0x3C00 0x0000 0x0000 0x4000 0x0003 0x0000 0x0000 0x00000000 0x40000000
#3toward-zero-negative503 0x3C00 0x3C00 0x0000 0x0000 0xC000 0x8003 0x0000 0x0000 0x00000000 0xC0000000
#4no-guard-bits637 0x3C00 0x0000 0x0000 0x0000 0x3C00 0x0000 0x0000 0x0000 0xBF7FFFFF 0x34000000
#5normalized-at-end772 0x3C00 0x3C00 0x0000 0x0000 0x0001 0x0001 0x0000 0x0000 0x3F7FFFFF 0x3F800000
#6subnormal-cut892 0x3C00 0x3C00 0x0000 0x0000 0x0003 0x4000 0x0000 0x0000 0x00000000 0x40000000
#7inf-times-01010 0x7C00 0x0000 0x0000 0x0000 0x0000 0x0000 0x0000 0x0000 0x3F800000 0x7FC00000

Scroll within the table for all rows and pins. Buses use hexadecimal; values containing X/Z use MSB-first binary. Inputs show the declared values in effect at each checkpoint, including retained inputs. Sequential tests also replay preparation changes between checkpoints, such as lowering the clock. Use the matching checkpoint label in the simulation below.

Open the full visualizer DotProductUnit<2>

7.8.2. TensorCore<N,N,N>

IO pins

Pin Direction Width Meaning
CLK, RST Input 1 each Clock, reset
VALID_IN Input 1 This edge's operands are a step
A_ROW_i Input 16 N each Row i of A: N FP16 values, element 0 in the low bits
B_COL_j Input 16 N each Column j of B
C_i_j Input 32 each The FP32 addends
D_i_j Output 32 each The FP32 results
VALID_OUT Output 1 D holds a step's result

(A pin carries at most 64 bits, so A comes in rows and B in columns.)

Behavior

One step per rising edge: operands registered at an edge, D = A × B + C registered at the next; D appears two edges after its operands, and a new step can start every edge. Each element is one DotProductUnit<N>.

On Volta, the instruction HMMA.884 multiplies an 8 × 8 × 4 tile as four such steps on the quadrants (PTX mma.m8n8k4); in the GPU of chapter 8, the warp's register file will feed this unit.

Implementation

Input registers for the rows, columns, addends and VALID; N² dot-product units; output registers. The gate-level 4 × 4 × 4 core has 16 units (see 7.9 for its size); its compact build uses the units' compiled gate lists, so the "compact" core is the same structure, proven equal unit by unit.

Examples

Two steps on consecutive edges: (2 I) × B + 1, then A × (I / 2) + 0.25.

All 4 recorded rows of TensorCore2ScenarioTest, in checkpoint order. Outputs are test expectations verified against the simulation. Time is the absolute settled checkpoint time in simulator units, not milliseconds or CPU cycles.

Default scenario profile: fidelity-gate-v1 / structural (ed03f70afe360dba). Changing fidelity or the circuit can change these times.

Checkpointzero-based number · timeline label Timesimulator units A_ROW_0Input · 32 bit A_ROW_1Input · 32 bit B_COL_0Input · 32 bit B_COL_1Input · 32 bit CLKInput · 1 bit C_0_0Input · 32 bit C_0_1Input · 32 bit C_1_0Input · 32 bit C_1_1Input · 32 bit RSTInput · 1 bit VALID_INInput · 1 bit D_0_0Expected output · 32 bit D_0_1Expected output · 32 bit D_1_0Expected output · 32 bit D_1_1Expected output · 32 bit VALID_OUTExpected output · 1 bit
#0edge-1240 0x00004000 0x40000000 0x3A003400 0x3C003800 1 0x3F800000 0x3F800000 0x3F800000 0x3F800000 0 1 not checked not checked not checked not checked 0
#1edge-2408 0xB800BE00 0x3800B800 0x00003800 0x38000000 1 0x3E800000 0x3E800000 0x3E800000 0x3E800000 0 1 0x3FC00000 0x40000000 0x40200000 0x40400000 1
#2edge-3488 0x00000000 0x00000000 0x00000000 0x00000000 1 0x00000000 0x00000000 0x00000000 0x00000000 0 0 0xBF000000 0x00000000 0x00000000 0x3F000000 1
#3edge-4503 0x00000000 0x00000000 0x00000000 0x00000000 1 0x00000000 0x00000000 0x00000000 0x00000000 0 0 not checked not checked not checked not checked 0

Scroll within the table for all rows and pins. Buses use hexadecimal; values containing X/Z use MSB-first binary. Inputs show the declared values in effect at each checkpoint, including retained inputs. Sequential tests also replay preparation changes between checkpoints, such as lowering the clock. Use the matching checkpoint label in the simulation below.

Open the full visualizer

The same at 4 × 4 × 4 (opens in Compact):

All 4 recorded rows of TensorCore4ScenarioTest, in checkpoint order. Outputs are test expectations verified against the simulation. Time is the absolute settled checkpoint time in simulator units, not milliseconds or CPU cycles.

Default scenario profile: fidelity-compact-v1 / structural (763e0b8bac717d60). Changing fidelity or the circuit can change these times.

Checkpointzero-based number · timeline label Timesimulator units A_ROW_0Input · 64 bit A_ROW_1Input · 64 bit A_ROW_2Input · 64 bit A_ROW_3Input · 64 bit B_COL_0Input · 64 bit B_COL_1Input · 64 bit B_COL_2Input · 64 bit B_COL_3Input · 64 bit CLKInput · 1 bit C_0_0Input · 32 bit C_0_1Input · 32 bit C_0_2Input · 32 bit C_0_3Input · 32 bit C_1_0Input · 32 bit C_1_1Input · 32 bit C_1_2Input · 32 bit C_1_3Input · 32 bit C_2_0Input · 32 bit C_2_1Input · 32 bit C_2_2Input · 32 bit C_2_3Input · 32 bit C_3_0Input · 32 bit C_3_1Input · 32 bit C_3_2Input · 32 bit C_3_3Input · 32 bit RSTInput · 1 bit VALID_INInput · 1 bit D_0_0Expected output · 32 bit D_0_1Expected output · 32 bit D_0_2Expected output · 32 bit D_0_3Expected output · 32 bit D_1_0Expected output · 32 bit D_1_1Expected output · 32 bit D_1_2Expected output · 32 bit D_1_3Expected output · 32 bit D_2_0Expected output · 32 bit D_2_1Expected output · 32 bit D_2_2Expected output · 32 bit D_2_3Expected output · 32 bit D_3_0Expected output · 32 bit D_3_1Expected output · 32 bit D_3_2Expected output · 32 bit D_3_3Expected output · 32 bit VALID_OUTExpected output · 1 bit
#0edge-1514 0x0000000000004000 0x0000000040000000 0x0000400000000000 0x4000000000000000 0x428040803D003400 0x430041003E003800 0x438041803F003A00 0x4400420040003C00 1 0x3F800000 0x3F800000 0x3F800000 0x3F800000 0x3F800000 0x3F800000 0x3F800000 0x3F800000 0x3F800000 0x3F800000 0x3F800000 0x3F800000 0x3F800000 0x3F800000 0x3F800000 0x3F800000 0 1 not checked not checked not checked not checked not checked not checked not checked not checked not checked not checked not checked not checked not checked not checked not checked not checked 0
#1edge-2770 0x3E003800B800BE00 0x41003E003800B800 0x430041003E003800 0x4480430041003E00 0x0000000000003800 0x0000000038000000 0x0000380000000000 0x3800000000000000 1 0x3E800000 0x3E800000 0x3E800000 0x3E800000 0x3E800000 0x3E800000 0x3E800000 0x3E800000 0x3E800000 0x3E800000 0x3E800000 0x3E800000 0x3E800000 0x3E800000 0x3E800000 0x3E800000 0 1 0x3FC00000 0x40000000 0x40200000 0x40400000 0x40600000 0x40800000 0x40900000 0x40A00000 0x40B00000 0x40C00000 0x40D00000 0x40E00000 0x40F00000 0x41000000 0x41080000 0x41100000 1
#2edge-31026 0x0000000000000000 0x0000000000000000 0x0000000000000000 0x0000000000000000 0x0000000000000000 0x0000000000000000 0x0000000000000000 0x0000000000000000 1 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0 0 0xBF000000 0x00000000 0x3F000000 0x3F800000 0x00000000 0x3F000000 0x3F800000 0x3FC00000 0x3F000000 0x3F800000 0x3FC00000 0x40000000 0x3F800000 0x3FC00000 0x40000000 0x40200000 1
#3edge-41033 0x0000000000000000 0x0000000000000000 0x0000000000000000 0x0000000000000000 0x0000000000000000 0x0000000000000000 0x0000000000000000 0x0000000000000000 1 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0 0 not checked not checked not checked not checked not checked not checked not checked not checked not checked not checked not checked not checked not checked not checked not checked not checked 0

Scroll within the table for all rows and pins. Buses use hexadecimal; values containing X/Z use MSB-first binary. Inputs show the declared values in effect at each checkpoint, including retained inputs. Sequential tests also replay preparation changes between checkpoints, such as lowering the clock. Use the matching checkpoint label in the simulation below.

Open TensorCore<4,4,4>

Source and tests

Units, model, tests.

Test Coverage
FloatReferenceTest The model against the paper's eleven V100 probes; the exact dot product against binary128 on the host
DotProductUnitTest K = 2 and 4, gates and compact form: special values against special addends, then random values around 1 and random patterns, a quarter with C cancelling the products; against the model
TensorCoreTest 2 × 2 × 2 at gate level and with compact children, 4 × 4 × 4 with compact children: 40 random tiles on consecutive edges, every element and VALID_OUT two edges later against the model
…ScenarioTest The recorded rows above