4-Node MoE Local Deployment: Architecture, Parallelism, and Benchmarking Guide

    This guide explores the complete path for locally deploying Mixture of Experts (MoE) large models across a 4-node cluster. It covers cluster hardware design, memory and capacity estimation, parallelism strategies using vLLM, RDMA networking configuration, quantization precision evaluation, long-context handling, and performance benchmarking methodologies to ensure efficient and scalable inference.

    I. Why Deploy Large Models Locally?

    Enterprises typically choose to run large model inference locally for three main reasons: data must remain within the internal network to meet compliance requirements; sensitive business data cannot be handed over to external services; and internal network access offers low latency and high stability.

    The new generation of large models largely adopts the Mixture of Experts (MoE) architecture. These models often have hundreds of billions of total parameters, but only activate a small fraction of experts per token. During inference, all expert weights must still reside in accessible memory. Combined with the KV Cache, a single device is usually insufficient. Therefore, multi-node collaborative inference has become a common choice.

    This article uses a cluster of four compute nodes and one high-speed switch as an example to illustrate the complete path from hardware to benchmarking. The numbers provided are illustrative. Actual configurations should be re-measured using your own hardware and models.

    II. Cluster Hardware Design

    1. Node Memory

    Each node is equipped with approximately 128GB of unified memory, where the CPU and GPU share the same physical memory pool. The four nodes total about 512GB of memory. Two points require attention. First, the operating system and runtime will occupy a portion of the memory, so the capacity available for weights is lower than the nominal value. You should base your calculations on actual measured available memory. Second, cross-node memory is not automatically merged into a single address space. Model weights must be sharded across nodes via tensor parallelism or pipeline parallelism, with each node holding only its own slice.

    2. Star Topology and Bandwidth

    The four nodes are interconnected via a single 400G switch. Each node only communicates with the switch, resulting in simple cabling and avoiding the complex topology brought by point-to-point direct connections between nodes.

    400G is the port line rate, which does not equal the effective bandwidth at the application layer. RDMA and RoCE can reduce communication latency, but this is predicated on the correct lossless network configuration of the NICs and switches, including PFC and ECN. Before going live, use tools like ib_write_bw to measure the actual bandwidth and latency between any two nodes and record the results as a baseline. If the measured bandwidth is only a small fraction of the nominal value, check the PFC, ECN, and MTU settings first.

    3. Tiered Storage

    Placing low-frequency data, such as lookup tables and cold data, on local NVMe SSDs can free up memory for the KV Cache and concurrent requests. The trade-off is higher read latency, so this is only suitable for data outside the critical path. Active inference weights and the active KV Cache should not be placed on SSDs.

    III. Key Steps in Model Deployment

    1. Capacity Estimation

    First, estimate the weights. The weight footprint is roughly equal to the number of parameters multiplied by the number of bytes per parameter. Taking a 480B parameter model as an example, FP8 weights require about 480GB, and FP4 weights require about 240GB.

    The KV Cache footprint can be estimated using the following formula:

    Bytes per token = 2 * num_layers * num_kv_heads * head_dim * bytes_per_element

    Assuming the model has 60 layers, 8 KV heads, a head dimension of 128, and the KV Cache uses FP16 (2 bytes), the footprint per token is 2 * 60 * 8 * 128 * 2 = 245,760 bytes. A single request reaching a 1M token context would require about 245GB just for the KV Cache. If FP8 is used to store the KV Cache, the footprint is halved.

    The sum of weights and KV Cache must be less than the cluster’s available memory, and you must leave a buffer for activations and memory fragmentation.

    2. Inference Engine and Parallelism Configuration

    This section uses vLLM as an example. Parameter names vary across different engines. Before deployment, consult the documentation of your specific version to confirm that it supports multi-node deployment and your chosen model architecture.

    The principles for selecting a parallelism strategy are as follows:

    • Fitting the sharded weights and KV Cache within a single node is the prerequisite for execution.
    • Tensor Parallelism (TP) requires communication at every layer and should be kept within the fastest communication range. Cross-node TP significantly increases latency.
    • Pipeline Parallelism (PP) only passes activations between adjacent stages, resulting in minimal communication. It is well-suited for cross-node sharding.
    • Expert Parallelism (EP) requires all-to-all communication and is sensitive to bandwidth and latency. It should be enabled only after confirming its benefits through benchmarking.
    • Enabling Continuous Batching and Chunked Prefill can improve throughput in concurrent scenarios.

    The following example assumes each node provides a set of accelerator units, with intra-node tensor parallelism set to 1, and pipeline parallelism across the four nodes (PP=4). The FP8 weights of the example model are about 480GB, which leaves almost no room for the KV Cache when sharded to 120GB per node. Therefore, this scenario should use FP4 weights (about 60GB per node) or switch to a smaller model.

    Set the RDMA-related environment variables on each node:

    1. export NCCL_IB_HCA=mlx5 # Specify RDMA NIC prefix, modify based on ibstat output
    2. export NCCL_IB_GID_INDEX=3 # Common index for RoCE v2, confirm with show_gids
    3. export NCCL_SOCKET_IFNAME=eth0 # NIC used for the control plane
    4. export NCCL_DEBUG=INFO # Enable during initial deployment to verify communication paths

    Start Ray on the head node (assuming IP is 10.0.0.1):

    1. ray start --head --port=6379

    Execute the following command on the other three nodes respectively:

    1. ray start --address='10.0.0.1:6379'

    Start the inference service on the head node:

    1. vllm serve /models/your-model \
    2. --tensor-parallel-size 1 \
    3. --pipeline-parallel-size 4 \
    4. --distributed-executor-backend ray \
    5. --max-model-len 65536 \
    6. --gpu-memory-utilization 0.90 \
    7. --enable-chunked-prefill \
    8. --port 8000

    Note: --gpu-memory-utilization is designed for accelerator VRAM. On unified memory platforms, its actual behavior should be verified against the version’s documentation and empirical testing.

    RDMA and RoCE Pre-Launch Checklist:

    • Use ibstat to confirm that all port statuses are Active and the rates match the switch configuration.
    • Use show_gids to confirm the GID index used by RoCE v2, and ensure it matches NCCL_IB_GID_INDEX.
    • Run ib_write_bw between any two nodes and record the bandwidth and latency.
    • Confirm that the switch’s PFC and ECN configurations match the NICs; otherwise, packet loss will cause severe performance degradation.
    • Check the NCCL logs after the first startup. The logs should show information indicating the use of the IB network. If only Socket is visible, communication has fallen back to TCP and requires troubleshooting.

    3. Quantization

    Some models officially provide FP8 weights, while others offer FP4 versions. Whether FP4 can be used depends on the inference engine and hardware. Before deployment, check the engine’s support matrix, then perform a precision regression using a fixed evaluation set to compare the score difference between the original and quantized models. Claims of “near-lossless precision” must be backed by data. For example, the performance drop on the target business evaluation set can be kept within 1 percentage point, with the threshold determined by the business stakeholders.

    4. Ultra-Long Context

    The KV Cache footprint for a million-token context is detailed in the previous estimation. A single full-length request can occupy hundreds of gigabytes of cache, meaning a 4-node cluster typically cannot serve multiple full-length requests simultaneously. Practical approaches include:

    • Set max-model-len based on the percentile of actual business request lengths, rather than the model’s theoretical maximum.
    • Enable KV Cache quantization and prefix caching reuse for long-document businesses to reduce redundant computation and memory footprint.
    • Implement degradation strategies. Long requests exceeding the threshold should be queued, rate-limited, or forwarded to a smaller model.
    • The concurrency limit for long contexts in a single cluster should be based on empirical test results, not extrapolated from short-text concurrency data.

    IV. Performance Benchmarking Methodology

    1. Scenario Design

    Benchmarking should cover real-world business scenarios. It is recommended to include four categories:

    • Daily Q&A: Short input, short output. Focus on Time To First Token (TTFT).
    • Document Processing: Long input. Focus on prefill throughput.
    • Complex Reasoning: Long output. Focus on decode speed.
    • AI Coding & Agents: Multi-turn, high concurrency. Focus on overall throughput and stability.

    2. Benchmarking Commands

    Benchmarking uses the benchmark_serving.py script from the vLLM repository. The script path and parameters may change with versions; the following example references the current mainstream version:

    1. python benchmarks/benchmark_serving.py