Deploying MoE Models on Older GPUs: A Practical Engineering Guide

    Mixture-of-Experts (MoE) models can make older, lower-compute GPUs viable again, because VRAM scales with a model's total parameters while compute scales only with its activated parameters. This article walks through deploying a sparse ~26B MoE model (about 4B activated per token) on legacy accelerators with 32–64GB of VRAM. It covers static VRAM budgeting (weights, KV cache, and headroom), the trade-off between long context and parallel slots, why prefill is fast while decoding is slow (a Roofline analysis), how to stabilize tool calling for agent workloads, how to exploit spare VRAM for co-located auxiliary models, an engineering strategy for fast model iteration, and a pre-launch checklist. It is aimed at engineers who want to run capable models on hardware that trails the latest generation in compute and memory bandwidth.

    1. The phenomenon and the essence: why MoE makes old cards usable again

    On an older-architecture accelerator card—a single card with 32GB, two cards totaling 64GB, with compute and memory bandwidth clearly behind newer products—someone successfully ran a large model instance like this:

    • A sparse-activation architecture, with about 26B total parameters and only about 4B activated per token;
    • 8-bit quantization;
    • 3 parallel session slots, with a total context window of about 768K tokens;
    • During the initialization phase of an intelligent coding assistant (a system prompt plus project context requiring roughly 10K+ tokens), prefill speed approached 1000 tokens/s and generation speed was about 50 tokens/s;
    • The remaining VRAM was still enough to host an auxiliary model handling lightweight tasks such as heartbeat detection.

    The data comes from a personal environment and is for reference only; it is not universal. But the engineering logic it reflects is worth dissecting: why are MoE models especially well suited to this kind of hardware? And what constraints exist between these metrics?

    1.1 The key property of MoE: VRAM is counted by total parameters, compute by activated parameters

    A traditional dense model pushes every token through all of its parameters, so VRAM usage and per-token compute grow together. An MoE (Mixture-of-Experts) model instead splits the feed-forward layers into multiple parallel “experts,” and a gating network selects a few experts for each token to participate in the computation (a common activation ratio is 10%–25%). This produces two key differences:

    • Capacity comes from total parameters: all expert weights must stay resident in VRAM, and this determines the model’s knowledge capacity;
    • Overhead depends on activated parameters: the actual compute and weight reads per token are proportional only to the activated parameters, and this determines inference speed.

    In short: “VRAM is charged by total parameters, compute is charged by activated parameters.”

    1.2 Capability density compared with dense models

    Assume both model types have the same number of activated parameters per token:

    Dimension Dense model MoE with the same activated parameters Conclusion
    Per-token compute / read Full parameters Only the activated part Roughly equal
    Total parameters and knowledge capacity Equal to activated parameters Several times the activated parameters MoE wins
    VRAM usage Smaller Larger Dense wins

    The weakness of old cards is precisely compute and memory bandwidth, while their strength is relatively ample VRAM capacity and lower per-unit VRAM cost. MoE’s characteristic of “trading VRAM for capability” fits this hardware condition closely.

    1.3 Engineering prerequisite: getting it running on old hardware is not easy

    It should be stated objectively that whether an inference framework runs smoothly on older accelerators depends on the compatibility of three things: the driver version, the compute library version, and the framework binary. It also depends on whether mature implementations exist for attention operators, grouped-query attention, MoE routing, and efficient quantized matrix multiplication—in many cases this requires adaptation or even porting for a specific hardware backend. Therefore, the first step of technology selection is always compatibility verification. Section 7.1 gives specific methods.

    2. VRAM budget: do a static calculation first

    When deploying on old cards, VRAM is the only non-negotiable hard constraint. A static calculation should be completed before going live. The core formula is:

    1. VRAM need ≈ weight usage + KV cache + compute buffers + framework/context overhead

    2.1 Weight usage

    Weight usage is determined jointly by the total parameter count (not the activated count) and the quantization bit-width, and can be estimated as:

    1. Weight bytes ≈ total parameters × average bits per weight ÷ 8

    With about 26B total parameters and 8-bit quantization, that is about 8.5 bits per weight (8-bit integers plus a small number of scaling factors), so the weights are about 27.6GB. Switching to 4-bit group quantization (about 4.5 bits per weight) can compress this to about 14.6GB. The embedding layer, the output layer, and alignment padding for expert weights add a small amount of extra overhead, which is ignored here.

    2.2 KV cache

    The KV cache stores the key and value vectors of historical tokens at each layer. Its size is independent of the total parameter count and depends only on the model’s attention structure, context length, number of concurrent slots, and cache precision:

    1. KV bytes = 2 × layers × KV heads × head dim × bytes per element × context length × slots

    (The factor of 2 accounts for one copy each of K and V; KV heads refers to the number of KV heads actually cached in grouped-query attention.)

    Assume the model has 32 layers, uses grouped-query attention, and has 4 KV heads with a head dimension of 128:

    • If the KV is stored in FP16, each token’s KV is about 64KB;
    • With 3 slots and about 256K tokens each, the KV totals about 48GB;
    • This clearly cannot coexist with the weights, so at this point the KV needs 8-bit quantization (about 24GB), further KV compression, or a smaller context/slot configuration.

    This example illustrates a conclusion that is easy to overlook: in long-context scenarios, the real VRAM hog is often not the weights but the KV cache. Cache quantization is one of the key levers that determines whether such a deployment is viable.

    2.3 Worked example and headroom

    The sum of the components is only a theoretical lower bound. Actual deployment must also reserve headroom for:

    • Temporary activations produced by prefill and batching;
    • VRAM used by compute-graph capture (such as CUDA Graph);
    • Memory allocator fragmentation;
    • Repeated cache growth and shrinkage caused by frequent context-length changes;
    • The framework’s own overhead.

    As a rule of thumb, reserving 10%–15% is prudent. In addition, if tensor parallelism is used to split the model across multiple cards, cross-card communication adds latency, so high-speed interconnect within the same node is the ideal prerequisite.

    3. Long context and parallel slots: essentially a resource allocation

    The configuration of “3 slots, about 768K total context” deserves a separate analysis.

    3.1 Their product is easily misread

    Parallel slots can be understood as the number of sessions handled concurrently within the inference process. Requests within the same slot execute sequentially, while different slots can be batched together for parallel decoding. A common mistake is to simply multiply “the maximum context the model supports” by “the sum of the multi-slot windows” and arrive at an unrealistic capacity expectation.

    1. Available context per slot ≈ total context budget ÷ number of slots

    In this configuration, each slot has about 256K tokens available on average, provided that each request allocates on demand and the total does not exceed the budget. Enabling KV quantization can further increase the effective capacity. A few things to watch in actual use:

    • If each slot independently reserves its maximum window, the real usable total will be smaller than the nominal value;
    • If the actual length of each request is far below the window limit, overall capacity utilization will be low.

    Combined with a long-context measurement: for example, with an 8-bit KV cache and about 256K tokens per slot, the KV is about 8.4GB; adding about 27.6GB of weights and about 4GB of headroom gives roughly 40GB in total, which is below the 64GB of total VRAM. This explains the feasibility of such a configuration in terms of order of magnitude.

    3.2 Diminishing marginal returns from more slots

    Increasing the number of slots improves concurrent throughput, but there are two limits:

    1. VRAM constraint: the KV cache grows linearly with the number of slots;
    2. Compute constraint: during batching, the attention and shared parts of the dense layers grow with context length and batch size, and MoE experts may also suffer from load imbalance within a batch.

    When the GPU is already in the compute-bound regime, adding more slots often only raises latency while yielding limited gains in total throughput.

    3.3 The cost and benefit of long context

    For mainstream Transformers, the attention computation grows quadratically with sequence length, and this shows up mainly in the compute-intensive prefill phase. Combined with the “lost in the middle” phenomenon, the context window should be treated as a scarce resource that needs careful management, not something where longer is always better. Engineering recommendations:

    • Put in only what is necessary: retrieve results on demand, and periodically summarize and compress dialogue history;
    • Fix the prompt prefix: place the system prompt and tool definitions at the beginning and keep them stable and unchanged. If the engine supports prefix-cache reuse, this avoids re-prefilling them on every request;
    • Choose the window through load testing: use load testing to find the shortest context with acceptable accuracy, and put the saved VRAM toward a larger KV cache or higher concurrency.

    4. Inference throughput: understanding the structural difference between “fast prefill, slow decode”

    About 1000 tokens/s for the initialization prefill and about 50 tokens/s for output generation looks like a 20x difference, but in fact two different kinds of computation are at work.

    4.1 The two phases through the Roofline model

    To judge what limits a computation, calculate its “arithmetic intensity” (the number of floating-point operations performed per byte of data read) and compare it with the hardware’s “ridge point” (peak compute ÷ peak memory bandwidth):

    • If the arithmetic intensity is below the ridge point, it is memory-bound and performance is determined by memory bandwidth;
    • If it is above the ridge point, it is compute-bound and performance is determined by compute.
    Phase Tokens in the batch Characteristic Bottleneck
    Prefill Thousands, processed at once Large matrix multiplication; weights read only once Compute
    Decode 1 token per sequence per step Activated weights must be read for every generated token Memory bandwidth

    This leads to two important inferences:

    • Fast prefill does not mean a smooth overall experience;
    • The key to improving generation speed is reducing the amount of data that must be moved per token.

    4.2 Other factors affecting the decode phase

    • KV reads: the longer the context, the more KV must be read at each step, and in long-context scenarios this overhead is not negligible;
    • Effective bandwidth: the bandwidth actually achieved is usually below the nominal peak;
    • Framework overhead: scheduling, sampling, vocabulary sampling (top-k, top-p, and so on), memory copies, and kernel launches all dilute the effective bandwidth.

    4.3 An actionable optimization checklist

    1. Improve quantization efficiency: prefer quantization formats that have efficient dedicated kernels on this hardware, and avoid a “double discount” on both accuracy and compute;
    2. Quantize the KV cache: this balances VRAM usage against read overhead in long-context scenarios;
    3. Speculative decoding: use a small model of the same architecture or a lightweight draft mechanism to propose several candidate tokens, then have the large model verify them in a single pass; this suits scenarios where the generated content is highly predictable, and the benefit depends on the draft hit rate;
    4. Scheduling strategy: on top of continuous batching, evaluate “chunked prefill,” which splits a long prompt into several small chunks and schedules them mixed with decode requests, mitigating the impact of long-context requests on the time-to-first-token of new requests;
    5. Benchmarking: establish a benchmark process with a unified methodology covering time-to-first-token (TTFT), per-token output latency, overall throughput, and long-context performance, and base every adjustment on before-and-after comparison data.

    5. Tool-calling stability: from “usable” to “reliable”

    In agent scenarios such as intelligent coding assistants, the model interacts with business systems through function calls (tool calling). The typical flow is: the model outputs structured content containing a tool name and JSON parameters, the runtime parses and executes it, and then feeds the result back to the model for continued reasoning.

    The “fewer tool-call errors” mentioned in the experience report is precisely the core metric for such scenarios. One point must be clarified before selection: all models generally support tool calling; the difference lies in stability.

    5.1 Common failure modes

    Failure type Typical symptom Main cause
    Format violation Truncated JSON, unquoted keys, extra explanatory text Output-length limit, sampling randomness
    Parameter error Missing required fields, type mismatch, illegal enum value Vague tool description
    Wrong tool selection Answering directly when a tool should be called, or choosing the wrong tool Too many tools, overlapping descriptions
    Hallucinated parameters Passing a nonexistent path or field The model lacks knowledge of the runtime environment
    Call loop Repeatedly calling the same tool, stuck in an endless loop No round limit or termination condition
    Privileged operation Executing sensitive operations such as deletion or writes without confirmation Missing permission control

    5.2 Engineering measures

    1. Curate the tool list: the number of tools and the length of their descriptions directly consume context and, in proportion, dilute the model’s attention to the system instructions. Group tools by scenario and dynamically inject only the subset needed for the current task;
    2. Standardize tool descriptions: use semantic names, specify each parameter’s type, value range, and examples, and clearly document the return structure on failure;
    3. Use structured-output constraints: on frameworks that support constrained decoding, use a JSON schema or grammar constraints to force the output to conform to a predefined structure, eliminating parsing errors at the source;
    4. Validate strictly and retry in a limited way: when parsing fails or a parameter is invalid, feed a clear error message back to the model as the tool result, rather than discarding it or retrying indefinitely;
    5. Limit rounds and repeated calls: set a maximum number of tool-call rounds, and detect consecutive repeated calls and force termination;
    6. Keep decoding parameters stable: tool-calling scenarios tend to use a lower temperature; when switching a model across versions, fix the sampling parameters and run comparison regressions;
    7. Permissions and observability: high-risk operations require human confirmation or secondary validation; fully log the input and output of each call for traceability.

    5.3 A reference implementation of the validation loop

    The following is language-agnostic pseudocode showing the core structure of a tool-call validation loop:

    1. function call_tools(model, tools, message_history, max_rounds = 8, max_retries = 2):
    2. for round from 1 to max_rounds:
    3. reply = model.infer(message_history, tools, temperature = 0.1, output_format = JSON_schema)
    4. call_list = parse_structured_output(reply)
    5. if call_list is empty:
    6. return reply.text
    7. executed = False
    8. for each call in call_list:
    9. error = validate(call, tools) # tool exists, required params, types, enum values
    10. if error is not empty:
    11. result = {error_message: error, hint: "Fix the params and retry"} # feed the error back for self-correction
    12. else if call.tool in high_risk_tools:
    13. result = request_human_confirmation()
    14. else:
    15. result = execute(call.tool, call.params)
    16. message_history.append(role = "tool", content = result)
    17. executed = True
    18. if not executed:
    19. return "Could not complete the tool call, degraded gracefully"
    20. return "Reached the maximum number of rounds, switching to the fallback flow"

    5.4 The evaluation loop

    Selection and launch cannot rely on subjective impressions. Build an automated evaluation set that includes at least the following metrics:

    • Tool-selection accuracy;
    • Parameter correctness and format-compliance rate;
    • Average number of calls per round;
    • Task success rate;
    • Answer quality when no tool call is made.

    At the same time, cover difficult samples from real business such as long dialogues, ambiguous instructions, and multi-tool combinations, and integrate them into a continuous-integration pipeline so that every change to the model or the prompt is traceable.

    6. The value of spare VRAM: multi-instance co-location and graceful degradation

    When a MoE model of about 26B runs within 64GB of VRAM, the remaining VRAM still has value.

    • By the earlier worked example, with an 8-bit KV cache the main model occupies about 40GB, leaving about 20GB (less after headroom is deducted);
    • If the main model switches to 4-bit quantization, its usage can drop to about 35GB, and the headroom grows further.

    This spare capacity can be used for:

    • Auxiliary-model co-location: deploy small models to handle lightweight tasks such as heartbeat detection, dialogue summarization, request routing, and content moderation;
    • Extended context: enlarge the KV cache or the number of slots to support longer sessions;
    • Prefix caching: reserve prefix-cache space to accelerate repetitive requests.

    Co-location requires attention to resource isolation: set a fixed VRAM cap for each auxiliary instance to prevent the main instance from failing to allocate as its context grows; and set priorities for online inference versus offline batch jobs, so that the latter cannot squeeze out the former’s compute resources.

    7. An engineering strategy for fast iteration

    7.1 After a new model is released, existing advantages may quickly disappear

    Open-source model iteration moves fast, and new-generation models often improve across tool-call stability, long-context performance, and inference efficiency. The experience-based advantage that “a certain model makes fewer tool-call errors in a certain environment” may vanish quickly when another new model appears. The only reliable approach is:

    • Model layer: abstract a unified interface, so that adapting to a new model requires only swapping the backend and the prompt template;
    • Evaluation layer: make the evaluation set cover the key business metrics; run new models through offline evaluation and a small-traffic canary first, then gradually ramp up;
    • Prompts and tool descriptions: manage them decoupled from any specific model, store them under version control, and avoid scattering them across business code;
    • Inference backend: put compatibility verification first, focusing on the level of support for quantization formats, attention implementations, grouped-query attention, and MoE routing, as well as the adaptability of custom operators and low-level compilation schemes.

    7.2 Use output constraints to lower the cost of switching models

    Tool calling is the most failure-prone part when switching models. Once JSON mode or grammar constraints are enabled at the inference-framework layer, the model only needs to “pick the right tool and fill in the right parameters,” and the output structure is guaranteed by the decoding process, so switching models requires no rewrite of the parsing logic.

    7.3 Use service encapsulation to hide hardware differences

    Encapsulate the self-built inference service as an HTTP interface consistent with the mainstream OpenAI-compatible API specification, and implement the following uniformly at the gateway layer:

    • Authentication and quota/rate limiting;
    • Timeout control and fault retry;
    • Request logging and metrics collection.

    This way, upstream business does not need to know whether the backend is a self-built old-card cluster, an inference service deployed on a cloud container platform, or a managed large-model service, which preserves the room to migrate flexibly among self-built, cloud, and managed options. To reduce hardware procurement and operations investment, one can also leverage the general capabilities of cloud platforms such as Baidu AI Cloud—heterogeneous compute, containerized deployment, object storage, monitoring and alerting, and logging—to quickly stand up an elastic inference service.

    8. Pre-launch checklist

    1. Compatibility verification: driver, compute library, and inference-framework versions match, and the target quantization format and attention implementation are available;
    2. VRAM calculation: estimate item by item as “weights + KV cache + headroom,” reserving a 10%–15% buffer;
    3. Context strategy: define the number of slots and the per-slot window, enable KV quantization, and verify the effect of prefix-cache reuse;
    4. Performance baseline: separately record the throughput and latency of the prefill and decode phases to form a comparable baseline;
    5. Tool-call governance: streamline the tool list, enable structured-output constraints, and complete validation, retry, round limits, and permission control;
    6. Evaluation regression: build an automated evaluation set covering tool calling and answer quality, and integrate it into continuous integration;
    7. Observability: monitor VRAM usage, queue length, TTFT, output latency, and tool-call failure rate, and configure alerts;
    8. Disaster recovery and degradation: when the main instance fails, automatically switch to a backup instance or a smaller-parameter backup model to keep the core path available.

    Conclusion

    Deploying MoE models on older accelerators is essentially a delicate balancing act with VRAM and bandwidth: compress weights and the KV cache with quantization, balance capacity against concurrency with context and slot configuration, locate bottlenecks through throughput analysis, compensate for the model’s instability in tool calling with engineering measures, and use a replaceable architecture to cope with fast model iteration. The MoE architecture decouples “capacity” from “speed,” allowing hardware with relatively insufficient compute to still carry high-quality models; but what ultimately determines real-world results is still the engineering system built around it.