Running Long-Context LLMs on Two Consumer-Grade GPUs: A Practical Deployment Guide

    This guide explains how to deploy a long-context language model on two 32 GB GPUs using quantization, KV-cache optimization, multi-slot scheduling, and hardware-specific backend adaptations. It covers memory budgeting, MoE model selection, prefill and decode performance, tool-calling reliability, and mixed deployment of large and small models for agentic workloads.

    1. Why Long-Context Inference Matters

    As AI agents and automated workflows become more common, LLM inference is no longer limited to single-turn question answering. Models increasingly need to process context windows containing tens or even hundreds of thousands of tokens.

    In coding assistants and workflow automation systems, the system prompt, tool definitions, conversation history, and file contents can easily produce an initial context of tens of thousands of tokens. The context may continue to grow over multiple rounds of interaction. This creates three major deployment challenges:

    1. VRAM capacity: The longer the context, the more VRAM is consumed by the KV cache. Memory often becomes the bottleneck before compute capacity.
    2. Prefill speed: If the initial long-context prefill is too slow, the user experience quickly deteriorates.
    3. Tool-calling reliability: Agentic applications frequently require the model to produce structured tool-call instructions. Invalid output formats can interrupt the entire task chain.

    This article uses a representative deployment on two mixed consumer/professional GPUs as a reference and extracts general techniques for developers facing similar requirements.

    2. Hardware and VRAM Planning

    The setup discussed here uses two older data-center-class GPUs with 32 GB of VRAM each, providing 64 GB in total. These GPUs offer substantial memory at relatively low cost, but their compute performance and interconnect bandwidth are limited. In most cases, the cards communicate over PCIe rather than a high-speed GPU interconnect.

    As a result, the deployment strategy should focus on using the available VRAM efficiently while avoiding unnecessary compute overhead.

    A rough VRAM budget can be divided into the following components:

    • Model weights: With Q8_0 quantization, the dense portion of a model with roughly 26 billion parameters occupies more than 20 GB.
    • KV cache: This is the most flexible component and has the greatest direct impact on the maximum supported context length.
    • Activations and compute buffers: These depend on factors such as batch size and sequence length.
    • Headroom: Some memory should be reserved for additional instances or a second model.

    Mixture-of-experts (MoE) models can be particularly advantageous in this environment. Although their total parameter count may be large, only a small subset of parameters is activated for each token. For example, a model may activate only around 3B–4B parameters per token.

    This provides two important benefits:

    • The amount of computation is relatively low, allowing decode throughput to remain competitive.
    • VRAM is used primarily to store weights rather than to support intensive computation, which makes these models suitable for older GPUs with ample memory but limited compute capability.

    This is the fundamental reason MoE models are attractive for consumer and older data-center GPUs: they trade additional memory capacity for reduced compute requirements.

    3. Choosing the Inference Engine and Backend

    3.1 Engine Selection: Why Use a Lightweight Runtime

    There are generally two deployment paths: heavyweight inference-serving frameworks and lightweight local inference engines. This setup uses the latter for several reasons:

    • Support for less common hardware architectures is often updated quickly, with active community contributions.
    • Multiple quantization formats are available, including Q8_0 and Q6_K, allowing a more precise balance between quality and VRAM usage.
    • Features such as continuous batching, KV-cache management, and multi-slot concurrency are often built in.
    • Configuration is highly granular, allowing direct control over context length, batch size, cache type, and other low-level parameters.

    3.2 Backend Adaptation for Non-CUDA Hardware

    For AMD GPUs, the official backend is generally based on the ROCm ecosystem. However, specific hardware—especially older GPU models—may encounter unsupported operators, build failures, or unoptimized performance in official releases.

    Common community-driven approaches include:

    1. Changing the compilation targets: Add the architecture code corresponding to the target GPU to the build configuration.
    2. Adding or replacing operators: Replace unsupported kernels or fall back to more general implementations.
    3. Tuning the BLAS library: Replace or rebuild the underlying linear algebra library to improve performance on older GPUs.

    A representative build configuration looks like this:

    1. cmake -B build \
    2. -DGGML_HIP=ON \
    3. -DAMDGPU_TARGETS=gfx906 \
    4. -DCMAKE_BUILD_TYPE=Release
    5. cmake --build build --config Release -j

    The architecture code and dependency versions must be adjusted for the actual environment. Before compiling, it is useful to search the relevant community issue trackers for compatibility reports involving the same GPU model. This can prevent a significant amount of trial and error.

    3.3 Context and Concurrency Configuration

    In the example deployment, three concurrent slots provide a combined context capacity of approximately 780,000 tokens. The main trade-offs are as follows:

    • KV-cache quantization: If the runtime supports quantized KV caches, such as q8_0, cache memory consumption can be reduced substantially. The resulting precision loss is usually small, making this a worthwhile trade-off for long-context workloads.
    • Per-slot context versus concurrency: With a fixed total cache budget, increasing the number of slots reduces the context available to each slot. Agentic workloads often begin with a large initial context, so it is usually better to run fewer slots with sufficient per-slot capacity.
    • Swap and offloading: Some runtimes can move the KV cache of inactive slots to system memory. This can increase total capacity, but it also introduces additional latency.

    4. Performance and Bottleneck Analysis

    Under this configuration, the approximate measured performance was:

    • Long-context prefill: Close to 1,000 tokens per second for an initial context of more than 100,000 tokens.
    • Decode: Approximately 50 tokens per second.
    • Additional capacity: The remaining VRAM was sufficient to load another small MoE model in the 20B parameter range for low-frequency auxiliary tasks.

    4.1 Why Prefill Can Approach 1,000 Tokens per Second

    Prefill is compute-intensive. Throughput is primarily determined by compute capacity and weight bandwidth. Because an MoE model activates relatively few parameters per token, and because sufficiently large batches can be used, older GPUs may still achieve strong prefill performance.

    This is particularly important for agentic applications. If filling an initial system prompt containing tens of thousands of tokens takes several dozen seconds, the application becomes difficult to use in practice.

    4.2 Setting Realistic Decode Expectations

    Decode is more bandwidth-intensive. Its speed is approximately determined by the time required to read the active weights at each generation step.

    Around 50 tokens per second is generally sufficient for a smooth single-user interactive experience. With multiple slots, the same deployment can serve several sessions concurrently.

    If higher throughput is required, possible options include:

    • Using a lower quantization level, such as Q6_K, to reduce bandwidth pressure.
    • Enabling speculative decoding, in which a smaller model helps accelerate generation by the larger model.

    4.3 Reusing Spare VRAM with Multiple Models

    The idea of loading a second small model into the remaining VRAM is worth emphasizing. The long-context primary model can handle complex tasks, while the smaller model handles lightweight operations such as health checks, summary compression, and simple classification.

    A unified scheduling layer can route requests to the appropriate model. This mixed deployment approach improves utilization of expensive VRAM and is a practical strategy for multi-GPU systems with limited compute resources.

    5. Tool-Calling Reliability: An Often-Overlooked Selection Criterion

    In agentic applications, models must produce tool-call arguments in strict formats, such as JSON. In practice, models can differ significantly in tool-calling reliability. Under frequent tool use, some models may produce malformed output, hallucinated parameters, or incorrect call timing, causing the task chain to fail repeatedly.

    The following selection guidelines are useful:

    1. Run tool-calling benchmarks based on real workloads: Do not rely only on general capability leaderboards. Test the actual tools and end-to-end workflows used by the application.
    2. Check grammar and structured-output support: A capable inference framework can use grammar constraints to force the model to produce valid JSON, significantly reducing failures caused by model-level instability.
    3. Implement retry and fallback logic: When parsing fails, send the error information back to the model and retry instead of failing immediately.

    6. Conclusion

    This deployment demonstrates that two older 32 GB GPUs, combined with a lightweight inference engine and carefully planned quantization and scheduling, can support a local inference environment with hundreds of thousands of tokens of total context, multiple concurrent sessions, and reliable tool calling.

    The main principles are:

    • Choose an MoE architecture to trade surplus VRAM for limited compute capacity.
    • Use quantization effectively, combining Q8_0 weight quantization with KV-cache quantization to balance quality and capacity.
    • Plan slots around the KV-cache budget before deciding on the concurrency level.
    • Adapt the backend when necessary, since non-mainstream hardware may require community-developed fixes and tuning.
    • Run large and small models together to make use of every available gigabyte of VRAM.

    For teams and individual developers with limited budgets who want to build long-context agentic applications, this approach provides a practical and broadly applicable deployment reference.