Basis Lab

From a Matrix Multiply to a Forward Pass

A Unit That Only Multiplies Small Matrices Is Worth Eight Times, on the Multiplies That Can Feed It

Last timeMultiplying in Tiles

A dedicated unit does a whole four by four matrix product in one step. The published gain is eight times, and a multiply collects it only if memory can keep up.

Tiling moved the multiply off the memory limit and onto the arithmetic limit. Since nearly all of a pass is this one operation, the next move belongs to the builder of the device: make units that do nothing but multiply matrices, and make them much faster at it than a general unit could be.

What one of them does in a step

A general arithmetic unit serves one worker at a time, a multiplication and an addition for one product of one cell. The dedicated unit takes three small tables at once.

FIG 1The one operation the dedicated unit performs
a table of four rows and four columns, taken from a tile of the first table of the multiply
a four by four table from the matching tile of the second
the four by four table of running totals so far
the running totals after this step, all sixteen of them
NVIDIA introduced these units on the Tesla V100 in 2017 and calls them Tensor Cores. On that device A and B hold two-byte numbers and the totals may be two-byte or four-byte.

Each of the sixteen cells of DD gains four products. That is sixty-four multiplications, each with its addition, in one step of the clock. The vendor's description of the V100 counts upward from there.

The lesson stops here

5 more paragraphs to go

You have read the opening. The rest of the argument, the problems that check whether it landed, and the lines worth keeping at the end all come with a plan.

The first lesson of every course in the library reads the whole way through, free, so you can see exactly what the rest of them are.

See the planThe contents

This is the reading half

Starting the course gives you your own copy of it. Every idea on every page has problems standing under it, marked with a reason rather than a tick, and any sentence you do not believe can be opened and argued with. None of that can happen on a page nobody owns.

The contents

The rest of this course

  1. 01A Forward Pass Is a List of Matrix Multiplies, and You Can Count Each One
  2. 02A Multiply Is Cut Into Tiles So That Each Block of Workers Reuses What It Fetchedopening only
  3. 03A Unit That Only Multiplies Small Matrices Is Worth Eight Times, on the Multiplies That Can Feed Ityou are here
  4. 04Halving the Size of a Number Is Worth Exactly Two to Memory and Whatever the Units Say to Arithmeticopening only
  5. 05Every Operation Has a Fixed Cost to Start, and the Small Ones Are Nearly All Startopening only
  6. 06A Run of Small Operations Joined Into One Pass Pays for One Start and One Trip Through Memoryopening only
  7. 07A Multiply Fills the Device Only Above a Certain Batch, and the Batch Can Be Computedopening only
  8. 08A Device Reported as Fully Busy May Be Using One Hundredth of Its Arithmeticopening only

Read alongside