MilikMilik

Running Multiple LLMs on One GPU with Smart Multiplexing

Running Multiple LLMs on One GPU with Smart Multiplexing
Interest|High-Quality Software

What Advanced LLM Inference Optimization Really Means

Advanced LLM inference optimization on a single GPU means designing a parallel inference architecture and control plane that shares one backend, carefully rations VRAM for multiple models, and uses admission control to keep three or more agents responsive instead of crashing under memory pressure. Instead of launching isolated LLM processes that compete blindly for 8GB of VRAM, an optimized system centralizes GPU ownership in a C++ daemon, tracks per-model memory commitments, and refuses new workloads before they hit out-of-memory, trading naive concurrency for predictable throughput and latency under tight VRAM constraints. The uncomfortable truth: you will not fix an NVIDIA GTX 1080 with only 8 GB of VRAM by swapping prompts or agents. You will fix it by treating the GPU like a shared, scarce resource in an operating system you control. That mindset aligns with the broader shift from prompt engineering toward “loop engineering”—building the external execution loops and verification systems that coordinate model actions instead of micromanaging individual prompts.

Running Multiple LLMs on One GPU with Smart Multiplexing

From Loops to Parallel Inference Architecture

If you are building agent systems, you are now in the business of architecting loops, not one-off calls. Agent A writes code, Agent B reviews it for security flaws as it appears, and Agent C drafts documentation in parallel. To achieve a responsive developer experience, all three must be resident in memory and able to fire tokens at the same time—this is not a nice-to-have, it is the product requirement. Loop engineering matured from ReAct-style reasoning loops in 2022 through AutoGPT in 2023 and “Ralph loop” scripts in 2025, and by 2026 platforms embed commands like "/goal" and "/loop" directly into tools such as Codex and Claude Code. As these automation frameworks handle more routine code generation, the developer’s main job shifts from wordsmithing prompts to building verification systems and orchestration layers that keep autonomous loops aimed at verifiable outcomes. Parallel LLM inference is a direct consequence of that shift: the loops you design must share silicon without stepping on each other.

Why Three Small Models Kill an 8GB Card

On paper, three “small” instruct LLMs should fit on a GTX 1080. In practice, the first llama.cpp process quietly sabotages the other two. With a context window of 172032 and -ngl 99, llama-completion happily eats 6,536 MiB out of 8,192 MiB of VRAM before decoding a single token, and most of that is KV cache reservation, not model weights. When the second and third processes try to reserve their own KV buffers, their cudaMalloc calls hit “out of memory” and die. This is not a bug; it is llama.cpp doing the safe thing for a single process: pre-reserving KV cache so decoding never stalls mid-stream. The naive three-terminal approach adds insult to injury by spawning three independent CUDA primary contexts on the same card, each burning hundreds of megabytes of driver overhead before touching any tensors. The result is an OOM lottery with no shared accounting or queue. Tutorials that tell you to “run three agents on one GPU” without talking about VRAM bookkeeping are being optimistic about the silicon.

Running Multiple LLMs on One GPU with Smart Multiplexing

C++ Multiplexing and Admission Control: The Real Fix

The right response to this mess is not a clever algorithm; it is boring, disciplined bookkeeping. A small C++ daemon, lmxd, becomes a long-lived owner of the GPU and the single backend, speaking a tiny Unix-socket protocol (HELP, STATUS, LIST, REGISTER, UNREGISTER) with your agents. Agents no longer spawn their own llama-completion binaries; they ask the daemon to register models, and the daemon decides whether a new agent fits before loading anything. The whole admission policy lives in one number—90% of total VRAM—and one rule: admit a new agent only if currently_used + new_estimate is less than or equal to the 90% cap. If the ledger refuses, the daemon returns an ERR VRAM_LEDGER_DENY code and never touches the GPU. The model loader enforces one llama_backend_init call per device and keeps a refcounted map of GGUF paths so identical weights are mapped into VRAM once and shared. "That is the entire system: a number (90%), an honest ledger, a strict order of operations, and one shared backend." This is LLM multiplexing in its most useful form.

Running Multiple LLMs on One GPU with Smart Multiplexing

Bare Metal Trade-offs: Balancing Throughput, Latency, and Risk

Running your own C++ daemon on bare metal feels old-fashioned compared to managed inference platforms, but it buys you something those platforms often hide: control over every byte of VRAM and every context on the card. The daemon refuses to spawn extra CUDA primary contexts and calls llama_backend_init exactly once, cutting hundreds of megabytes of overhead that containers or multiple processes would consume. On a cramped 8GB card, that overhead is the difference between one agent demo and three agents working together. This parallel inference architecture is opinionated: you cap VRAM at 90%, share weights, and accept that some requests will be denied to preserve latency for the agents already admitted. Advanced implementations stack loops hierarchically—generation, verification, long-term optimization—which means more agents and more concurrent workloads on the same hardware. Poorly designed loops can still balloon costs, erode observability, or chase ill-defined goals without end, and loopmaxxing your way into infinite execution cycles will fail for subjective objectives. But if you care about LLM inference optimization and GPU memory efficiency, bare metal multiplexing plus strict admission control is the practical way to keep three LLMs alive on one aging GPU without waiting for a hardware refresh.

Running Multiple LLMs on One GPU with Smart Multiplexing

Milik earns a commission when you shop through our links, at no extra cost to you. This article was generated with AI from published sources and product data.

You May Also Like

Comments
Say something...
No comments yet. Be the first to share your thoughts!