Layer 6 · Inference & Optimization
Running trained models quickly and cheaply for real users: serving, APIs, compression and caching.
In simple words: Getting answers out of a finished AI quickly and cheaply, for millions of people.
Like: A restaurant kitchen during service: the recipe is fixed, and now it's about getting many plates out fast and affordably.
Where it breaks: A kitchen cooks each order separately. Inference servers push many users' requests through the same model step together to use the hardware efficiently.
What it gives the layer above
A fast, affordable endpoint: send text in, get text out.
What it needs from the layer below
Model weights from Foundation Models and serving hardware from Cloud & Infrastructure.
Concepts
- Model APIs & routers
Paying per token to send requests to a hosted model, either directly to a provider or through a router that picks among many providers. - Batching & KV caching
Serving tricks that process many users at once and avoid recomputing work already done. - Quantization
Storing a model's numbers with fewer bits so it's smaller and faster, at a small cost in accuracy. - Local inference runtimes
Programs that run downloaded model files on your own computer instead of a remote service. - Speculative decoding
A small, fast model guesses the next few tokens and the big model checks them all at once, giving the same output in fewer slow steps.
Walkthrough
- A coding question goes out. A coding tool sends “why does this test fail?” to a model API, perhaps through a router that picks a provider, and pays per token.
- The provider shares the work. On the provider's servers the question rides in a batch with many other users' requests, and the KV cache saves re-reading the long code file for every new token.
- Smaller numbers, more room. Quantized weights take less memory, leaving room for more users' caches in each batch.
- Or ask the same question at home. The same open model, quantized into a GGUF file, runs in a local runtime on a home GPU. The coding tool just points at localhost instead.
- A small helper speeds it up. With only one user at home, a small draft model guesses ahead and the big model checks its guesses, so the answer streams out sooner with nothing changed.
Examples
- Model APIs and routers
- Local runtimes and GGUF files
- Quantization
- Batching and KV caching
- Speculative decoding