Log inStart free
LESSON 37.C1 · 6 STAGES · 2 CONTROLS · 3 CHECKSPRO · PREVIEW

The full stack for one request

Follow one chat question from the user to the cost of each token.


Pro lesson. Stage 1 is free to watch. Pro opens all 6 stages, 2 controls and 3 checks, in this lesson and every other.

Go Pro · $8.25/mo
EXPLAINER · 37.C1 · FULL STACK BAYFIRST WORD 377 ms · ENDS 409 ms
01
Stage 1 of 6 · Beginner view
One question goes in. The first word shows at 377 ms; the reply ends at 409 ms.
Explain it simply

On the left, a user types a question. In the middle is one closed box, the service that answers. On the right, the reply comes back. The line below counts the words on the screen over time, and they show one by one.

A question box, a closed service box and a reply box. The words show from 377 ms to 409 ms.

request, tokens, networkweights, slots, pricesoutput tokens, replywaits, waste, dropped
beginner viewfront doortokenizequeuebatchpassesattentionKV blockssamplestreamcost33.258.0229.1529.1429.0128.0329.0529.2033.0234.01user · chat appWhat is the capital of France?the serviceone closed boxreplyThe capital of France is Paris.questionone by onetime since the user sends (ms)words on the screen010020030040007whole replysentfirst word 377 msreply ends 409 msbeginner viewfront doortokenizequeuebatchpassesattentionKV blockssamplestreamcost33.258.0229.1529.1429.0128.0329.0529.2033.0234.01user · chat appWhat is the capital of France?the serviceone closed boxreplyThe capital of France is Paris.questionone by onetime since the user sends (ms)words on the screen010020030040007whole replysentfirst word 377 msreply ends 409 ms
Toy: one 512-token chat prompt, an 8B model, one H100, 4 requests
STAGE 1 / 6
MATH · STAGE 1HOVER A SYMBOL OR A SHAPE
Tfirst=Tnet+Twait+TGPU\sy{first}{out}{T_{\text{first}}} = \sy{net}{data}{T_{\text{net}}} + \sy{wait}{grad}{T_{\text{wait}}} + \sy{gpu}{param}{T_{\text{GPU}}}
Tfirst=240.0+130.0+7.3=377.3 msT_{\text{first}} = 240.0 + 130.0 + 7.3 = 377.3\ \text{ms}

The first word waits for the network, the queue and the GPU.

Common mix-ups

MYTHModel math takes most of the time of a chat reply.

The fix, and 1 more mix-up with the diagram to show them, come with Pro.

Predict, then reveal
3 CHECKS · PRO
Q01With FCFS traffic, if the reply comes back whole, does it end later?

Make your guess, then test it in the diagram. All 3 checks come with Pro.

PRO LESSON · YOU WATCHED STAGE 1 OF 6
Unlock the full explainer
  • 5 more stages and 2 live controls
  • 2 mix-up cards and 3 predict-then-reveal checks
  • Watch it as a narrated video, in three voices
  • Every Pro lesson and capstone · 656 in total

$99 a year, or $15 a month. Cancel any time.