How to Serve a 768K-Context MoE Model on Two Older GPUs: A Practical VRAM-Budget and Throughput Guide
This article walks through a real deployment that serves a ~26B-parameter MoE model with roughly 768K tokens of aggregate context across three concurrent session slots on two generation-old 32GB datacenter GPUs (64GB HBM total). It explains how to compute the VRAM budget before evaluating the model, why MoE decouples weight cost from compute cost, how the KV cache drives context cost, why prefill can hit ~1000 token/s while decode stays around ~50 token/s, and how to lift bandwidth-bound decode throughput with batching, tensor parallelism, and prefix caching. It also covers 8-bit versus 4-bit quantization tradeoffs, tool-calling reliability as a hidden model-selection criterion, co-locating a secondary model in leftover VRAM, the observability metrics and capacity guardrails needed to avoid silent degradation, and the conditions under which migrating off self-hosted older GPUs becomes the right call.
How to Serve a 768K-Context MoE Model on Two Older GPUs
1. The problem: turn “impossible” into a computable budget
For inference under resource constraints, the most common mistake is to discuss model capability first and only later ask whether the hardware can hold it. The correct order is the reverse: compute the VRAM budget first, decide whether the model is viable, and only then talk about speed and experience.
The constraints here were a specific set: two datacenter accelerator cards from two generations back, 32GB each (64GB HBM total, with memory bandwidth far below current flagship cards); an open-source Mixture-of-Experts (MoE) model with roughly 26 billion total parameters and about 4 billion activated per token; 8-bit block quantization; and a requirement to support three concurrent session slots with an aggregate context of about 768K tokens. The target workload is not offline batch processing but the online interaction of a coding-oriented Agent: a long system prompt plus code snippets plus multi-turn tool calls.
On paper this looks under-provisioned. It runs anyway, and the key is a single fact: in an MoE, memory cost and compute cost are decoupled.
2. The VRAM budget: three slices of the pie
Inference-time VRAM usage breaks down roughly into three parts:
Total VRAM ≈ resident weights + KV Cache pool + runtime overhead (compute buffers / graph / communication)
- Resident weights are set by the total parameter count and have nothing to do with how much is activated. 26 billion parameters at 8-bit quantization come to on the order of 26GB; with the partially unquantized embedding, normalization, and output layers, the actual on-disk/loaded size is somewhat higher. This is the “entry fee”—incompressible once loaded.
- The KV Cache pool is set by layers × KV heads × head dimension × bytes per element × sequence length × concurrent slots. This is where the real cost of context comes from.
- Runtime overhead—compute buffers, graph structures, communication staging, and so on—usually runs on the order of 1–2GB.
The crux: MoE’s small activation count only affects “how fast,” not “whether it fits.” This is also why a model with 4 billion activated parameters can run at speeds on par with a dense model of the same total scale—during decode, each token only reads the weights of the routed-to experts, not all weights.
On quantization, 8-bit block quantization (Q8-style formats) is a pragmatic landing point:
| Precision | Weight size (26B) | Relative precision loss | Suitability |
|---|---|---|---|
| 16-bit float | ~52GB | baseline | Won’t fit on 64GB across two cards; ruled out immediately |
| 8-bit block quantization | ~26GB | minimal | Chosen for this scenario |
| 4-bit quantization | ~13GB | visible | Can be traded for longer context, but tool-calling stability degrades |
Agent scenarios have very low tolerance for structured output (JSON, function arguments), and the format breakage from 4-bit quantization often costs more than the VRAM it saves. “Use 8-bit rather than 4-bit”—this was one of the most important conclusions of the whole effort.
3. The KV cache is the real cost of context
Say the model has L layers, H_kv KV heads, head dimension D, and b bytes per cached element. A single sequence occupies:
KV_bytes ≈ 2 × L × H_kv × D × b × seq_len
The factor of 2 comes from keeping both a K and a V cache. This one formula explains three things people routinely misunderstand:
- Why GQA/MQA is a prerequisite for long context. If the KV head count equals the query head count (MHA), the cache balloons several-fold. Grouped-query attention lets multiple query heads share one KV group, compressing the cache to a fraction of the size—which is what makes a 768K context feasible at all.
- Why context length is a “multiply,” not an “add.” Three slots of 250K tokens each consume the same cache as a single slot of 750K tokens. Aggregate context and concurrency stand in a multiplicative relationship to the cache pool, so capacity planning must be done as
total slots × per-slot length, not as the longest single session. - Why you can trade precision for space. Dropping the KV cache to 8-bit or lower is usually a better deal than quantizing weights to 4-bit—weight quantization directly damages the model’s language and format abilities, whereas the marginal quality impact of KV quantization is comparatively manageable.
The essence of the multi-slot mechanism is to reserve independent KV space and generation state for each concurrent session, preventing attention from one session from contaminating another. With it enabled, three Agent sessions advance in parallel without blocking each other. The cost is that the cache pool is statically partitioned, so a single slot cannot borrow another slot’s idle space. That is why more slots is not automatically better. Slots × per-slot context = cache pool size—once this equation is fixed, it should be back-derived from the longest real business session, not set arbitrarily to 8 or 16.
4. Performance asymmetry: near-1000 token/s prefill, only tens for generation
A recurring observation in testing: during initialization, the ~10K-token prefill runs at close to 1000 token/s, while generation runs at only about 50 token/s. This is not a misconfiguration but an inevitable result under the roofline model:
- Prefill stage. The entire input can be processed in one parallel pass, with all tokens entering the matrix multiply at once. This stage is compute-bound; the hardware’s parallelism is fully exploited, arithmetic intensity is high, and throughput is naturally high.
- Decode stage. Every generated token has to move the currently active weights from VRAM through the compute units. With batch size 1 and sequence length 1, arithmetic intensity is extremely low, and the stage is entirely memory-bandwidth-bound. Bandwidth divided by the bytes that must be read per token is the physical ceiling on single-stream speed.
This also means: chasing single-stream speed on cards like these yields limited returns; chasing throughput is the right move. Actionable directions include:
- Increase concurrent batching. Continuous batching merges the decode steps of multiple sessions so that a single weight read serves many tokens, and total throughput rises roughly linearly. In an Agent scenario, three slots naturally form a batch, so the gains are clear.
- Aggregate bandwidth across multiple cards. Dual-card tensor parallelism slices the weights, halving the per-card bytes read per token; in theory the bandwidth aggregates into a near-linear decode speedup, at the cost of inter-card communication and the overhead of sharding.
- Prefix cache reuse. An Agent’s system prompt, tool declarations, and codebase context are highly repetitive across requests. With prefix caching enabled, that “10K-token initialization prefill” only needs to be computed once for real; later requests hit the cache and skip prefill entirely, sharply reducing time-to-first-token (TTFT). This is the highest-ROI optimization in Agent scenarios.
- Speculative decoding. A small model or draft head proposes candidate tokens and the main model verifies them, folding the verification of several tokens into a single weight read under bandwidth limits. It is more complex to implement; consider it only after prefix caching and batching are in place.
5. A hidden hard metric for model selection: tool-calling reliability
One comparison worth recording: another MoE from the same generation—35 billion total, 3 billion activated—frequently produced tool-call format errors in the same environment, while the model described above stayed stable. Such differences rarely show up on benchmark leaderboards, but in Agent production they are a veto item.
Typical forms of tool-call failure:
- Emitting invalid JSON, or wrapping a function call in the wrong markers, so the parser throws immediately;
- Parameter-name hallucination—calling fields that don’t exist in the tool declaration;
- Wrong parameter types (passing a string where a number is expected, an object where an array is expected);
- Fabricating an answer instead of calling a tool it should have called, or looping on the same tool call.
Engineering-side hardening, ordered by cost-effectiveness:
1. Constrained decoding (grammar / JSON Schema)→ mask invalid tokens at the sampling stage, eliminating syntax errors at the root2. Simplify tool declarations→ reduce tool count, shorten descriptions, flatten nested parameters to lower the model's cognitive load3. Parsing fault-tolerance layer→ loose matching, field alias mapping, type coercion, and reinjecting error hints on missing required fields so the model can self-correct4. Retry and circuit breaker→ retry once on a single format error; on consecutive failures, degrade to "no-tool mode" and report5. Structured eval set→ fix 100–200 tool-call cases, quantify format-validity rate, parameter-accuracy rate, and average call rounds
Point 5 is the easiest to skip, yet it determines whether switching models can be a rational decision rather than a guess. Fold tool-call accuracy into regression testing, and model iteration stops depending on subjective feel.
One more observation: the original author noted that “once a newer-generation model arrives, the old one falls out of favor.” This points to an architectural principle—models must be pluggable. The inference runtime, quantization format, prompt templates, and tool declarations should be abstracted into a configuration layer, so switching models changes only config, not business code. Hardware investment cycles run 3–5 years; a model’s lifecycle may be only a few months. Decoupling the two keeps infrastructure from being locked to any single model.
6. Reusing leftover VRAM: co-locating a secondary model
At 8-bit quantization, the dual cards still leave considerable VRAM headroom. The practice here was to keep a ~20B-parameter dense model resident at a lower quantization precision to handle background light tasks: session heartbeat keepalive, rolling summaries of long conversations, request-routing classification, and offline log tagging.
This co-location needs three disciplines:
- Process isolation and resource quotas. Run the two models as separate processes with explicit limits on their respective VRAM and thread usage, so contention doesn’t cause TTFT jitter on the main model.
- Clear priority. Background tasks must be deferrable and droppable; when the main path is busy, background tasks yield rather than the reverse.
- Tiered quantization precision. Background tasks have low demands on format and reasoning depth, so they can use 4-bit to shrink their residency and leave the saved VRAM for the main model’s KV cache.
7. Observability and capacity guardrails
The biggest risk in deploying on older cards is not performance but silent degradation when there’s no fallback. At minimum, these metrics should be in monitoring and alerting:
- Time-to-first-token (TTFT) and decode rate in TPS—tracked per session rather than as a global average, since an average hides the long tail;
- KV cache pool utilization and slot queue time—the first signal of a capacity alarm;
- Context-truncation rate and prefix-cache hit rate;
- Peak VRAM and fragmentation; slow growth under sustained operation usually means a cache isn’t being released;
- Tool-call failure rate and parse-exception stacks, for quality regression.
For capacity guardrails, set a per-session context limit and actively run summary compression as it approaches the ceiling, rather than letting a request blow out a slot and drag down the other sessions. The benefit of long context is linear, but the risk is global—a point that holds especially true in a shared-cache-pool, multi-slot architecture.
8. When to leave self-hosted older GPUs
The self-hosted approach has clear boundaries on when it makes sense: the model is replaceable, the load is predictable, data can’t leave its domain, the hardware is an existing sunk asset, and the team can maintain the inference engine.
Once these signals appear, it’s time to re-evaluate the path: GPU supply is tight or failure rates are rising, making availability impossible to guarantee; peak load fluctuates widely and needs minute-level elastic scaling; models iterate faster than hardware depreciates; and the team has to pour ever more effort into maintaining self-adapted compute-stack branches (the vendor compute stack for older accelerators is often off the mainline, with community patches becoming a single point of dependency).
The value of the cloud path isn’t a stronger single card but turning the uncontrollable into the controllable: elastic GPU instance pools and rolling upgrades via a container platform, quantized weights and versions on object storage for canary rollout and fast rollback, monitoring and alerting in place of manual inspection, and on-demand scale-up/down to absorb peaks. Whether to migrate comes down to whether the total cost of ownership of the self-hosted approach (including human maintenance and failure losses) has already exceeded the incremental cost of the cloud—and this is a calculation worth redoing every year, because the numbers on both sides keep changing.
9. Conclusion
Serving a 26B-parameter MoE model with 768K-level context under a 64GB dual-card constraint wasn’t about any single trick but a combination of correct judgments: using MoE’s weight/activation decoupling to make VRAM feasible; using 8-bit rather than 4-bit quantization to preserve structured-output ability; using GQA and KV quantization to fit context into the cache pool; using slots and batching to raise bandwidth-bound decode throughput; using prefix caching to eliminate the repeated prefill of Agent scenarios; and using constrained decoding plus an eval set to turn tool-call reliability from luck into a metric.
Hardware becomes obsolete and models get replaced, but this methodology—budget first, then performance, and finally guard quality with metrics—stays stable. What deserves long-term investment is not the tuning notes for one model on one card, but a pluggable model layer, quantifiable quality gates, and an observability system that makes clear whether the bottleneck is compute or bandwidth.
