Skip to content

Lesson 10 of 13 · 20m

Your Own GPU: Self-Hosted Inference

Decode speed is bandwidth ÷ weights; run the VRAM math, quantize deliberately, and keep an OpenAI-compatible exit.

An open-weights model on your GPU turns a per-token bill into a hardware problem. Whether that's a good trade is arithmetic, not ideology — and sometimes privacy settles it before the math starts.

The physics of inference

Autoregressive decode is memory-bandwidth-bound: each output token requires reading essentially all of the model's weights once. Tokens per second ≈ memory bandwidth ÷ model bytes. A 70B model at fp16 is ~140GB of weights; an A100's ~2TB/s of HBM delivers roughly 14 tokens/second single-stream before batching. That arithmetic — not FLOPs — is why inference hardware shopping starts with memory bandwidth and VRAM.

VRAM math you can do on a napkin: a 7B model at fp16 ≈ 14GB of weights; quantized to Q4_K_M ≈ 4GB. Then add the KV cache — attention keys and values stored per token. For a Llama-3-8B-style GQA layout that's on the order of 128KB per token, so a 128k-token context costs ~16GB on top of the weights. "It fits on my card" means weights plus KV cache plus framework overhead.

The software stack

  • llama.cpp — the GGUF format, CPU- and consumer-GPU-friendly, quantization flavors Q4_K_M/Q8_0 and friends. The substrate under most local runners.
  • Ollama — llama.cpp with a package manager and an OpenAI-compatible endpoint at localhost:11434/v1. ollama run qwen3:8b is the dev-loop answer.
  • vLLM — the production server: vllm serve <model> exposes an OpenAI-compatible API with PagedAttention — KV cache paged like virtual memory, which took waste from ~60% to under 4% — and continuous batching, which is what turns one user's 14 tok/s into forty users sharing the card efficiently.

When it wins

  • Privacy and residency. Data never leaves your box. For regulated or customer-PII workloads this settles the decision before cost enters.
  • Steady, predictable volume. Fixed hardware amortizes; bursty traffic pays cloud premiums or queues.
  • No per-call marginal cost. Agent loops and eval sweeps that would run a five-figure API tab become electricity.

The break-even math

Rough numbers to sanity-check the decision: a consumer card running a quantized 7B-class model serves tens of tokens per second for the price of electricity — call it ~$300/month of hardware and power amortized. The same volume through a frontier API bills per token and lands in the thousands fast at agent-loop rates; through a mini-tier API it lands in the hundreds. Below that volume the API wins; above it hardware wins; anywhere regulated, the API loses on residency terms regardless of price.

When it loses

Frontier capability. The open-weights frontier tracks the closed one by months, and the gap lives exactly where hard reasoning lives. Ops burden is real too: drivers, CUDA, capacity planning, failover — and nobody to page but you. The sane default is hybrid: local small models for the easy bulk, API frontier for the tail, behind the same OpenAI-shaped interface so routing stays a config value.

The ops reality check

Before committing: who owns the GPU box at 3am, what happens when it OOMs mid-request, how you roll a model upgrade back, and whether your API fallback is wired and tested — not just written down. Self-hosting that works is self-hosting with an exit: the OpenAI-compatible interface (/v1/chat/completions) that Ollama and vLLM both expose means the fallback is a base-URL change, not a rewrite. Test the failover on a Tuesday afternoon, not during an outage.

Field notes

  • Licenses are terms: Meta's Llama community license has real restrictions (the 700M-MAU clause); many Mistral and Qwen releases are Apache-2.0. Read before shipping.
  • Quantize deliberately: Q4 is where quality starts to visibly drop on hard tasks; Q8 is nearly free. Benchmark on your eval fixtures, not the model card.
  • GGUF for llama.cpp/Ollama, safetensors for vLLM — same weights, different packaging.

Was this lesson helpful?

Sign in to rate

Keep reading

Related articles from the SudoSecurity blog.