Basis Lab

What It Costs to Run a Model

The One Trick That Actually Works

Last timeWhen the Context Gets Long

Reading the weights once and using them for many requests at the same time is the single change that turns a movement problem into an arithmetic one.

The previous lessons have been mostly bad news: the weights must be read for every word, the kept conversations must be read too, and arithmetic sits idle through all of it. This lesson is the good news, and there is really only one piece of it.

The weights do not care how many requests there are

A pass through a weight matrix takes whatever vectors you hand it and multiplies each one against the same numbers. Hand it one vector and it reads the matrix and does one vector's worth of arithmetic. Hand it sixty-four and it reads exactly the same matrix and does sixty-four vectors' worth. The reading is identical.

FIG 1One pass over the same hundred and forty gigabytes of weights, with more and more riding on it
steprequests in the groupgigabytes of weights read for the passgigabytes read on behalf of each requestoperations per bytewhat happened
1one140140 / 1 = 1401A single reader alone on a machine. Every byte of the model is fetched to produce one word for one person, and the multipliers are idle for almost all of it.
2eight140, unchanged140 / 8 = 17.58Seven eighths of the per-request reading has gone, and nothing was changed except how many vectors were handed to the same matrix.
3sixty-four140, unchanged140 / 64 = 2.1964The reading is identical to the first row. The arithmetic is sixty-four times larger, and it is arithmetic the machine had spare anyway.
4a hundred140, unchanged140 / 100 = 1.4100The balance point of the machine. From here on the multipliers are the limit rather than the wire, which is the first time in this course that has been true.
4 steps
The second column never moves, which is the whole lesson. The same hundred and forty gigabytes are read whether one request or a hundred are riding on the pass, so the third column falls exactly as fast as the group grows and the fourth climbs at exactly the same rate. This is the single most useful fact in the course, and it says that the balance point of a machine, around a hundred operations per byte, is also a target group size: reach it and the arithmetic units are finally busy.

So the idle arithmetic from the third lesson has an answer, and the answer is to stop sending one request at a time. Notice that this is not a clever algorithm or a better format. It is the same work, rearranged so that an expensive reading is amortised.

It is also the reason the serving of a model looks so different from the running of one. A single reader talking to a model alone is served by a machine doing a few per cent of the arithmetic it is capable of, and nothing can be done about that, because there is no one to share the reading with. The same machine serving a hundred readers at once is doing useful work with nearly all of its arithmetic. The hardware has not changed and the model has not changed, so almost the whole difference in cost per word between a quiet system and a busy one comes from this one effect.

The lesson stops here

4 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. 01The Two Kinds of Work
  2. 02Paying for Precisionopening only
  3. 03The Ceiling You Cannot Code Aroundopening only
  4. 04What the Model Holds On Toopening only
  5. 05The Length at Which Everything Changesopening only
  6. 06The One Trick That Actually Worksyou are here
  7. 07Reading and Writing Are Different Jobsopening only
  8. 08What a Million Words Actually Costsopening only

Read alongside