Large Model Long-Context Deployment and GPU Memory Planning: A Practical Guide

    This guide explains how to plan GPU memory for deploying large sparse models with long-context support. It clarifies why activated parameters do not determine memory usage, outlines the four components of memory planning, describes how to select resource tiers from single nodes to dedicated long-context pools, and shows how to route requests by input length. A pre-launch checklist is also included.

    1. First, a Common Misconception: Activated Parameters Are Not GPU Memory Usage

    Most state-of-the-art sparse large models use a Mixture of Experts (MoE) architecture. A typical configuration has a total parameter count in the hundreds of billions, while a single forward pass activates only about one-tenth or fewer of those parameters. When doing capacity planning, many developers use the activated parameter count as the basis for estimating GPU memory. This is a dangerous simplification.

    Activated parameters determine compute volume, not storage volume. Every expert weight in an MoE model must remain resident in GPU memory. The router only decides which experts a given batch of tokens goes through at runtime, but the experts that are not activated do not disappear from memory. Therefore, GPU memory planning must cover at least four components:

    1. Full weights: All experts and shared layers must be loaded, making this the largest contributor to memory usage;
    2. KV Cache: Grows linearly or even faster with context length, output length, and concurrency;
    3. Runtime overhead: The framework’s own buffers, communication buffers, and temporary activations;
    4. Peak stacking of concurrent requests: The instantaneous high-water mark when multiple requests are resident simultaneously.

    A practical order of assessment is: first determine “whether it fits” based on the full weights, then determine “how many requests can be served simultaneously” based on the KV Cache, and finally determine the “safe water level” using runtime headroom. Skipping any of these steps will lead to queuing or even crashes during production peaks.

    2. Resource Tier Assessment: From a Single Node to a Dedicated Long-Context Pool

    On general-purpose configurations, a single node with 8 high-memory accelerator cards (around 141GB per card) can typically serve as a reference starting point for FP8 precision deployment. If the workload genuinely requires full million-token context, it is better to prioritize next-generation accelerator cards with larger per-card memory (around 180GB). For proof-of-concept (POC) validation, 4-bit quantization can significantly lower the barrier, allowing a team to get the pipeline running with fewer cards.

    It is important to emphasize that the above is only a resource tier assessment that answers “roughly what class of machine is needed,” not a guarantee that “deployment will definitely work.” Whether it can actually go live depends on the length distribution of real tasks, latency requirements, and production constraints.

    3. Million-Token Context Is Not the Default Service Window

    Supporting million-token context and “opening a million-token window by default for all requests” are two different things. The real cost center of long context is the KV Cache: the longer the input, the longer the output, and the higher the concurrency, the larger the cache usage. A single request approaching one million tokens and dozens of 128K requests may exert comparable pressure on GPU memory and the scheduling queue.

    A more robust approach is to first gather request length distribution statistics, then design tiered serving:

    • Within 32K: Usually the largest share; prioritize retrieval-augmented generation (RAG) and a shared service pool to optimize for throughput and cost;
    • 32K–128K: Set quotas and queuing mechanisms to prevent individual long requests from crowding out the shared pool;
    • Above 128K: Split into a separate long-context service group with dedicated instances and monitoring metrics;
    • Approaching 1M: A low-concurrency dedicated queue, combined with asynchronous task processing and result callbacks, to avoid synchronous waiting dragging down overall availability.

    The illustrative routing logic can be written as:

    1. def pick_pool(input_len: int) -> str:
    2. if input_len <= 32_000:
    3. return "shared_pool" # Shared pool, optimized for throughput
    4. if input_len <= 128_000:
    5. return "quota_pool" # Quota + queue
    6. if input_len < 900_000:
    7. return "long_ctx_pool" # Dedicated long-context group
    8. return "dedicated_lowq" # Low-concurrency dedicated queue

    4. Pre-Launch Checklist

    • Use real workload samples to measure input/output length percentiles rather than planning against theoretical limits;
    • Load-test three scenarios separately: weight loading, peak KV Cache, and concurrent stacking;
    • Set timeouts, retries, and fallback strategies for long-context requests, and store results in object storage for asynchronous retrieval when necessary;
    • Establish monitoring and alerts for GPU memory water level, queue duration, and time to first token;
    • Validate accuracy loss before discussing cost reduction for quantization schemes.

    Summary: The deployment challenge of sparse large models lies not in “whether it fits,” but in “how long context and concurrency are scheduled in an orderly manner.” Tiering context, isolating long requests, and building capacity on top of the real distribution is the reliable path from POC to production.