Basis Lab

What It Costs to Run a Model

Reading and Writing Are Different Jobs

Last timeMany Requests at Once

Taking in a prompt and producing a reply obey opposite limits, want opposite settings, and interfere with each other when run on the same machine.

Every request to a model does two quite different things, and almost every confusing measurement in serving comes from averaging over the difference.

What the two phases are

First the prompt is taken in. Every position of it is processed in a single pass through the weights, which produces the kept summaries for all of those positions and, at the end, the first word of the reply. Then the reply is produced, one word per pass, each pass reading the whole store again.

The user experiences these as two separate things: how long before anything appears, and how quickly it then arrives. They are set by different phases and limited by different resources.

FIG 1Operations per byte in the two phases, against a balance point of a hundred
stepthe passrequests grouped into itpositions each request contributesoperations per byteagainst the balance pointwhat happened
1taking in a two hundred word prompt12001 x 200 = 200200 / 100, so twice past itOne reading of the weights serves all two hundred positions at once, so even a short prompt is already limited by arithmetic rather than by movement.
2taking in a two thousand word prompt12,0001 x 2,000 = 2,0002,000 / 100, so twenty times past itThe same single reading, ten times the positions riding on it. Grouping prompts together here would add waiting and buy nothing at all.
3producing one word, one reader alone111 x 1 = 1one hundredth of the way thereEach request contributes exactly one position, because the word being produced depends on the one before it. This is the row the rest of the course is about.
4producing one word, a hundred readers grouped1001100 x 1 = 100exactly at itA hundred readers, found and held at the same moment, to get the machine to where a single two thousand word prompt was twenty times over.
4 steps
Read the last column and the two phases are not on the same part of the curve at all. Taking in a prompt arrives saturated or close to it, for free, because the positions are all available at once; producing words starts a hundred times short and can only be fixed by finding a hundred readers. Nothing a serving team does moves a phase from one side to the other, which is why grouping is everything to one half of a request and a waste of waiting to the other.

The same arithmetic, a hundredth of the time

The clearest way to feel the difference is to price a symmetrical exchange: two thousand words in, two thousand words out.

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. 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 Worksopening only
  7. 07Reading and Writing Are Different Jobsyou are here
  8. 08What a Million Words Actually Costsopening only

Read alongside