Serving Open-Weight Models at Scale
Host open models in production with vLLM, TGI or SGLang: batching, KV cache, quantization and autoscaling on GPUs.
Advanced · about 6 hours · difficulty 4/5
Learn first: Running Open-Weight Models Locally, Deploying LLM-Powered Services
Running a model on your laptop with Ollama is different from serving hundreds of concurrent users. Production inference servers are built to squeeze throughput out of expensive GPUs.
Inference servers
- vLLM: the most widely used open-source server, with an OpenAI-compatible API, continuous batching and PagedAttention for efficient KV cache memory.
- SGLang and Hugging Face TGI: strong alternatives with similar features.
- NVIDIA TensorRT-LLM / Triton: maximum performance on NVIDIA hardware with more setup.
- Managed endpoints (Hugging Face Inference Endpoints, cloud AI platforms, specialist GPU clouds) handle the infrastructure for you.
Key concepts
- Continuous batching: new requests join the running batch every step, which keeps GPUs busy.
- KV cache: memory holding attention state for each active sequence; it limits how many long conversations you can serve at once.
- Quantization (such as 8-bit, 4-bit, FP8) shrinks memory and increases speed with small quality loss. Always evaluate.
- Tensor parallelism splits a large model across several GPUs.
- Prefix caching and speculative decoding speed up repeated prompts and generation.
- Multi-LoRA serving hosts many fine-tuned adapters on one base model.
When self-hosting makes sense
Data residency or privacy requirements, very high steady volume where GPUs beat per-token pricing, custom fine-tuned models, or offline environments. For spiky or low traffic, hosted APIs are usually cheaper.
Good enough to move on
You can deploy an open model with vLLM behind its OpenAI-compatible API, load test it, and report throughput, latency and cost per million tokens compared to a hosted API.
Key concepts
- vLLM
- SGLang / TGI
- Continuous batching
- KV cache and memory limits
- Quantization formats
- Tensor parallelism
- Speculative decoding
- Load testing and cost per token
Mini project
Serve a small open model with vLLM on a rented GPU, load test it at 1, 10 and 50 concurrent users, and write up tokens per second, p95 latency and estimated cost per million tokens.
Check yourself
Why does continuous batching increase throughput, and what happens to KV cache memory as conversations get longer?
Free resources
- vLLM documentation (vLLM)
- Hugging Face Text Generation Inference (Hugging Face)
- SGLang documentation (SGLang)