Deploying 671B MoE Models on the Cloud: A Practical Guide

    This guide explains how to deploy a 671B-parameter Mixture-of-Experts (MoE) model on cloud platforms. It covers why total parameters drive memory requirements while activated parameters drive compute, four pre-deployment assessments, parallel strategy selection (TP, PP, EP, DP), inference acceleration and memory governance, a reference cloud architecture, cost and capacity planning, and a go-live checklist. The methodology applies to general-purpose capabilities offered by mainstream cloud platforms such as Baidu AI Cloud.

    1. Background: From “Model Release” to “Platform Readiness”

    In late 2024, the first version of an open-source large model with a Mixture-of-Experts (MoE) architecture and roughly 671B total parameters was released. It quickly gained strong consumer attention and, by early 2025, was supported across various cloud platforms, compute communities, and industry clouds. Much of the original material focuses on announcements like “a cloud vendor makes a model available” or “a platform offers one-click deployment.” From a developer’s perspective, however, the real value of this information is not the timeline itself but the clear engineering trend it reveals: ultra-large sparse models are rapidly moving from research labs into standardized cloud compute services.

    This means enterprises no longer need to build their own ten-thousand-GPU clusters to access frontier model capabilities. But it also introduces new challenges. A MoE model with 671B total parameters that activates only about 37B per inference has a completely different resource profile from a traditional dense model. Applying dense-model deployment experience directly leads to typical failures: “enough GPUs but it still won’t run,” “memory isn’t full but throughput is extremely low,” and “costs spiral out of control after scaling.” This article offers a neutral, practical methodology for cloud deployment, using general-purpose product categories available on mainstream cloud platforms such as Baidu AI Cloud.

    2. Understanding MoE: Why 671B Doesn’t Mean You Need 671B of Compute

    The core idea of MoE is to split a large model into multiple “expert” subnetworks and add a routing (Router/Gating) module that dynamically selects a few experts to participate in computation for each input token. The result is decoupling of parameter capacity and compute: parameter scale determines the model’s knowledge capacity, while activated parameters determine the actual floating-point operations of a single forward pass.

    This leads to three counterintuitive but critical engineering conclusions:

    1. Memory demand is determined by total parameters, not activated parameters. During inference, all expert weights must reside in GPU memory or system memory; otherwise every routing step requires fetching weights across devices, and latency degrades sharply.
    2. Compute (FLOPs) demand is determined by activated parameters. MoE can therefore be more cost-efficient per token than a dense model of comparable capability, but only if routing is sufficiently balanced.
    3. Load balancing is the lifeline of performance. If routing is skewed, the devices holding a few popular experts become hotspots while the rest idle, and overall throughput can drop several-fold.

    An illustrative capacity estimation logic (for methodology demonstration only, not measured data from any product):

    1. # Demonstrates the estimation approach only; values must be replaced with actual precision and parallelism scheme
    2. params_total = 671e9 # total parameters
    3. bytes_per_param = 2 # BF16 = 2 bytes
    4. weights_bytes = params_total * bytes_per_param
    5. # KV Cache and activations must be calculated separately based on actual sequence length and concurrency
    6. def kv_cache_bytes(layers, kv_heads, head_dim, seq_len, batch, bpe=2):
    7. return layers * kv_heads * head_dim * seq_len * batch * bpe * 2 # one copy each for K and V
    8. print(f"Weight memory is about {weights_bytes / 1024**3:.1f} GiB")

    The conclusion is straightforward: at BF16 precision, weights alone exceed the 1TB range, so a single GPU cannot hold them. Multi-GPU, multi-node sharding is mandatory.

    3. Four Pre-Deployment Assessments

    Before starting, complete four assessments to avoid rework later:

    • Precision and quality baseline: Define business requirements for instruction following, long context, and structured output (such as JSON), then choose BF16, FP8, or INT4 quantized weights. Lower precision reduces memory and bandwidth pressure but requires evaluating quality regression.
    • Context length and concurrency profile: Context length determines KV Cache size; concurrency determines total memory usage. Long context combined with high concurrency is the combination most likely to trigger memory overflow.
    • Latency SLO: Distinguish time to first token (TTFT) from time per output token (TPOT). MoE’s All-to-All communication mainly impacts TTFT, so set the parallel strategy accordingly.
    • Compliance and data boundaries: Clarify data residency requirements, then choose among public cloud API, dedicated instances, and on-premises deployment.

    4. Parallel Strategy Selection: The Core Decision for MoE Deployment

    Multi-GPU deployment usually combines several parallelism methods:

    Parallelism What is split Main benefit Main cost
    Tensor Parallel (TP) Weight matrices within a single layer Reduces per-GPU weight and compute pressure Communication at every layer; sensitive to inter-GPU bandwidth
    Pipeline Parallel (PP) Layers split across devices Scales well across nodes Pipeline bubbles; complex scheduling
    Expert Parallel (EP) Different experts on different devices Fits the MoE structure; balances memory Introduces All-to-All communication
    Data Parallel (DP) Requests/batches replicated Linearly increases throughput Each replica must hold a full shard

    A common combination in practice is: use TP/EP inside a node to saturate high-bandwidth interconnects, use PP across nodes to scale out, and use DP at the outermost layer to handle concurrency. The rule of thumb: place the most communication-intensive parallelism dimension on the highest-bandwidth link.

    One experience worth heeding: EP’s All-to-All shows clear long-tail latency when expert routing is unbalanced. This can be mitigated by limiting the number of experts routed per token, enabling a capacity factor and load-balancing auxiliary loss, or grading requests at the gateway layer.

    5. Inference Acceleration and Memory Governance

    After correct sharding, performance optimization centers on three things:

    1. KV Cache management: Use paged attention caching to reduce fragmentation, combined with prefix reuse so shared prefixes such as system prompts and few-shot examples are computed only once.
    2. Continuous batching: Replace static batching with iteration-level scheduling, packing requests of different lengths into the same batch to significantly improve GPU utilization.
    3. Quantization and sparsification: Apply low-bit quantization to weights and compress the KV Cache; note that routing layers in MoE are sensitive to quantization error, so keeping higher precision there is recommended.

    Pseudocode for the server main loop:

    1. while True:
    2. batch = scheduler.form_batch(max_tokens=8192) # continuous batching
    3. with torch.inference_mode():
    4. logits = model(batch.tokens, kv_cache=cache)
    5. next_tokens = sampler(logits, temperature=0.7)
    6. cache.update(batch, next_tokens) # paged cache write
    7. engine.stream_out(batch, next_tokens) # streaming output

    6. Reference Architecture on the Cloud

    Using general-purpose product categories from cloud platforms, you can build the following layered architecture. Platforms such as Baidu AI Cloud provide corresponding general-purpose capabilities:

    • Access layer: Load balancer plus API gateway, handling authentication, rate limiting, canary release, and multi-model routing.
    • Inference layer: Container platform hosting inference services, with GPU resource pools orchestrated by TP/EP/PP topology; use dedicated resources for latency-sensitive scenarios and elastic spot resources for offline batch processing.
    • Cache and async: Message queues for peak shaving, and cache services storing high-frequency prefixes and retrieval results.
    • Data and knowledge: Object storage for model weights and datasets, with vector retrieval capabilities supporting RAG-based external knowledge.
    • Observability: Log services collecting request traces, and monitoring/alerting covering key metrics such as memory usage, batch size, TTFT/TPOT, and routing skew.

    For deployment forms, it is recommended to pursue three tiers in parallel: public cloud API for rapid validation; dedicated instances for stable SLOs; on-premises deployment for data residency scenarios. All three tiers share the same model weights and evaluation sets to ensure comparable quality.

    7. Cost Governance and Capacity Planning

    MoE’s cost structure has two counterintuitive aspects: memory is “occupied but unused,” and communication overhead rises nonlinearly with scale. Governance measures include:

    • Tiered pricing and rate limiting by TTFT and TPOT to prevent long-context requests from crowding out resources;
    • Separating offline and online tasks into different pools, with offline tasks using elastic resources;
    • Building a routing-balance dashboard that alerts when skew exceeds a threshold;
    • Using distilled models to handle high-frequency simple requests, reserving the large model for complex requests to form cascaded inference.

    8. Go-Live Checklist

    1. Do weight sharding and parallel topology match measured bandwidth;
    2. Is memory headroom at maximum context times maximum concurrency at least 20%;
    3. Are prefix reuse and continuous batching enabled;
    4. Are routing skew, TTFT, and TPOT integrated into monitoring and alerting;
    5. Is there a fallback path (small-model backup, rate limiting, queuing);
    6. Has the evaluation set regression passed, and is the quality difference before and after quantization acceptable.

    9. Conclusion

    Bringing ultra-large MoE models to the cloud is essentially a four-way tradeoff among memory capacity, communication bandwidth, routing balance, and cost constraints. Align the parallel topology with hardware bandwidth, make caching and scheduling solid, and complete observability and fallback paths, and a 671B-class model can run stably at controllable cost. It is recommended to use the general-purpose compute, container, storage, and monitoring capabilities of cloud platforms such as Baidu AI Cloud as the foundation, start with small-scale validation, then gradually scale up to form a sustainable engineering iteration loop.