One Division Says Whether Faster Arithmetic Would Help
Last timeThe Rate Bytes Arrive
Divide a job's operations by its bytes, divide the device's arithmetic rate by its memory rate, and compare the two. The smaller side names the limit you are against.
The last lesson ended with a job far above nothing in particular: adding two arrays took 115 times longer to feed than to compute. This lesson turns that comparison into a single division that can be done for any job on any device, before the job is written.
The ratio of a job
Count the operations the job performs and the bytes it moves, and divide.
Adding two arrays does one addition for each result. That result is four bytes written, from two values of four bytes read. One operation for twelve bytes: a ratio of , about 0.08 operations a byte.
A layer of a model is different. Each weight is two bytes and is used once for every item in the batch, with one multiplication and one addition. A batch of items does operations on those two bytes, so the ratio is operations a byte. Counting only the weights, which dominate, the ratio of a layer is its batch size.
Both numbers are properties of the job. Neither mentions a device.
The balance point of a device
A device has two rates: the arithmetic it can do in a second and the bytes its memory can deliver in a second. Divide the first by the second.
The lesson stops here
6 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 contentsThis 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