Self-Hosting LLMs with Open Weights: A Practical Deployment Guide
This guide walks through the practical engineering of self-hosting large language models after full weights are released. It compares direct API calls with self-hosting, outlines four feasibility checks (data residency, request stability, latency budget, customization needs), and shows how to estimate VRAM for weights, KV Cache, and framework overhead. It also covers a four-layer service design, quantization and compression trade-offs, a staged rollout from shadow traffic to full production, and security and cost governance. Readers will get a repeatable path for deciding which traffic belongs on which deployment route and for running self-hosted inference under controlled cost.
1. Background: What Opening the Weights Changes
A research team recently released the full weights of its flagship large model. The news spread quickly across overseas technical communities, and an official account from a chip vendor publicly acknowledged it. The reason it moved so fast among developers is not that “there is one more model.” It is that deployment control shifts from a remote endpoint back to the people running the model.
For the past two years, most teams consumed large models by calling remote endpoints: send a request, get a result, while the model itself, inference scheduling, and autoscaling are all handled by the provider. This model has an obvious advantage: near-zero startup cost. The drawbacks are equally clear: data has to leave your environment, per-call cost grows linearly with volume, the capability ceiling is whatever parameter tier the provider exposes, and network jitter shows up directly as business latency.
With full weights available, there are now two parallel paths:
- Path A (API calls): zero operations, pay as you go, continuous model upgrades. A fit for spiky traffic, low data sensitivity, and validation-stage workloads.
- Path B (self-hosting): download the weights into your own environment and load and run them where compute is available. You can customize and optimize for the business, data never leaves your perimeter, and unit inference cost is amortized as utilization rises.
Path B is not a replacement for Path A; it is a complement. The real engineering decision is which traffic goes down which path, and the sections below give a practical way to decide.
2. Four Feasibility Checks Before Self-Hosting
Before downloading any weights, run a quick feasibility screen with four questions. It prevents a lot of wasted effort.
- Can data leave your environment? If the workload involves personal information, financial transaction details, medical records, or industrial process parameters, compliance requirements often rule out API calls outright, making self-hosting mandatory.
- Is call volume stable? Self-hosting is mostly a fixed-cost structure and only pays off at high enough utilization. A workload with low average daily requests and pronounced troughs will sit idle at low load for long stretches.
- What is the latency budget? API calls include a round trip over the public internet plus queueing, typically fluctuating in the hundreds of milliseconds. Local deployment compresses the network hop to the internal network, giving more controllable latency that suits real-time interaction.
- Do you need customization? If the business requires a domain-specific vocabulary, a specific output format, a specific safety policy, or even continued training at the weight level, only having the weights gives you room to operate.
3. Compute Sizing: VRAM Is the Hard Constraint
The most common reason self-hosting fails is not that the framework is hard to use. It is that VRAM estimates are too optimistic. A reusable rough calculation:
VRAM need ≈ parameters × bytes per parameter + KV Cache + framework and activation overhead# bytes per parameter referenceFP16/BF16 -> 2 bytesINT8 -> 1 byteINT4 -> 0.5 byte# example: a model of roughly 30 billion parametersweights_fp16 = 30e9 * 2 / 1024**3 # ≈ 55.9 GiBweights_int8 = 30e9 * 1 / 1024**3 # ≈ 27.9 GiBweights_int4 = 30e9 * 0.5 / 1024**3 # ≈ 14.0 GiB
The most easily overlooked term above is KV Cache. It grows with concurrency and context length, and with long contexts and high concurrency it can exceed the weights themselves. So the evaluation cannot stop at “does the model fit.” It also has to answer “how much concurrency can it serve once it fits.” The engineering approach: estimate an upper bound for KV Cache from the target concurrency and maximum context length, work backward to the remaining VRAM headroom, then set the batch size.
If a single GPU cannot hold it, there are two options. One is tensor parallelism, which splits a single layer’s weights across multiple GPUs; it involves frequent communication and demands high inter-GPU bandwidth. The other is pipeline parallelism, which splits by layer; communication volume is small but bubbles appear. In practice the two are often combined, together with weight quantization to push VRAM into a safe range.
4. Layered Design for the Inference Framework and Service
Self-hosting is not “getting a script to run.” It means delivering an operable service. A four-layer split is recommended:
- Model layer: weight files, tokenizer, and configuration, under a unified version number with checksums, to avoid a weight and configuration mismatch in production.
- Inference layer: batch scheduling, KV Cache management, and quantized execution. The core metrics are throughput and time to first token.
- Service layer: expose a unified interface and handle authentication, rate limiting, timeouts, retries, and fallback.
- Operations layer: logs, metrics, alerts, and capacity watermarks.
One key design in the service layer is the fallback path. When the inference layer is above its watermark, requests should shift smoothly to a backup path (for example a smaller model or a remote endpoint) rather than returning an error outright. Illustrative middleware logic:
def handle(request):if gpu_queue_depth() < HIGH_WATER:return local_infer(request) # primary self-hosted pathif fallback_enabled:return remote_infer(request) # fallback pathraise Overloaded("retry_after=200ms")
5. Quantization and Compression: Bringing Cost into a Usable Range
The direct benefit of open weights is the freedom to choose precision. Common approaches and their trade-offs:
- Weight quantization (INT8/INT4): VRAM and bandwidth usage drop significantly and throughput rises, but you need to evaluate whether the business metrics can accept the regression.
- Structured pruning: remove redundant attention heads or layers. High payoff but a large change, requiring effect re-validation.
- Distillation to a smaller model: route high-frequency, simple intents to the small model and complex requests to the large model, forming a cascade.
- Cache reuse: cache results for high-frequency repeated requests and reuse KV for long-document prefixes to cut repeated computation.
One reminder: any compression must be measured against your business evaluation set, not general public leaderboards. Fix a regression set that includes boundary samples, run it on every change, and record three numbers: quality, latency, and VRAM.
6. Rollout Path and Capacity Strategy
A four-stage rollout is recommended to avoid a one-time cutover:
- Shadow traffic: mirror real production requests to the self-hosted instance, log only without returning, and compare output consistency and latency distribution.
- Small-percentage canary: shift 1% to 5% by user or by request, and watch error rate and timeout rate.
- Ramp up: raise the percentage gradually against monitoring watermarks while load-testing peak concurrency to confirm rate-limiting thresholds.
- Full rollout and steady state: build a capacity model, scale out ahead of predicted traffic, and keep the fallback switch.
For elasticity, use a container platform to scale replicas, a message queue to smooth peaks and fill troughs, and wire logs and metrics into a unified logging service and a monitoring and alerting system. Metrics should cover at least: time to first token, per-token generation latency, queue depth, VRAM usage, actual batch size, timeout rate, and number of fallback triggers.
7. Security and Cost Governance
Self-hosting brings security responsibility back on-premises, and three things need to be in place. First, interface authentication and tenant isolation to prevent internal network abuse. Second, bidirectional filtering of inputs and outputs to guard against prompt injection and leakage of sensitive information. Third, integrity and access control for weights and configuration, with change auditing retained.
For cost governance, watch three levers: raise average batch size and utilization, use quantization to lower compute per unit, and use cascades and caching to cut wasted computation. Making “cost per thousand requests” and “cost per token” standing dashboards works better than looking at the bill at month end.
8. Conclusion
The significance of opening full weights is turning the large model from “a service you can only rent” into “infrastructure you can own.” For developers, the real capability is not how many weights you have downloaded, but whether you can build a complete engineering loop from compute sizing and quantization and compression through service delivery to capacity governance. Start with the four feasibility questions as a screen, then use shadow traffic and a small-percentage canary to control risk, and let self-hosting take on real business traffic step by step at a controlled cost.
