Long-Context MoE Inference on Older GPUs: Practical Deployment and Optimization

    This article explains how to run Mixture-of-Experts (MoE) models on older 32 GB GPUs for long-context local inference. It covers VRAM budgeting, KV-cache sizing, layer-split parallelism over PCIe, 8-bit weight quantization, prefill/decode trade-offs, prefix caching, reliable tool calling, co-resident auxiliary models, and a deployment checklist. Using a representative two-GPU configuration, it shows how to make practical use of spare VRAM and memory bandwidth on older cards while keeping the deployment stable, cost-aware, and replaceable.

    Introduction: Small Footprint and Long Context Are Changing the Economics of Local Inference

    Previous-generation 32 GB data-center compute cards are now inexpensive on the used market, and their single-card VRAM capacity is far higher than that of most consumer GPUs. However, when deploying mainstream open-weight models on them, three problems often appear at the same time:

    • Compute is relatively weak, so generation is slow.
    • Total model parameters far exceed the capacity of a single card.
    • Official software stacks often no longer support this hardware generation.

    Mixture-of-Experts (MoE) architectures make the combination of “small active footprint + long context” practical again. A typical setup uses two 32 GB GPUs to form a 64 GB VRAM pool and runs an open-source MoE model with about 26 billion total parameters and about 4 billion activated parameters per token. With 8-bit integer weights loaded, the setup can support nearly 800,000 tokens of context across multiple concurrent slots.

    In testing, when initializing a coding assistant and filling a prompt of tens of thousands of tokens, prefill can process close to 1,000 tokens per second. During sustained generation, a single request typically outputs at tens of tokens per second.

    The value of MoE models is that they decouple two tangled metrics:

    Metric Determined by Impact
    VRAM usage Total parameters × bytes per parameter Determines whether the model can fit
    Per-token compute demand Activated parameters Comparable to a dense model of the same scale
    Per-token memory access Activated weight bytes + KV-cache reads Determines the upper limit of generation speed

    For example, a model with 26 billion total parameters and 4 billion activated parameters occupies about 26 GB of weights under 8-bit quantization, which fits into a 64 GB VRAM pool. But generating one token only requires moving about 4 GB of weights. Generation speed is mainly determined by VRAM bandwidth, not compute.

    This is exactly why older GPUs and MoE models fit together well: older cards generally have weaker compute, but their bandwidth and VRAM capacity are not necessarily poor. More importantly, mature inference engines make these older cards usable again. These cards belong to different generations of the same GCN instruction-set architecture and share the same software stack. Official builds of community inference frameworks usually already cover this generation, and the need for custom adaptation is often limited mainly by outdated tutorials.

    However, “can fit” does not mean “works well.” To obtain a stable and predictable service from this type of configuration, systematic engineering is needed in at least five areas: capacity planning, parallel strategy, quantization trade-offs, prompt reuse, and tool calling. Each is discussed below.

    1. VRAM Budget: Allocate Weights First, Then KV Cache

    Single-card VRAM should be allocated in the following order: model weights → KV cache → auxiliary model → safety margin. It is also important to always reserve about 1–2 GB for display output, system processes, and fragmentation. Avoid filling VRAM completely, otherwise unexpected fallback behavior may occur.

    After overhead, two 32 GB GPUs provide about 62 GB of usable VRAM. Once roughly 26 GB of weights are loaded, about 36 GB remains. This is enough for:

    • Three slots of context cache;
    • A small model in the range of about 12 billion parameters for tasks such as heartbeat checks and background assistance;
    • A reasonable safety margin.

    There is a common misconception here: equating “large model size” with “high activation cost.” For MoE models, weight placement only determines static VRAM occupancy. What actually affects interaction smoothness is the amount of activated weights and KV cache read during each forward pass.

    2. Long Context and Multiple Slots: Budget KV Cache Before Choosing Context Length

    Long context may look “free” when advertised, but in reality every layer must store key-value pairs for every token. KV-cache size can be estimated as follows, ignoring optimizations such as GQA:

    1. KV(bytes) ≈ number of slots × layers × 2 × KV heads × head dimension × max context per slot × bytes per element

    Assume a MoE model with 24 layers, 8 KV heads, and head dimension 128:

    • If one slot is filled with 262,144 tokens and the cache is stored in FP16, it requires about 24 GiB.
    • If three slots are all filled, KV cache alone requires about 72 GiB, which exceeds the available VRAM.

    Therefore, “3 × 262144 ≈ 786432” only represents a theoretical capacity upper bound. It does not mean that all of that context can remain resident simultaneously. In practice, a more pragmatic strategy is usually needed:

    1. Separate long and short contexts: Long-context requests occupy a dedicated slot, while other slots use a shorter default context.
    2. Enable on demand: Only sessions that truly require very long context should enable large windows.
    3. Compress storage: Use quantized KV cache or sliding-window caching to reduce the cache cost per token.
    4. Disable context sliding: If long-document Q&A must retain the full text, disable the mechanism that automatically truncates history beyond the limit. Otherwise, the long-context capability will be silently weakened.

    The purpose of multiple slots is not only concurrency. In scenarios such as intelligent coding, each session or subtask occupies an independent slot, naturally achieving context isolation. Requests can also switch to idle slots and reuse established prefix caches, avoiding repeated warm-up.

    3. Dual GPUs and Beyond: Interconnect Often Sets the Ceiling

    With layer split, each GPU handles only part of the layers. To generate one token, a hidden state of roughly a few MB must be passed across GPUs. For PCIe, this is almost negligible. Therefore, in dual-GPU setups, layer split is usually the preferred choice: activated experts can reside on either GPU, there is no need for frequent inter-GPU communication, and throughput scales roughly linearly with the number of cards.

    What really slows things down is tensor split. If every card holds all experts and computes part of them, a cross-card reduction must be performed after every expert layer, causing communication frequency to increase by an order of magnitude. External interconnects such as PCIe have latency and bandwidth far below those of dedicated high-speed interconnects. In dual-GPU setups, they may even perform worse than a single GPU. In short, treating bandwidth-limited dual GPUs as “one large GPU” is only worthwhile during compute-intensive stages, but the decode stage is not such a stage.

    Several easily overlooked details also matter:

    • Physical slots and NUMA: If two GPUs are attached to two different CPUs, cross-socket communication may require a detour. If there is no direct link between the GPUs, communication must go through memory. NUMA binding and topology-aware strategies can mitigate this, but cannot eliminate it.
    • Single-card inference overhead: Tensor parallelism usually requires each card to hold all experts, so weights are duplicated across cards. About 26 GB nearly fills a single card. The result is halved bandwidth and tight VRAM, so it is better to use dual cards only when needed.
    • Leave headroom on the cards: In high-load scenarios, reserving 10%–20% VRAM can reduce the risk of fragmentation and sudden allocation failure.
    • Multi-instance deployment: When compute is tight, instead of letting two models queue against each other, bind different models or replicas of different precision to different GPUs to reduce idle waiting.

    4. Quantization: 8-Bit Weights Are the Sweet Spot for Older Dual-GPU Setups

    The choice of quantization specification must balance three goals: fit, speed, and quality that does not collapse.

    • 8-bit weight quantization: Compared with common 4-bit quantization, 8-bit doubles weight footprint but preserves numerical precision. It is more friendly to sensitive tasks such as instruction following and tool-call parameter generation. For older dual-GPU setups where both bandwidth and VRAM are not severely constrained, it is usually a more practical choice.
    • KV-cache quantization: In long-context scenarios, the cache itself may approach or even exceed the size of the weights. Storing the cache at lower precision effectively enlarges both the context limit and the number of slots. The cost is a slight precision loss on very long sequences.
    • Per-layer and per-expert differentiation: Routing layers, embedding layers, and output layers are small in number but frequently read, so they are usually kept at higher precision. Deeper expert weights are relatively less sensitive and can be compressed more aggressively.

    More importantly, quantization should be treated as a variable that can be regression-tested. Run the same fixed evaluation set against both high-precision and quantized versions, comparing structured-output validity, code-generation pass rate, and instruction-following scores. If the difference exceeds a threshold, roll back precision or reduce context length rather than first assuming that the model has “become dumber.”

    5. Prefill and Decode: Two Different Workloads, Two Different Budgets

    The phenomenon of “a few seconds for initialization but relatively slow generation” in this scenario comes from the fact that the two workloads have completely different characteristics:

    Stage Performance bottleneck Behavior
    Prefill Compute and bandwidth are both stressed, but the work is parallelizable Multi-GPU and large batches can significantly improve speed
    Decode Reads of activated weights and KV cache, limited by bandwidth Tensor-parallel cross-card communication becomes extra overhead

    This leads to two practical recommendations:

    1. Move expensive work forward: Place large static content such as system prompts, tool descriptions, and project context at the beginning of the request, allowing the prefill stage to digest it quickly.
    2. Use caching to absorb repeated computation: Prompt caching works by prefix hits. After the first fill, subsequent turns only process newly added content, and the initialization latency is amortized across multiple conversation turns.

    Only four metrics are easy to track quantitatively: TTFT, prefill throughput in tokens/s, decode speed in tokens/s, and slot occupancy. They correspond respectively to “perceived waiting,” “ability to digest long context,” “reading speed,” and “capacity safety.”

    6. Tool Calling: The First Weakness Exposed When Switching Models

    In agent scenarios, one incorrect tool call can break the entire task chain, which is much more serious than being “a little slow.” Differences in structured-output stability across models often determine real-world experience more than benchmark scores do. Four common failure modes are:

    • Invalid format: The output is not valid JSON, or Markdown code fences are mixed in.
    • Missing or incorrectly typed parameters: Fields are omitted, or strings are written as numbers.
    • Hallucinated parameters: Undefined tool names or fields are fabricated.
    • Semantic deviation: The correct tool is selected, but the arguments are misunderstood, for example treating a relative path as an absolute path.

    There are four layers of engineering measures, from outside to inside:

    1. [Business input]
    2. │ 1. Tool-list pruning and parameter validation (before the call)
    3. ▼
    4. [Model inference] ── 2. Structured-output constraint / grammar constraint (during decoding)
    5. │
    6. ▼
    7. [Parsing layer] ──── 3. Strict parsing + normalization + type coercion (during parsing)
    8. │ On failure
    9. ▼
    10. [Retry policy] ─── 4. Single-field correction retry / degrade to human confirmation (fallback)
    1. Tool-list pruning: Tool descriptions are themselves a major token consumer. Expose only the tools truly needed for the current task, and use layered loading instead of providing everything at once. This reduces both ambiguity and prefill cost.
    2. Structured-output constraints: Prefer an inference backend that natively supports JSON Schema or grammar-constrained decoding, ensuring parseable output at the decoding stage. This is the fundamental way to eliminate format-related errors and is more reliable than post-hoc patching.
    3. Strict parsing and idempotent retries: Apply type coercion and required-field validation to parameters. Make write operations idempotent so that retries after failure are safe.
    4. Behavioral evaluation: Build a fixed test set of 100–300 cases covering real tasks, and measure legal rate, completeness rate, hallucination rate, and semantic correctness rate. Regression-test every time the model or configuration changes.

    Tool-calling capability is the joint result of “model × quantization × inference engine × parsing strategy.” For comparisons to be meaningful, keep the same hardware, the same quantization script, and the same parsing chain.

    7. Co-Resident Models: Keep an Auxiliary Model Resident for Heartbeat and Light Tasks

    When VRAM has headroom, a small model can be kept resident to handle background inspection, heartbeat checks, lightweight classification, and similar tasks. This avoids loading and unloading it each time. When co-resident, pay attention to:

    • Reserve a safety margin: Auxiliary-model usage should be kept within 15%–20% of the VRAM budget.
    • Allocate by GPU: Bind the auxiliary model to a different GPU from the main model, or limit its VRAM usage.
    • Isolate context: The auxiliary model should use an independent slot to avoid competing with the main model’s session cache.

    8. Design for Replaceability: Abstract a Unified Inference Layer

    Open-weight models iterate quickly. Today’s first choice may be surpassed by the next version. Instead of binding to a single model, abstract “model capability” behind unified interfaces, such as a unified chat interface, a unified tool-calling protocol, and a unified streaming-output format. Then, switching models requires only configuration changes, not business-code changes.

    It is also useful to turn capacity estimation into reusable scripts. Given parameters, quantization byte width, context length, and number of concurrent slots, the script can output required VRAM and expected speed:

    1. def estimate(total_params_b, quant_bytes, kv_bytes, overhead_gb=2):
    2. weight_gb = total_params_b * quant_bytes # e.g., 26 × 1 ≈ 26GB
    3. return weight_gb + kv_bytes + overhead_gb # Fill kv_bytes and overhead_gb from measurements

    9. Pre-Launch Checklist

    • Are the two GPUs in the same NUMA node? Is parallelism using layer split rather than tensor parallel?
    • Does the sum of the three-slot limits exceed available VRAM? Do long requests occupy a dedicated slot?
    • Is automatic context truncation disabled for long-document scenarios?
    • Have structured-output validity and hallucination rates been regression-tested with a fixed evaluation set?
    • Are JSON Schema / grammar constraints enabled at the decoding layer?
    • Is auxiliary-model usage kept within the reserved range and bound to a separate GPU?
    • Have TTFT, prefill throughput, decode speed, and slot occupancy been recorded?
    • Is the model integrated through a unified interface so it can be switched without changing business code?

    Conclusion

    The combination of older GPUs and MoE models is essentially about trading VRAM for compute and bandwidth for parameters. It is suitable for local scenarios that are privacy-sensitive, fixed-cost-sensitive, and require long context and stable structured output. But what really determines the experience is not “how large a model can be installed.” It is whether context and cache are correctly budgeted, whether interconnect is used wisely, whether tool calling is strictly constrained, and whether models remain replaceable.

    After local validation has matured, if there are needs for elastic scaling or higher concurrency, it may be worth evaluating combinations of cloud heterogeneous compute instances, containerized inference platforms, and object storage. For specific specifications and pricing, refer to the official documentation.