Running LLMs Locally on Consumer GPUs: Quantization and Multi-GPU Inference
This article explains how to deploy a mid-sized (~27B parameter) language model on local workstation hardware. It covers memory and hardware estimation, quantization bit-width trade-offs, layer and tensor splits across heterogeneous devices, key inference parameters, and the trade-off between reasoning depth and latency.
1. Background: Why Run Mid-Sized Models Locally
Local LLM deployment is driven by three main needs. The first is data boundaries. Scenarios involving internal documents, code, and customer information are not suitable for uploading to external services. The second is cost control. Sustained call volume can be amortized on local hardware into a one-time hardware investment plus electricity costs. The third is customizability. Developers can adjust inference parameters, context length, and system prompts themselves without being constrained by server-side policies.
A model with about 27 billion parameters is at a representative point. Its capability is sufficient for tasks such as code assistance, document understanding, and multi-step reasoning, while quantization can compress its size into a range that a personal workstation can handle. Discussing deployment methods at this scale is a useful reference for most developers.
2. Estimate Hardware Requirements First
Before deployment, estimate VRAM or memory requirements. The approximate formula for weight size is:
Weight size (GB) ≈ parameters (billions) × bits per parameter ÷ 8
For about 27 billion parameters with 4-bit quantization, 27 × 4 ÷ 8 = 13.5 GB. Actual released quantized files are usually slightly larger than this value due to mixed precision and metadata.
In addition to weights, inference also requires allocating cache for context. Cache size grows with context length and is affected by the number of model layers, attention head configuration, and cache precision. The runtime framework itself also consumes extra space. Therefore, being able to fit the model file into VRAM does not mean it will run smoothly. The reserved headroom should be based on actual testing; the longer the context, the more headroom is required.
3. Quantization Bit-Width Trade-offs
Quantization is a technique that trades precision for size. Common bit widths include 8-bit, 6-bit, 5-bit, 4-bit, and lower. The lower the bit width, the smaller the file, the lower the memory bandwidth pressure during inference, and the more obvious the loss in output quality. Generally speaking, 4-bit quantization maintains good quality on many general tasks. On error-sensitive tasks such as mathematical reasoning and long-chain code generation, higher bit widths usually produce visible differences.
When selecting a bit width, follow these steps:
- Define the task type and list the metrics that matter most, such as accuracy, time to first token, or overall throughput.
- On the same device, compare two or three quantized versions using the same test set.
- If VRAM allows, prefer the highest bit width that can fit entirely on the device.
4. Weight Splitting Across Heterogeneous Devices
When a single accelerator does not have enough VRAM to hold all weights, model layers can be distributed across multiple devices. There are two common approaches. Layer-wise splitting means different devices handle different layers, and data flows through each device in sequence. Tensor splitting means the weights of the same layer are split across multiple devices for parallel computation.
Allocation ratios should be determined based on device compute, VRAM capacity, and memory bandwidth. Below is an illustrative configuration idea; it does not correspond to the real interface of any specific tool:
# Illustrative: distribute model layers by VRAM ratiomodel_path = ./models/model-q4-weights # Quantized weight filesgpu_layers = all # Place as many layers as possible on accelerator devicesdevices = [device_0, device_1] # Primary accelerator and auxiliary devicesplit_ratio = [0.85, 0.15] # About 85% of weights on the primary GPU, 15% on the auxiliary devicesplit_mode = layerctx_size = 16384
With layer-wise splitting, data must be passed between devices, and each device’s computation time accumulates in sequence. The memory bandwidth of auxiliary devices is usually lower than that of the primary device, so if the allocation ratio is too high, overall speed may instead decrease. During tuning, start with a small auxiliary ratio, increase it gradually, and record the throughput change each time.
5. Meaning of Key Inference Parameters
- Context length: Determines the total length of input and output that can be accommodated, and directly affects cache usage.
- Batch size: Affects the degree of parallelism in the prompt processing (prefill) stage. The larger the batch, the faster the prefill, but the higher the peak VRAM usage.
- Thread count: Affects CPU-side scheduling and data preparation. When all layers are placed on accelerator devices, its impact on overall speed is usually small.
- Number of concurrent requests: Processing multiple requests simultaneously can amortize fixed overhead, but it dilutes the resources available to each request. On a personal workstation, single concurrency usually has the lowest latency.
- Attention computation optimization: Can reduce VRAM usage and improve speed, provided that the runtime and hardware support the corresponding implementation.
6. Reasoning Depth and Latency Trade-offs
Models that support thinking mode generate a segment of intermediate reasoning content before giving an answer. The deeper the reasoning, the more internal tokens are generated, and the time to first token and total duration increase accordingly. Accuracy is usually higher on multi-step reasoning and questions that require verification.
In practice, reasoning depth can be treated as an adjustable knob:
- Low setting: Suitable for format conversion, simple Q&A, and interactive scenarios with high requirements for response speed.
- Medium setting: Suitable for general code writing and document summarization.
