The Inference Stack — Model to GPU to Production
Two things enter an inference stack. Before the service can run, a model artifact is loaded into its execution layers. Once the service is live, each request enters through the production layer and descends through an inference engine and runtime to the hardware; generated output returns along the same path. The artifact flow determines what the system can run; the request path determines how the running system behaves.
A laptop can collapse these responsibilities into one process, while a large service may split them across several teams and clusters. The responsibilities remain even when the boxes change. A failure at any boundary appears to the user in the same way: the answer is late, wrong, or missing.
The model artifact
Before execution begins, the runtime needs a model artifact. A model repository typically packages weight tensors, an architecture configuration, tokenizer assets, and often default generation settings; exact contents vary by format and runtime. For the course's running example, the weights alone are about 16 GB at BF16. The architecture and numerical format constrain which hardware can hold the model, which runtimes support it, and which optimizations are available.
Model selection constrains every layer below it. A smaller model changes the work the whole system must perform. A custom architecture may be excellent research and still be expensive to serve because mature kernels and engine support do not exist yet. Model selection belongs in an inference design review for the same reason database selection belongs in a backend design review: later choices inherit its constraints.
The runtime
The runtime turns the model artifact into work the hardware can execute. A framework such as PyTorch represents tensors and operations, then dispatches or compiles implementations for a device. Those implementations eventually launch GPU kernels. A production inference engine such as vLLM, SGLang, or TensorRT-LLM adds request admission, scheduling, GPU-memory management, distributed workers, and output streaming. It may also replace or specialize lower execution layers with its own compiled paths and kernels.
Product boundaries overlap in real implementations. An engine may call PyTorch in one path, use its own CUDA kernels in another, and invoke a compiler-generated kernel elsewhere. The model architecture defines the intended computation; the runtime and engine decide how to execute and share it.
The last lesson introduced batching as many requests sharing one read of the weights. The inference engine owns the live version of that idea: at each iteration, its scheduler revises which requests run together as requests arrive and finish. Later modules teach the scheduling and memory mechanisms.
The hardware
The GPU contains two resources the runtime must coordinate: memory that holds bytes and compute units that operate on them. The H100 SXM has 80 GB of HBM3 and up to 3.35 TB/s of peak HBM bandwidth. That memory holds the 16 GB model weights, temporary values, and state carried for active requests. The previous lesson showed why the path between memory and compute can matter more than the headline arithmetic rate during token generation.
A host process on the CPU accepts and prepares work, launches GPU operations, and handles the surrounding service. Tokenization, sampling, and request bookkeeping may run on the CPU or move elsewhere depending on the runtime. In the course's H100 SXM server topology, CPU-GPU traffic crosses PCIe, while NVLink connects peer GPUs. Multi-GPU systems add more boundaries and more ways to wait; the hardware and parallelism modules will make those costs explicit.
The production service
One model server can answer requests, but a production service has responsibilities outside that process. An entry point authenticates and validates traffic. A router chooses a healthy replica. A queue absorbs short bursts and imposes admission policy when demand exceeds capacity. Autoscaling changes the number of replicas. Observability connects what users experience to engine queues, GPU memory, hardware utilization, errors, and cost.
The same model and engine can sit inside two very different services. Online inference has a user waiting for each answer, as in chat, code completion, and voice. Its deployment is tuned around response latency and the worst delays users are allowed to see. Offline inference processes a body of work such as a document corpus or podcast archive. No user is waiting on an individual token, so the deployment can trade request latency for total throughput and lower cost. A team with both workloads may operate separate deployments even when the model is identical.
Cross-layer diagnosis
The map is most useful during diagnosis. A slow answer might come from a long queue, a runtime scheduling decision, an unexpectedly slow fallback kernel path, exhausted GPU memory, or an application that spent most of its latency budget before inference began. Adding GPUs helps only some of those cases. Replacing the engine helps another subset.
Inference engineering therefore requires two kinds of knowledge: depth in the layer you change and enough breadth to prove that the bottleneck is actually there. The next lesson turns that distinction into levels of practice.