Local LLM Selection and a Unified Inference Gateway: A Practical Guide
This article explains how to select and run local large language models when memory capacity, not peak compute, is the real bottleneck. It covers capacity and bandwidth trade-offs, storage tiering for faster model loading, replacing one-process-per-model setups with a unified model manager and an OpenAI-compatible local gateway, dual admission checks, eviction protection, and observability for capacity governance.
1. Reframing the Problem: Local Inference Is Capacity-Bound, Not Compute-Bound
When most people deploy a large language model locally, their first instinct is to check compute specs. In practice, the experience ceiling is usually determined by two other factors: memory capacity and memory bandwidth.
The reason is straightforward. Model weights must reside entirely in memory that the compute units can address directly. If capacity is insufficient, no amount of peak floating-point performance will let the model load. During decoding, tokens are generated serially one at a time, which makes the workload memory-access bound: bandwidth directly determines how many tokens per second you get.
Consumer discrete GPUs typically provide 16GB to 32GB of VRAM. Even with 4-bit quantization, models in the 30B parameter range and above are hard to fit comfortably, let alone leaving room for the KV cache. Unified memory architectures, by contrast, allow a large share of system memory to be allocated to the graphics and compute units as a usable memory pool, which mitigates the capacity problem at its root.
The trade-off is equally clear: unified memory has lower bandwidth than a high-end discrete GPU, so decoding speed has a hard ceiling. The sensible chain of trade-offs is therefore: trade bandwidth for capacity, trade capacity for context length, and trade context length for agent capabilities. If your goal is a high-throughput scenario such as frequent code completion that demands very high output rates, a local unified memory setup is not a good fit. But if you want the model to act as the “brain” for long-document understanding and multi-turn tool calling, a decoding speed of 20–40 tok/s is already usable.
A practical evaluation order:
- Capacity: quantized weight size + peak KV cache + runtime overhead, with more than 30% headroom left.
- Bandwidth: the hard upper bound on decoding speed, which must match the business tolerance for latency.
- Context: KV cache growth from long context is linear, so capacity headroom ultimately translates into usable context.
- Ecosystem and quantization format support: whether mainstream inference runtimes can fully cover the required operators, avoiding fallback to inefficient paths.
2. Storage Tiering: Don’t Let Loading Time Eat the Experience
Model loading is an easily overlooked step. Tens of gigabytes of weights on a slow link can take tens of seconds to cold-start, which directly hurts the interactive experience. The practical approach is to tier storage:
- Put weight files that need memory-mapped (mmap) random reads in the high-speed slot; the higher the sequential read bandwidth, the faster the load.
- Use the low-speed slot only for cold backups and archives, storing compressed packages, datasets, logs, and other content that does not need random reads.
- Enforce one rule: weight files that need mmap must never sit on a slow link, otherwise random-read amplification will multiply loading time.
Also reserve enough filesystem cache space for the weight directory, and avoid letting other large file write tasks compete for I/O.
3. From “One Model, One Process” to Unified Hosting
The most common early approach is to open a terminal and a port for each model and start whichever one you need. This quickly spirals out of control as the number of models grows, with four typical symptoms: nobody can account for memory usage; starting a new model directly exhausts system memory; model names and addresses are scattered across five or more places in each caller’s configuration; and forgotten processes hold the memory pool indefinitely, so the model you actually need cannot start.
The converged architecture fits in two sentences: all models are managed by a single unified model manager, and all calls go through one local gateway that is compatible with the OpenAI interface protocol. The manager itself can be a lightweight service listening on the local loopback address, with four responsibilities.
1. Budget Accounting
Set a budget for the entire memory pool, for example 112GiB available with an 8GiB floor reserved for the system. Each model registers its estimated usage (weights + estimated KV cache + runtime margin). Before startup, the manager checks the books and rejects the request outright if it exceeds the budget, rather than pushing the system into swap.
2. Measured Admission
Book accounting is not trustworthy on its own: after weights go through mmap, many pages enter the page cache, so the free memory reading can “look like a lot” while actually being unreclaimable. A second gate is therefore required: measured available memory must be ≥ the floor + the estimated usage + a safety margin. Only when both gates pass is the model admitted.
def admit(model_est_gib, floor_gib=8, margin_gib=4, budget_gib=112):used = sum(m.est_gib for m in registry if m.running)if used + model_est_gib > budget_gib:return False, "budget_exceeded"avail = read_mem_available_gib() # measured available memoryif avail < floor_gib + model_est_gib + margin_gib:return False, "actual_memory_insufficient"return True, "ok"
3. Eviction Protection and Idle Reclamation
Mark critical models as resident so they cannot be automatically evicted. For models idle beyond a threshold, perform a graceful unload and clear their corresponding cache pages at the same time. A good eviction order is by “idle duration × estimated usage,” releasing the targets with the largest payoff first.
4. A Unified Gateway and a Single Configuration Source
The gateway exposes one interface externally and routes internally by model name to the corresponding backend process. The business side only knows model aliases and no longer needs to be aware of ports. Model names, addresses, timeouts, and retries all converge into one configuration, so a single change takes effect globally.
4. Observability and Capacity Governance
Once hosting is unified, you need a minimal but usable observability surface: record the deviation between the estimated and measured usage for each load, to refine the estimation model; record queue time, time to first token, and decoding speed, to tell whether the bottleneck is capacity or bandwidth; and set tiered alerts on memory watermarks, proactively rejecting new requests before the floor is approached rather than waiting for the system to crash.
If local resources cannot host all models, a hybrid strategy works: keep hot models resident locally, load cold models on demand, and offload batch and offline tasks to general-purpose cloud compute, leaving only the interactive path local. The same tiering applies to a combination of object storage for weights and archives with local disk.
5. Conclusion
Local LLM selection should not start from compute specs, but from the balance among capacity, bandwidth, and context. The focus of deployment is not single-model tuning, but building an engineering loop of “unified hosting + unified gateway + dual-gate admission + observability.” With this approach, running multiple models side by side goes from uncontrollable to budgetable, reclaimable, and observable, so local inference can reliably handle long-context and agent workloads.
