Zero Labs
Industry News / AI

How AI Models Think, and Where They Run: From One Weight to a GPU Server

Source · Towards AI By Deepak Kumar

From the publisher’s feed, collected in the ZeroLabs newsroom.

Everyone’s impressed by what AI can do. Here’s how a model actually works, and why running one takes GPUs that cost more than a car.What Happens When You Send a PromptEvery time you send a prompt to a language model, whether small, medium or large, you make an API call from a device and get an answer back in seconds. It feels instant, but behind the scenes a lot of work happens to produce that answer.Every model also has limits it must work within. The most common ones are:Capacity limits: The model can only read and respond within a fixed token limit.Knowledge limits: The model only knows what was in its training data, up to its cutoff date.Behavioral limits: Safety training, usage policies, system prompts and guardrails decide what it will and won’t do.Governance limits: Data privacy and residency rules, regulations, and audit and observability requirements decide how and where it can operate.Start Simple: A Very Basic ModelImagine a very small machine. You give it an input, and it always gives you the same output for that input.This machine takes any number X, adds 5 to it every time, and returns X + 5. Give it 10, and you get 15. Give it 100, and you get 105.Simple machineIn LLM terms:X is your prompt (the input).5 is the model parameter: what the machine has “learned.”X + 5 is the model’s response (the output).Making the Model a Little SmarterNow let’s make our machine a little smarter. Instead of just adding a number, it multiplies the input by one value and adds another:Output = (w × X) + bSimple modelHere w (weight) and b (bias) aren’t chosen by us. The machine learns them by looking at thousands of examples.Weight (w) controls how much influence the input has on the output.Bias (b) is the model’s built-in starting point before it considers the input.In fact, our first machine was this same formula with w = 1 and b = 5.Weight and Bias in the Housing MarketWeight decides how much an input affects the price:Large weight: a small change in the input causes a big change in the output.Near-zero weight: the input hardly matters.Negative weight: the output goes down as the input goes up.For example, if w = 2,000, every extra square foot adds ₹2,000 to the price. If the model learns a negative weight for “age of house,” older houses get cheaper.Bias is the starting point: the output you get before any input is counted. It’s a fixed amount added at the end.For example, if b = ₹1,00,000, the house has a base value of ₹1 lakh before its size is even considered. You can think of it as the value of the land or a market baseline.So a 1,000 sq ft flat would be priced at:(2,000 × 1,000) + 1,00,000 = ₹21,00,000 (₹21 lakh)Putting them together, imagine a line on a graph:The weight sets how steep the line is (the slope).The bias sets where the line starts (the intercept, the point where it crosses the vertical axis).Training is just the machine trying different slopes and starting points until the line fits the data best.Our two machines side by side:The +5 machine: w = 1, b = 5. It passes the input through unchanged and adds 5.The house-price machine: w = 2,000, b = ₹1,00,000. It charges ₹2,000 per sq ft, starting from ₹1 lakh.Table 1From Two Parameters to BillionsOur house-price model has just two parameters. A real house price depends on much more: location, floor, number of bedrooms, distance to the metro, the builder’s reputation. Each new factor brings its own weight. Stack thousands of these small machines in layers, with each layer passing its output to the next, and you get a neural network.An LLM is the same idea at a huge scale. Its input isn’t square footage but your prompt, broken into tokens. Its output isn’t a price but the most likely next word. And its parameters don’t number two. They number in the billions, each one a weight or bias learned from huge amounts of text.No single weight “knows” anything. Just as no single factor sets the price of a flat in Mumbai, the intelligence comes from billions of them working together.And all those billions have to live somewhere. A 70-billion-parameter model needs about 140 GB of memory just to hold its weights, before it answers a single question. Every time you make an API call, those weights, already loaded on GPUs, are multiplied against your prompt, and the result is sent back to you as an answer in seconds, for thousands of people at once.A model’s knowledge lives in its weights. But billions of weights are useless if there’s nowhere fast enough to run them.So where do those 140 GB (70 billion weights at the standard 2 bytes each) actually live? What does the work when you send a request? And why do the GPUs behind it cost more than a car?Let’s find out, starting with some basics.Transformers: How the Model ThinksOur house-price example needed only a handful of weights. Today’s models can summarize a 100-page document. To make that possible, the weights grow into the billions and the model grows into many layers stacked on top of each other. The output of one layer becomes the input to the next.Simple networkThis entire network of layers is called a transformer. What makes it special is a mechanism called attention: at every layer, each word looks at the other words in the input to work out which ones matter most for its meaning.In simple terms, the transformer is the formula (like the house-price calculator from earlier). It’s written once in code and is broadly the same across GPT, Llama and Claude. What makes them different is not the formula; it’s the weights (like the price per square foot).TransformerThe formula (the transformer) is only a few pages of code; the knowledge is in the weights. A real model doesn’t have one or two weights; it has billions of them. These billions of weights are what training produces, and together they can take up tens or even hundreds of GB. They are simply files sitting on a disk, and their size varies from model to model. Before the model can answer a single request, all of its weights have to be loaded into memory.One may ask: why can’t a large model run well on a personal computer or a small server? To understand, let’s look at how a normal laptop or server performs a calculation.Why a Large Model Doesn’t Fit in a Laptop: CPU and RAMYou open the calculator on your laptop and calculate 100 × 2. What happens? The calculator responds with 200. Behind the scenes, the CPU and RAM are doing all the work.See the diagram below.Simple CPU-RAMWhen you ask it to calculate 100 × 2, this is how it works: the computer saves the instructions in RAM, the CPU fetches the instructions from RAM, computes the result, and saves it back to RAM. Here the CPU is doing all the work, while RAM acts as temporary storage, holding the instructions and data the CPU is currently working on.This setup has three limits when it comes to running a large model:1. A normal laptop has a limited number of CPU cores. The latest Intel Core Ultra Series 3 processors offer 6, 8, 12 or 16 cores, so a laptop can process only a small number of calculations in parallel, compared with the thousands of cores in a GPU.2. A typical laptop has 16–32 GB of RAM, whereas a rack server may have 512 GB or more, but the weights of the largest models can go beyond even that.3. Data moves between the CPU and RAM over a fairly narrow channel: roughly 77–128 GB/s on a laptop, and a few hundred GB/s on a large server. That sounds fast, but a model has to read all of its weights for every word it generates. Even if a 140 GB model fit in a laptop’s memory, at 100 GB/s it would take more than a second per word.Where the Model Lives and Works: GPU and VRAMTo run a large model quickly, we need three things: thousands of cores working in parallel, hundreds of GB of memory, and a very fast link between the two. Get all three, and the LLM can answer our requests much faster.That’s exactly what NVIDIA’s GPUs and their VRAM provide, solving each of the problems we discussed earlier.1. Parallel processing: A basic or entry-level modern NVIDIA GPU typically has around 2,560 to 3,840 CUDA cores (such as the GeForce RTX 5050 with 2,560 CUDA cores and RTX 5060 with 3,840 CUDA cores), while high-end models reach 10,000 to over 21,000. Each CUDA core is far simpler than a CPU core, but together they can do thousands of small calculations at once, which is exactly what a model needs.2. Memory capacity: A basic or entry-level modern NVIDIA GPU typically comes with 8 GB of VRAM (such as the GeForce RTX 5050 and RTX 5060), while mid-range models offer 12 GB to 16 GB and flagship cards reach 32 GB (RTX 5090). That’s still far short of 140 GB, which is why serious models run on data-center GPUs such as the H100 (80 GB) or B200 (192 GB), often several linked together.3. Memory bandwidth: Data transfer between a GPU chip and its VRAM typically ranges from 320 GB/s on entry-level cards to 1,792 GB/s on flagship gaming GPUs, and reaches 3,000–8,000 GB/s on data-center GPUs.GPUUnlike the CPU and RAM, the GPU and its VRAM sit on the same card (on data-center GPUs, the same chip package), connected by a much wider channel. That is what lets data move at such high speed.The table below compares cores and memory (source: Intel and NVIDIA websites).Table 2Who Drives It: Software and Model ServersA chip on its own can’t do anything useful; something needs to drive it. That’s where software comes in: CUDA, NVIDIA’s platform for programming its GPUs, and PyTorch, the popular framework built on top of it that most AI models are written in. With a few lines of PyTorch code, you can load a model, ask it a question and get an answer. A very small model can even run this way on your laptop.In production, though, it’s not just one request: many users can send requests at the same time. So we need something that keeps listening for requests and serves them around the clock. That’s where a model server such as vLLM comes into the picture. vLLM is built on PyTorch; it wraps the model in a service, exposes an HTTP endpoint (an address apps can send requests to), and batches requests from many users together so the GPU stays busy.A Closer Look at a Model ServerWhen a model server starts, it loads all the weights into VRAM once. After that, the server stays up and waits for requests.At its core, the model is a prediction machine: given your input, it predicts the next word. More precisely, it works on tokens, which are words or pieces of words. For each new token, it looks at all the tokens so far (your prompt plus everything it has written) and predicts the next one. It repeats this loop until it predicts a special end token or reaches a length limit. Because the answer is produced one token at a time and sent back as each token is generated, ChatGPT’s reply appears word by word.A Closer Look at the Token Prediction LoopWhen you send a big prompt to ChatGPT, there’s a short delay, and then the answer streams out steadily. The delay is called the prefill step, and the streaming is called the decode (or streaming) step.Fig 1The loop has two parts:1. The prefill step: when you ask a question, your prompt is first converted into tokens. The GPU then processes all of these tokens together, in parallel, in a single pass through the model. Along the way, it saves its intermediate results for each token (called the KV cache) so it never has to redo it. So whether you send 20 tokens or 2,000, the weights are read from VRAM only about once. A longer prompt just means more calculation, which is why a big prompt causes a longer delay. Once the first token is generated, the answer starts appearing on your screen. The time this takes is called TTFT (time to first token).2. The streaming step: from here, the model produces one token at a time. For every new token, the GPU has to read all of the weights from VRAM again, so this step’s speed is limited by memory bandwidth, not by the number of cores. That’s why the answer streams out at a steady pace, and why fast VRAM matters so much. The delay between two output tokens is called TPOT (time per output token).TTFT and TPOT are the two basic benchmarks for any LLM serving setup. They depend on the GPU, but also on the model’s size and the model server running it. Prefill speed (TTFT) depends mostly on the GPU’s compute power, while streaming speed (TPOT) depends mostly on its memory bandwidth.A Closer Look at CachingThe KV cache works well within a single request. However, once the model has responded, the cache is normally cleared, and the model remembers nothing. So the chat app keeps track of the history and sends the entire conversation to the model every time the user asks a question. The model then has to rebuild the KV cache for the whole conversation, again and again. As the chat grows longer, the wait before each answer (TTFT) grows too, and more and more tokens have to be processed.To solve this, model servers use prefix caching: the server keeps the KV cache for the earlier part of the conversation in VRAM, so when the next message arrives, it only has to process the new tokens. It also saves cost across users: if many requests start with the same text, such as a company’s standard instructions or a shared document, the server works through that shared part once and reuses its KV cache for everyone. The model still writes each answer fresh; it only skips re-reading the part it has already seen.Wrapping UpSo, where does the model live? In the GPU’s VRAM, where all of its weights are loaded once and stay put. What does the work when you send a request? Thousands of GPU cores, directed by CUDA, PyTorch and a model server such as vLLM. And why do the GPUs cost more than a car? Because a serious model needs tens or hundreds of GB of very fast memory sitting right next to those cores, and often several data-center GPUs linked together.We also saw how a single request is answered: a prefill step that reads your whole prompt at once (measured by TTFT), then a streaming step that produces the answer one token at a time (measured by TPOT), with caching so the model doesn’t redo work it has already done.Remember the four limits from the start? Each one now has a physical explanation. The capacity limit exists because every token you send adds to the KV cache in VRAM, and VRAM is finite. The knowledge limit exists because the weights stop changing the day training ends, so the model only knows what it learned. The behavioral limits are partly learned into the weights through safety training and partly layered on top with system prompts and guardrails. And the governance limits decide where those GPUs are allowed to sit and who can see the prompts that pass through them.So the next time an answer appears in seconds, remember what just happened: your prompt was turned into tokens, run through billions of tiny (w × X) + b calculations on a GPU, and streamed back to you one token at a time. That’s how an AI model thinks, and where it runs.Coming up next: One GPU, Many Users. So far, we’ve followed a single request. But a real deployment serves thousands of people at once. Next time, we’ll see how one GPU handles many requests at the same time: how the model server batches them together, shares the GPU’s memory between them, and keeps every user’s answer streaming without anyone waiting too long.How AI Models Think, and Where They Run: From One Weight to a GPU Server was originally published in Towards AI on Medium, where people are continuing the conversation by highlighting and responding to this story.