Why self-hosting models makes sense for growing organizations

In an AI-forward organization platform teams become inference teams. Coding assistants cannot send source code to third parties and frontier model bills increase month to month. Support tools also need internal data that a hosted model cannot reach. Organizations want to run these models themselves and open models now make that practical. Hugging Face hosts more than two million open models and the best of them compete with closed models. DeepSeek released R1 in January 2025 and it matched OpenAI's o1 on math and coding benchmarks about a month after o1 came out. When you run your own model you control latency uptime and where your data goes. At high volume you can also cut costs by about 80 percent. The work suits platform engineers. The price of a fixed level of AI capability falls roughly 10x a year and most of that comes from how models are served not from better GPUs. Upbound the company behind Crossplane and Modelplane saw this firsthand. In its Project Champagne blog series the team ran its own models and found that vLLM and scheduling worked. The time went to TLS identity timeouts storage IAM and observability.

The inference engine turns model weights into an API surface

An inference engine like vLLM or SGLang is the server that turns model weights into an API. For a platform engineer the closest mental model is a stateful database server with a GPU attached. It loads a large dataset into memory at startup and keeps per-session state. It also schedules work internally and answers over HTTP. Ollama on a laptop is the same idea at small scale and every hosted model API runs one behind the scenes. Unlike a database the engine keeps its working set in GPU memory not RAM. GPU memory is small and expensive so most tuning is about deciding how much of it each request gets.

The inference stack has four layers. At the bottom kernels do the arithmetic you rarely choose them directly. Above them sits the engine. Above that a control plane deploys and manages engines because sooner or later you run more than one. On top a gateway routes traffic across models and replicas. Requests pass through the gateway to an engine which runs kernels on the GPU. The control plane deploys and manages the gateway and engines but no request passes through it.

Tokens the unit language models work in and why they matter

A token is the unit a language model works in roughly a word or word fragment. Context windows prices and speeds are all counted in tokens. When someone quotes tokens per second they mean this unit. Weights are fixed and the KV cache grows with load. Size for both as you would a database footprint and working set. Weights are the fixed footprint. Most models are released at 2 bytes per parameter BF16 or FP16 so an 8B model needs about 16 GB and it has to live in GPU memory not system RAM. On a 48 GB L40S that leaves about two-thirds of the card for everything else. That number is the same for one user or a hundred.

The KV cache is the working set. Each new token is computed against every token before it. Rather than recompute that history the engine keeps the attention keys and values for every token in flight. Its size scales with context length multiplied by the number of concurrent conversations much like a session store that grows with both session size and user count. You can estimate the KV cache per token from a models config: KV bytes per token = 2 × layers × KV heads × head dimension × bytes per value. For Llama 3 70B at FP16 (80 layers 8 KV heads head dimension 128) that is about 320 KB per token. One 128K-token conversation needs about 40 GB of cache. At that size the KV cache usually limits how many users a GPU can serve.

Weights and the KV cache fixed footprint and growing working set

Watch for these sizing mistakes. Mixture-of-experts MoE models keep every weight resident. A model with 320B total parameters and 18B active still needs about 320 GB at FP8 only compute scales with the active parameters. Read the checkpoint size not the dtype table. While self-hosting its own models for Project Champagne Upbound estimated one MoE model at about 315 GB from its dtypes Part 2. The real checkpoint was 177.7 GB because the experts were stored in a 4-bit format. Leave room for runtime overhead. CUDA graphs activations and memory fragmentation all take space. A model that fits at startup can still run out of memory days later.

Two phases prefill and decode with opposite bottlenecks that set latency

Each request runs in two phases on the same GPU and they are limited by different things. Prefill reads the whole input in parallel including the system prompt and tool definitions as well as the conversation history. It produces the first token and the KV cache. It is limited by compute and sets time to first token TTFT. Decode writes the answer one token at a time. Each token needs a pass that reads all active weights plus the KV cache from memory. At long context reading the cache can cost more than reading the weights. It is limited by memory bandwidth and sets time per output token and tokens per second.

Generating one token does one or two floating-point operations per byte read from memory depending on weight precision. An H100 needs about 295 operations per byte to stay busy. That means one request uses a small fraction of the chip while the compute units wait on memory. Peak compute has grown about 3x every two years against about 1.6x for memory bandwidth. Nearly every optimization either moves fewer bytes per token or spreads each byte across more tokens. Because the phases have opposite bottlenecks a technique that speeds one often does little for the other. That is why benchmarks report TTFT and tokens per second separately.

Metrics that matter for inference performance and capacity planning

Time to first token TTFT queueing plus prefill how long the user waits before anything appears. With reasoning models the engines first token may be hidden thinking measure the first token the user sees. Time per output token or inter-token latency decode speed per stream speculative decoding and memory bandwidth show up here. Tokens per second per user interactivity or the models typing speed falls as batch size rises. Throughput total tokens per second across all users rises as batch size rises. Goodput throughput that still meets your latency targets the number to plan capacity with. End-to-end latency total request time depends on how much the model writes a healthy 190-second answer is normal for long generations. Percentiles p50 p90 p99 of each latency users feel the tail not the average. Errors and refusals failed or rejected requests count refusals as errors or a context cap can look like a speedup. Cost per million tokens GPU cost divided by tokens served compare at the load you actually run.

Cost per million tokens converts a GPU price and a throughput into one comparable number: GPU cost per hour divided by tokens per second × 3600 × 1000000. Spheron worked example: a GPU at $2.90 an hour sustaining 1200 tokens per second costs about $0.67 per million tokens.

Latency versus throughput batching trade-offs that affect users

Batching more requests together raises total throughput and slows each individual user. Interactive chat and coding favor latency. Overnight batch jobs favor throughput. It is the same trade-off as tuning a database for transactions or for analytics. Write down the workloads constraints before you tune anything.

Working with coding agents and long prompts what changes

Coding agents and other agentic workloads stress every part of this picture. Upbound measured this in Part 5 of its Project Champagne series where about 10 of its engineers ran Claude Code and other coding agents against a self-hosted model. Their traffic looked like this prompts are long the median prompt was 59K tokens and the p90 was 125K. Prompts are mostly repeated about two-thirds of prompt tokens hit the prefix cache because agents resend their transcript on every turn. Thinking is hidden a reasoning model can think for more than a minute before its first visible token. Every timeout between the agent and the model has to allow for that. Load depends on the client short-prompt sessions launch subagents and can keep more requests in flight than long-prompt sessions. Plan capacity in requests in flight rather than seats. Sessions run for hours streams tool calls and credentials all have to keep working for that long.

When to adopt each concept signal-driven approach

Each row gives the symptom that tells you its time to act in roughly the order teams need them. Fitting the weights choose a model precision and GPU so the weights fit with room to spare the engine fails to start or starts with almost no KV cache left. Continuous batching and paged KV cache share each GPU pass across requests and hand out cache in small blocks already on by default in vLLM and SGLang check it do not build it. Quantization store weights in fewer bits and give the freed memory to the KV cache requests queue while the GPU still has compute to spare. Prefix caching reuse the work already done on repeated prompt openings already on by default in vLLM and SGLang watch the hit rate once your clients are agents or chat apps that resend long histories. Speculative decoding draft several tokens and verify them in one pass individual responses stream too slowly even at low load. Gateway and control plane route between replicas and manage engines declaratively you add a second model a second replica or a second cluster. Sharding across GPUs split one model with tensor pipeline or expert parallelism the model will not fit on one GPU plan this before you deploy. Autoscaling add and remove replicas on queue depth and KV cache use idle GPUs show up on the bill or queues build at peak hours. Disaggregation run prefill and decode on separate GPUs long prompts stall streaming at scale and you have RDMA-class networking. Most teams need only the first few rows on day one add the rest when their signals show up.

Running inference in production start from use cases not hardware

Each use case sets different requirements. In Project Champagne coding agents needed long context without quality loss reliable tool-call parsing streaming sessions that last hours and an Anthropic-compatible API for Claude Code. Chat needed low time to first token real concurrency and an OpenAI-compatible API for existing tools. The platform needed TLS on a real hostname and identity tied to the company domain. It also needed observability that tells a healthy engine from a busy one and correct placement without babysitting. Separate interactive workloads from batch workloads they need different targets and often different deployments. Write the pass and fail bar down before you test anything.

Pick models deliberately evaluate on your own tasks public benchmarks measure someone else workload. Start small then grow a small MoE model with a few billion active parameters builds operating experience faster and costs less to get wrong. Most teams need only the first few rows on day one add the rest when their signals show up.