Deploying a Trillion-Parameter MoE Model on Two Accelerator Servers with Baidu AI Cloud

    This article outlines a two-node deployment approach for a trillion-parameter multimodal MoE model on Baidu AI Cloud. It covers a 32-die configuration using TP16 × PP2 parallelism, 4-bit weights and 8-bit activations, network validation, weight and image preparation, service configuration, and staged load testing for long-context and agent workloads.

    Deploying a Trillion-Parameter MoE Model on Two Accelerator Servers with Baidu AI Cloud

    1. Background and Deployment Goals

    Native multimodal mixture-of-experts (MoE) models with roughly a trillion total parameters and tens of billions of active parameters are becoming important infrastructure for long-context inference and AI agent applications. These models can offer context windows of around one million tokens, process inputs such as text and images, and maintain extended conversation state for tool use and complex task planning.

    Deploying them presents substantial engineering challenges. Model weights occupy terabytes and cannot fit in a single server’s accelerator memory. Long contexts require much more KV cache memory than conventional conversational workloads. Cross-node communication, sharded weight loading, quantization operator compatibility, and service reliability all affect whether a deployment succeeds.

    This article describes a reusable deployment approach for engineering teams working in a Baidu AI Cloud environment:

    • Two accelerator servers, each with 16 accelerator dies and 64 GiB of memory per die, for a total of 32 dies.
    • Tensor parallelism of 16 within each server and pipeline parallelism of 2 across servers, giving a world size of 32.
    • Approximately 1.47 TB of quantized model weights, using 4-bit weights and 8-bit activations, distributed across several hundred shards.
    • A prebuilt inference image matched to the model version and pinned by digest for reproducibility.

    The goal is not simply to start an inference service. It is to complete a deployment workflow covering node registration, network planning, runtime configuration, service exposure, and load-test acceptance.

    2. Architecture Overview

    The design can be summarized as two nodes, 32 accelerator dies, TP16 × PP2, with long-context stability as the priority.

    Both nodes join the same accelerator communication network, referred to here as the parameter network. The platform selects deployment nodes according to that network topology. Within each node, high-bandwidth interconnects carry the frequent collective communication required by tensor parallelism. Across nodes, pipeline parallelism reduces communication frequency.

    The approximately 1.47 TB weight footprint uses 4-bit weight and 8-bit activation quantization to fit within the aggregate 32 × 64 GiB accelerator memory capacity while leaving room for the KV cache, activations, and runtime buffers.

    Component Configuration
    Nodes Two accelerator servers; 16 dies per server; 64 GiB per die; 32 dies in total
    Interconnect High-speed accelerator links within and between nodes, included in one parameter network
    Parallelism TP16 within each node, PP2 across nodes, world size 32
    Model Native multimodal MoE with trillion-scale total parameters, tens of billions of active parameters, a million-token context window, 4-bit weights and 8-bit activations, approximately 1.47 TB of weights, and several hundred weight shards
    Image A prebuilt inference image compatible with the model version, pinned by digest
    Platform Baidu AI Cloud container infrastructure, model deployment services, monitoring, and alerting

    The initial priority is not maximum single-request throughput. It is reliable coordination across all 32 dies, avoiding out-of-memory failures during long-context inference, and maintaining uninterrupted multi-turn agent tool use. Scheduling and concurrency can then be optimized incrementally.

    3. Key Design Decisions

    3.1 Parallelism: Why TP16 × PP2?

    The 32 dies need an appropriate parallel layout. Using tensor parallelism across all dies would significantly increase cross-node communication. Relying entirely on pipeline parallelism would still leave substantial memory pressure within individual stages.

    TP16 within each node keeps frequent tensor-parallel communication inside the node’s high-bandwidth domain. PP2 limits pipeline communication to two nodes, keeping the number of stages, pipeline bubbles, and scheduling complexity relatively manageable. A world size of 32 maps one-to-one to the 32 dies, simplifying shard assignment and fault isolation.

    Before deployment, verify that TP and PP are compatible with the model’s layer count, attention head count, and MoE expert distribution. If the layer count is not divisible by PP2, or the attention head count is not divisible by TP16, the runtime may encounter uneven partitioning, load imbalance, or startup failures.

    Check the model architecture parameters in advance, then run an initial health check to confirm that every rank can load its assigned weights.

    3.2 Memory Planning: Reserve Capacity for Long Contexts

    Total accelerator memory is 32 × 64 GiB, or approximately 2 TiB. Although approximately 1.47 TB of weights may appear to leave ample headroom, the KV cache can grow rapidly with million-token contexts. MoE routing, activations, communication buffers, and temporary quantization and dequantization allocations also consume memory.

    Usable headroom must therefore be measured through load testing. Concurrency should not be estimated from the weight footprint alone.

    Treat maximum context length, maximum concurrency, and maximum output length per request as joint constraints. For example, first validate an 80K-token context at low concurrency, then increase the context length to 200K tokens while monitoring memory usage, request queues, and time to first token.

    Agent workloads need particular attention because context accumulates over multiple tool-use rounds. A request that fits initially may exceed the memory limit in a later turn.

    3.3 Networking: Validate the Parameter Network

    The parameter network is central to two-node reliability. Add both nodes’ high-speed accelerator interconnects to the same network, allow the platform to validate accelerator connectivity, and select that network for deployment.

    Verify that:

    • All 16 accelerator dies on each node are recognized.
    • Cross-node links have no packet loss or reduced link speed.
    • Collective communication initializes without timeouts.
    • The deployment template’s network selection matches the actual topology.

    Do not force service startup if connectivity validation fails. Common causes include blocked ports, abnormal link states, inconsistent node identifiers, and restrictive network policies.

    Resolve network problems before loading weights. Otherwise, networking failures may be mistaken for model or image incompatibilities.

    4. Deployment Procedure

    4.1 Register the Nodes

    In the Baidu AI Cloud environment used for this deployment, add the servers through compute-node management, generate the installation command, and run it on both accelerator servers.

    After registration, verify:

    • Node status.
    • Detection of 16 accelerator dies per server.
    • Driver and runtime versions.
    • Memory capacity on each die.

    Keep the two node configurations as symmetrical as possible. Differences in processing capacity can create an imbalance between pipeline stages.

    4.2 Configure the Parameter Network

    Add both nodes’ accelerator interconnects to the same parameter network. The platform checks accelerator-to-accelerator connectivity and uses the selected network to choose nodes during deployment.

    Run a separate full connectivity validation before deployment and record link status and any affected dies. Cross-node PP2 communicates less frequently than cross-node tensor parallelism, but it still requires stable bandwidth and latency.

    4.3 Prepare the Weights and Inference Image

    The model weights occupy approximately 1.47 TB across several hundred shards. Confirm that every shard is present, checksums pass, and paths are consistent. Use high-throughput storage or fast local disks where possible to reduce the impact of random reads during loading.

    Choose a prebuilt inference image compatible with the model architecture and quantization format. Pin the image by digest to prevent image drift from introducing operator incompatibilities.

    The deployment template should explicitly specify the weight path, shard count, quantization format, maximum context length, and parallelism settings.

    The following YAML illustrates parameter relationships only; it is not a specific platform API:

    1. # Illustrative configuration: parameter relationships only
    2. model:
    3. path: /models/moe-quantized
    4. max_context_tokens: 1048576
    5. quantization: 4bit-weight-8bit-act
    6. parallel:
    7. tensor_parallel_size: 16
    8. pipeline_parallel_size: 2
    9. world_size: 32
    10. runtime:
    11. image: "<prebuilt-inference-image-pinned-by-digest>"
    12. weight_shards: 346
    13. health_check: /health

    4.4 Expose the Service and Run Health Checks

    Once the service starts, expose the inference endpoint through the platform gateway and configure health checks, timeouts, rate limits, and log collection.

    Long-context requests can have a high time to first token, so gateway timeouts should not simply reuse settings intended for short conversations. Agent tool use may involve multiple round trips, requiring appropriate session handling and retry policies.

    Begin with single-concurrency health requests to validate conversation, reasoning, and tool-use flows. Increase concurrency only after these checks pass.

    5. Load Testing and Acceptance

    Run load tests from a server-side client through the platform gateway to the inference instance, reducing the risk that the client network becomes the bottleneck.

    Use three workload groups:

    1. Random short- and medium-length sequences: approximately 2,048 input tokens and 512 output tokens.
    2. Long-context agent workloads: 80K-token inputs.
    3. Extended-context agent workloads: 200K-token inputs.

    The source deployment reported that all 836 requests completed successfully. This indicates that, with appropriate scheduling, the two-node, 32-die configuration could reliably support the tested workload mix.

    Acceptance should cover more than request success rate. Record:

    • Time to first token.
    • Time per token.
    • End-to-end latency.
    • Throughput.
    • Peak accelerator memory usage.
    • KV cache utilization.
    • Queue length.
    • Error-code distribution.
    • Inter-node link status.

    If success rates decline for long-context workloads, first inspect memory usage and maximum concurrency. If short-sequence throughput is low, examine batching and tensor-parallel communication efficiency. If tool-use workflows are interrupted, check gateway timeouts and session state handling.

    6. Troubleshooting and Best Practices

    Troubleshoot in the following order: resources → network → weights → image → parameters → service.

    Layer Checks
    Resources Confirm that all 32 accelerator dies are online
    Network Confirm that parameter-network connectivity validation passes
    Weights Verify shard completeness and checksum consistency
    Image Confirm that quantization operators support the model architecture
    Parameters Verify TP16, PP2, world size 32, and maximum context settings
    Service Check gateway timeouts, health checks, and logs for abnormalities

    Recommended practices include:

    • Pin both the image digest and the weight version.
    • Validate at low concurrency before testing long contexts.
    • Reserve sufficient accelerator memory for the KV cache.
    • Monitor memory usage and link status for every die.
    • Roll out new deployment templates gradually.
    • Retain load-test scripts and representative request samples.
    • Configure timeouts and retries specifically for agent workloads.
    • When out-of-memory failures occur, first reduce concurrency or maximum output length rather than adding nodes without diagnosing the cause.

    7. Conclusion

    Deploying a trillion-parameter MoE model on Baidu AI Cloud is a systems engineering task spanning resource topology, parallelism, quantized weights, long-context scheduling, and service management.

    The two-node, 32-die TP16 × PP2 design provides a practical deployment path: keep frequent tensor-parallel communication within each node, use pipeline parallelism across nodes to control communication frequency, and reduce memory pressure with 4-bit weights and 8-bit activations.

    A validated parameter network, pinned inference image, and staged load testing make the deployment reproducible and its acceptance measurable. For long-context and agent applications, sustained reliability depends on continuously observing and tuning memory headroom, concurrency limits, and timeout policies.