Home / Chapter 7 · Production and serving
    Last edited · 14 min read

    Use with AI

    The inference stack

    Before the model answers a chat message, the request reaches an inference server, often through a gateway, and the server uses libraries and a driver to run the model on the GPU. Each level has its own job and knows little about the others.

    In plain wordsA map of seven levels. At the top level you see the application and the API; deeper down, the same request appears as tokens, tables of numbers, hardware commands and individual multiplications.

    When an answer arrives slowly or the server runs out of memory, the API alone doesn’t reveal the cause. Dividing the stack into levels shows which component to inspect.

    The example on this page is a Kubernetes cluster running the vLLM inference server, PyTorch and NVIDIA H100 GPUs, with a model of 70 billion parameters and 80 layers.

    Go down the stack level by level. Tap an element to jump to its step

    GPU figures are H100 specifications; the model, replica count, token IDs and tensor shapes are illustrative and simplified. OpenAI and Anthropic don’t publish their full stacks.

    Level 1. System

    Level 2. Cluster

    Level 3. Server

    Level 4. Model

    Level 5. Libraries

    Level 6. Driver

    Level 7. GPU

    Check yourself

    How does a request reach the GPU, and what does each level do?

    The application sends the conversation history. The gateway checks access, and the router picks a replica. The server tokenises messages, schedules model passes and allocates memory. A worker launches the model’s computations through GPU libraries and the driver. The GPU computes, the sampler picks a token, and the server streams text. Model passes repeat until a stop condition is met. Reasoning has no separate level: it is ordinary tokens the model generates.

    Po polsku

    Aplikacja wysyła historię rozmowy. Bramka sprawdza dostęp, a router wybiera replikę. Serwer tokenizuje wiadomości, planuje przebiegi modelu i przydziela pamięć. Proces roboczy uruchamia obliczenia modelu przez biblioteki GPU i sterownik. GPU liczy, sampler wybiera token, a serwer wysyła tekst. Przebiegi powtarzają się do spełnienia warunku końca. Rozumowanie nie ma osobnego poziomu: to zwykłe tokeny generowane przez model.

    Follow-up questions (4)
    Does CUDA know the model is reasoning?
    No. CUDA launches GPU programs that compute on tensors. Whether the next tokens are reasoning comes from the prompt, the tokens so far and the weights, and separating them from the answer is the job of a server-side parser.
    A container reports a driver that is too old, although the host has the CUDA Toolkit. What do you check?
    The Toolkit doesn’t matter here. What counts is the host driver, <code>libcuda.so</code> and the kernel module, and the version of the CUDA libraries in the image. Update the driver, use an image built for an older CUDA, or use a matching <code>cuda-compat</code> package, if the GPU and driver are supported.
    Why doesn’t launching a GPU program need a system call?
    When resources are created, the Linux kernel maps the command buffers and doorbell into the process. After that the user-space driver writes commands to memory and notifies the GPU with a doorbell write, so the CPU doesn’t switch to kernel mode for every operation. NVIDIA publishes the command format and doorbell in open-gpu-doc and open-gpu-kernel-modules, including for the H100, while research describes how the closed-source libcuda.so turns CUDA calls into those commands.
    Your model doesn’t fit on one GPU and throughput is too low. What do you do?
    Check quantisation or a GPU with more memory first. Otherwise tensor parallelism splits one copy’s weights, KV cache and computation across the GPUs of one node. Across nodes it is split into groups of layers by pipeline parallelism. Replicas add independent copies for concurrent requests. Measure the throughput of the configurations you’re considering.

    Sources

    Report an error · Suggest a fix