From Easy Frameworks to Low-Level Engines: A Practical Path to Local LLM Inference Tuning
Local LLM inference often starts with an easy-to-use framework and later moves to a low-level engine when hardware is uneven and performance limits appear. This article explains why that second step matters, how to tune multi-GPU setups with unequal VRAM, which common settings are misunderstood, and how a hot-swap proxy plus a repeatable method can get more speed from the same hardware.
From Easy to Extreme: Two Stages of Local LLM Inference
1. Why a Second Leap Is Needed
Most developers who run large models locally follow a similar path. At first, an out-of-the-box inference framework is enough: a few commands start a model, switch models, and expose an API. The experience is smooth. Once the model choice is fixed, the hardware mix gets complicated, and performance requirements rise, that “highway” starts to cap the ceiling. Many low-level parameters stay hidden, multi-GPU memory is underused, and custom needs are hard to meet.
The second leap then happens naturally: use the underlying inference engine directly and control each inference parameter yourself. One developer’s case in the community is representative. The hardware was modest—a consumer GPU with 12 GB of VRAM, plus three modified mining cards, for about 42 GB of VRAM in total and 96 GB of system memory. Before careful tuning, the same model ran at 11 tokens/s. After the parameters were understood and reconfigured, speed rose to 21 tokens/s, nearly double. Same hardware, a completely different experience.
The lesson is simple: ease of use and performance ceiling are often a tradeoff. An easy framework lowers the barrier; a low-level engine unlocks potential. The return scales with how deeply you understand the settings.
2. Uneven Multi-GPU VRAM: The Real Tuning Battlefield
Tuning a balanced multi-GPU setup is relatively straightforward. Uneven VRAM is where skill shows. Take a layout such as one 12 GB card plus three cards around 11 GB. The key parameters include:
1. GPU layer offload (n-gpu-layers-style parameters)
This decides how many model layers are offloaded to the GPU. Too few layers leave the GPU underused. Too many cause out-of-memory errors and frequent swapping between system memory and VRAM, and performance drops sharply. With uneven cards, you need to calculate how many layers each card can actually hold.
2. Tensor split (tensor-split-style parameters)
This splits model weights across cards by proportion. An even split is a poor default when VRAM differs: the smaller cards run out first while the larger card sits idle. A better approach is to split weights in proportion to each card’s usable VRAM.
3. Batch size (batch-size / ubatch-size-style parameters)
Batch size directly affects throughput. Many developers keep a small batch even when VRAM is plentiful. With tens of gigabytes of total VRAM, it is reasonable to try a batch size around 1024 and a larger micro-batch. Prompt processing can speed up noticeably.
4. Expert-layer CPU offload (-n-cpu-moe-style strategy)
For MoE models, placing expert layers on the CPU and attention layers on the GPU is often simpler and more effective than complex regex-style tensor offload rules. This is a practical pattern the community has verified repeatedly.
Calculating these values by hand is tedious. A useful approach is an automated tool that inspects the VRAM layout, decides which layers stay on GPU and which spill to CPU, and prints ready-to-use command-line parameters. This kind of “VRAM adapter” cuts the trial-and-error cost of multi-GPU tuning.
3. Common Misconceptions About Quantization and Attention
- Quantization format: At the same parameter count, newer formats such as MXFP4-style quantization are often better in both quality and speed than older methods. Do not assume smaller is always better. Prefer the highest-quality format that still fits the remaining VRAM.
- Flash Attention: Mainstream inference engines enable it by default, so manual setup is usually unnecessary. Watch instead for incompatible combinations that you turn on by hand.
- Do not run the inference service as root: There is no performance gain, and there is a security cost. This is a typical piece of advice that spread by repetition rather than evidence.
- Unified-memory-style switches: Some environment variables exist only as patches for specific hardware. They are not general optimizations. Turning them on blindly can cause crashes or worse performance.
4. Hot Model Switching: Letting Multiple Backends Coexist
Advanced users often hit this problem: different inference backends excel at different models. A newer engine is faster for some models, while a community branch is better for others. The practical fix is a model hot-swap proxy layer. It sits above several backends, routes by model name, starts the matching backend, loads the matching model, and releases resources when the request finishes.
The payoff is direct: switching backends can mean changing only a few characters in the config. In an image-generation workflow, VRAM can also move cleanly between a text model and an image pipeline. This is inference orchestration. It is the same idea as cloud setups that place multiple model services behind a gateway and a container platform with load balancing.
5. A Reusable Tuning Method
Community discussion can be turned into a general process:
- Fix the target model and hardware list. Record usable VRAM per card and understand memory-bandwidth limits.
- Measure a baseline. Record tokens/s with default parameters as the control.
- Change one variable at a time. Adjust layers, then split, then batch size, and compare each result.
- Pick the right quantization format. Prefer the highest-quality format that still fits.
- Use automation as a starting point. Let a VRAM-fit tool generate initial parameters, then fine-tune by hand.
- Orchestrate multiple backends when needed. Use a hot-swap proxy so each model runs on the engine that suits it best.
Closing
The appeal of local inference is full control: the more you understand, the more performance the hardware returns. An out-of-the-box framework fits the exploration stage; a low-level engine fits the refinement stage. They are not opposites—they are two phases of the same journey. When you are willing to learn what each parameter actually does, the same GPUs and memory can give you a very different answer.
