Run multi-node GPU training with eRDMA

Updated at:

Inter-node communication is often the bottleneck in multi-node GPU training, and dedicated networks like RoCE or InfiniBand can be costly. By enabling Alibaba Cloud Elastic RDMA (eRDMA) on GPU-equipped clusters, you can achieve high-throughput, low-latency communication within a VPC without a dedicated network. This topic shows you how to use eRDMA with Arena to submit distributed PyTorch jobs and accelerate your training workloads.

Prerequisites

How it works

eRDMA provides Remote Direct Memory Access (RDMA) capabilities over a standard VPC network. It bypasses the kernel protocol stack to perform direct memory reads and writes between nodes. This significantly reduces communication latency and increases throughput, which helps alleviate the network bottleneck in multi-node training.

This tutorial guides you through the following process:

  1. Install the ACK eRDMA Controller add-on to enable the cluster to recognize and schedule eRDMA resources.

  2. Create and configure a GPU node pool.

  3. Verify the GPU and eRDMA resources on the nodes.

  4. Submit a training job using Arena and verify eRDMA acceleration.

Procedure

Step 1: Install the ACK eRDMA Controller add-on

Before you create an eRDMA- and GPU-enabled node pool, you must install the ACK eRDMA Controller add-on. If your cluster already contains nodes before you install the add-on, ensure the node pools are configured as described in Step 2. Then, remove the existing nodes from the node pools and add them back to enable eRDMA.

Note
  • If your cluster uses the Terway network plug-in, you must add the eRDMA network interface to Terway's allowlist. This prevents Terway from modifying the eRDMA network interface. For instructions, see Configure an allowlist for elastic network interfaces (ENIs).

  • When a node has multiple network interfaces, the ACK eRDMA Controller assigns a lower routing priority (default value: 200) to the additional eRDMA network interface compared to other interfaces on the same subnet. If you configure the network interface manually, avoid routing conflicts.

  1. Log on to the ACK console. In the left navigation pane, click Clusters.

  2. On the Clusters page, click the name of your cluster. In the left navigation pane, click Components and Add-ons .

  3. On the Add-ons page, click the Networking tab, find the ACK eRDMA Controller add-on, and follow the on-screen instructions to configure and install it. The following table describes the key parameters.

    Parameter

    Description

    preferDriver (Driver type)

    Select the eRDMA driver type to use on the cluster nodes. For GPU scenarios, you must select ofed.

    For more information about driver types, see Enable eRDMA.

    Specifies whether to assign all eRDMA devices of nodes to pods

    Valid values:

    • True (selected): Allocates all eRDMA devices on a node to a Pod. You must select this option for GPU scenarios.

    • False (cleared): Allocates one eRDMA device to a Pod based on the NUMA topology. To ensure fixed NUMA allocation for Pods and devices, you must enable the CPU Static Policy on the node. For instructions, see Create and manage a node pool.

After the installation is complete, in the left-side navigation pane, choose Workloads > Pods. Select the ack-erdma-controller namespace and check the status of the Pods to confirm that the add-on is running correctly.

Step 2: Create and configure a GPU node pool

  1. Log on to the ACK console. In the left navigation pane, click Clusters.

  2. On the Clusters page, click the name of your cluster. In the left navigation pane, click Nodes > Node Pools.

  3. Click Create Node Pool and configure the parameters as described in the following steps. For information about other parameters, see Create and manage a node pool.

    1. Configure the node pool image: In the Instance and Image > Operating System section, select the Alibaba Cloud Linux 3 64-bit (pre-installed with the eRDMA software stack) image from Marketplace Image. This image uses cgroup v2. For the image IDs and version information in different availability zones, see Marketplace Image Details.

    2. Configure the GPU node driver version: In the Advanced Options (Optional) > Node Labels section, add a label with Key set to ack.aliyun.com/nvidia-driver-version and Value set to 580.126.09.

    3. Configure a script to disable the PCIe ACS (Access Control Services) feature: Disabling PCIe ACS improves the P2P communication capability between GPUs and eRDMA NICs. In Advanced Options (Optional) > Pre-defined Custom Data, enter the following script to automatically disable PCIe ACS when the node starts up.

      config_disable_acs_service(){
              cat << 'EOF' > /usr/bin/disable_pcie_acs
      #!/bin/bash
      ret=0
      found_acs_pci=0
      for BDF in $(lspci -d "*:*:*" | awk '{print $1}'); do
        # skip if it doesn't support ACS
        setpci -v -s ${BDF} ECAP_ACS+0x6.w > /dev/null 2>&1
        if [ $? -ne 0 ]; then
          continue
        else
          found_acs_pci=1
          setpci -v -s ${BDF} ECAP_ACS+0x6.w=0000
          if [ $? -eq 0 ]; then
            echo "[SUCCESS] Disabled ACS on ${BDF}"
          else
            echo "[ERROR] Failed to Disable ACS on ${BDF}"
            ((ret++))
          fi
        fi
      done
      if [ $found_acs_pci -eq 0 ]; then
        echo "[SKIP] no device found that supports ACS"
      fi
      exit $ret
      EOF
          chmod +x /usr/bin/disable_pcie_acs
       
          # Create a systemd service file
          cat << 'EOF' > /etc/systemd/system/disable_pcie_acs.service
      [Unit]
       
      Description=Disable PCIe Access Control Services (ACS)
      After=multi-user.target
       
      [Service]
      Type=oneshot
      ExecStart=/usr/bin/disable_pcie_acs
      RemainAfterExit=yes
       
      [Install]
      WantedBy=multi-user.target
      EOF
       
          # Reload the systemd configuration and enable auto-start on boot
          systemctl daemon-reload
          systemctl enable disable_pcie_acs.service
          systemctl start disable_pcie_acs.service
          echo "disable_pcie_acs service has been configured and enabled for auto-start"
      }
      config_disable_acs_service

      After the node is created, you can log on to the node and run the lspci -vvv | grep ACSCtl command to check the status of PCIe ACS. If the output contains SrcValid-, PCIe ACS is disabled. If the output contains SrcValid+, it is still enabled. Check if the script was executed correctly.

      Note

      The GPUs on ecs.ebmgn9g, ecs.ebmgn9gc, and ecs.ebmgn9ge instances are not connected by high-speed interconnects like NVLink or NVSwitch. Intra-node GPU-to-GPU communication defaults to PCIe, which is much less efficient. Therefore, in addition to using eRDMA for inter-node acceleration, you must disable PCIe ACS to improve peer-to-peer (P2P) communication between the GPUs and eRDMA network interfaces within the node.

Step 3: Verify eRDMA resources on nodes

After the node pool is created, verify that the GPU and eRDMA resources on the nodes are correctly identified and available for scheduling.

  • Method 1: Connect to the cluster using kubectl and run the following command to view the allocatable resources of a node.

    kubectl get node <node-name> -o jsonpath='{.status.allocatable}'

    The following output indicates that the node has successfully reported its GPU and eRDMA resources:

    {"aliyun/erdma":"400","cpu":"15890m","ephemeral-storage":"243149919035","hugepages-1Gi":"0","hugepages-2Mi":"0","memory":"128290128Ki","nvidia.com/gpu":"1","pods":"64"}
    • "nvidia.com/gpu":"1": Indicates that one GPU is available.

    • "aliyun/erdma":"400": Indicates that 400 eRDMA resources are allocatable on this node.

  • Method 2: Log on to an eRDMA-enabled node and run the following command to view eRDMA device information.

    ibv_devinfo

    The expected output shows two devices, erdma_0 and erdma_1, with a port state of PORT_ACTIVE. This indicates that the eRDMA devices are enabled and functioning correctly.

Step 4 (Optional): Install KubeSkoop for eRDMA monitoring

To monitor eRDMA traffic during training, you can install the ACK KubeSkoop add-on and enable monitoring. Install the add-on before submitting the training job to ensure complete traffic data collection.

  1. On the Clusters page, click the name of your cluster. In the left navigation pane, click Components and Add-ons .

  2. On the Add-ons page, click the Networking tab, find the ACK KubeSkoop add-on, and follow the on-screen instructions to configure and install it.

  3. After the installation is complete, in the left-side navigation pane, choose Workloads > Pods. Select the ack-kubeskoop namespace and check the status of the Pods to confirm that the add-on is running correctly. Then, go to the ARMS console, search for ACK KubeSkoop Network Monitoring, select your cluster, and complete the monitoring setup.

Step 5: Submit a training job using Arena

Use Arena to submit a distributed PyTorch training job and request eRDMA resources to accelerate inter-node communication.

  1. Install the Cloud-native AI Suite.

  2. Configure the Arena client and submit the training job. For more information about the parameters, see Key parameters for Arena job submission.

  3. Create two OSS PVC instances named mymodels and myworkspace to store the model, training output, and configuration files.

This tutorial uses the official ms-swift 4.2.0 image with added eRDMA support. For instructions on how to build the image, see Build a container image with eRDMA support for production. The training job uses two nodes and GRPO to perform reinforcement learning fine-tuning on the Qwen/Qwen3.5-35B-A3B model.

If you encounter any issues during training, see the FAQ section. For a complete description of NCCL environment variables, see the Appendix.

arena submit pytorch \
    --name=pytorch-swift \
    --namespace=default \
    --workers=2 \
    --gpus=8 \
    --share-memory=1000Gi \
    --device=aliyun/erdma=2 \
    --nproc-per-node=8 \
    --env=UCX_TLS=tcp \
    --env=UCX_NET_DEVICES=eth0 \
    --env=NCCL_SOCKET_IFNAME=eth0 \
    --env=NCCL_IB_HCA=erdma_0,erdma_1 \
    --env=NCCL_IB_DISABLE=0 \
    --env=NCCL_IB_GID_INDEX=1 \
    --env=NCCL_NET_GDR_LEVEL=SYS \
    --env=NCCL_P2P_LEVEL=SYS \
    --env=NCCL_GIN_TYPE=0 \
    --env=FLA_TILELANG=0 \
    --env=VLLM_MOE_BACKEND=triton \
    --data=mymodels:/models \
    --data=myworkspace:/workspace \
    --clean-task-policy=None \
    --image=kube-ai-registry.cn-shanghai.cr.aliyuncs.com/kube-ai/swift:ubuntu22.04-cuda13.0.3-py312-torch2.11.0-vllm0.20.1-modelscope1.36.3-erdma \
    --image-pull-policy=Always \
    --tensorboard \
    --logdir=/workspace/logs \
    "export NNODES=\$PET_NNODES \
     MASTER_ADDR=\$PET_MASTER_ADDR \
     MASTER_PORT=\$PET_MASTER_PORT \
     NPROC_PER_NODE=\$PET_NPROC_PER_NODE \
     NODE_RANK=\$PET_NODE_RANK && \
     megatron rlhf \
       --rlhf_type grpo \
       --model /models/Qwen/Qwen3.5-35B-A3B \
       --dataset open-r1/DAPO-Math-17k-Processed \
       --tuner_type full \
       --packing true \
       --enable_thinking false \
       --max_length 2048 \
       --global_batch_size 32 \
       --micro_batch_size 1 \
       --num_generations 8 \
       --max_completion_length 512 \
       --tensor_model_parallel_size 4 \
       --expert_tensor_parallel_size 1 \
       --expert_model_parallel_size 8 \
       --sequence_parallel true \
       --optimizer_cpu_offload true \
       --optimizer_offload_fraction 1 \
       --moe_grouped_gemm true \
       --moe_permute_fusion true \
       --reward_funcs accuracy \
       --temperature 0.9 \
       --train_iters 15 \
       --logging_steps 1 \
       --lr 5e-5 \
       --beta 0.04 \
       --epsilon 0.2 \
       --epsilon_high 0.28 \
       --attention_backend flash \
       --recompute_granularity full \
       --recompute_method uniform \
       --recompute_num_layers 1 \
       --dataloader_num_workers 4 \
       --dataloader_pin_memory true \
       --no_save_optim true \
       --no_save_rng true \
       --use_vllm true \
       --vllm_mode colocate \
       --vllm_gpu_memory_utilization 0.3 \
       --vllm_tensor_parallel_size 8 \
       --vllm_enforce_eager true \
       --vllm_max_model_len 2048 \
       --sleep_level 2 \
       --output_dir /workspace/output \
       --tensorboard_dir /workspace/logs"
Note

On ecs.ebmgn9g, ecs.ebmgn9gc, and ecs.ebmgn9ge instance types, you need to manually specify a NCCL topology graph file to ensure optimal communication efficiency. Save the file to an absolute path within the image and pass it using the --env=NCCL_GRAPH_FILE=<absolute-path-to-topology-file> parameter. For information on how to obtain the topology file, see NCCL environment variable configuration.

Step 6: Verify the job and eRDMA acceleration

Confirm that the training job has started successfully and that the eRDMA network is active.

  1. Check the logs of the master Pod. If the logs show training iteration information, the job is running correctly.

    kubectl logs pytorch-swift-worker-0 | head -n 50
  2. Verify that eRDMA is enabled. Look for the message Using network IB in the Pod logs. If this line appears, eRDMA is accelerating inter-node communication.

Step 7 (Optional): Monitor eRDMA traffic

If you installed the KubeSkoop add-on in Step 4, you can monitor the network traffic of the eRDMA interfaces in real time to verify data transmission.

  1. Go to the ARMS console. In the Connected Environments section, select your cluster. Under Add-ons Management, click ACK KubeSkoop Network Monitoring to view node-level and Pod-level monitoring dashboards.

    image.png

Performance comparison

By comparing relevant metrics and logs from training tasks, you can see the performance difference with and without eRDMA. As shown in the following figure, eRDMA can reduce training iteration time by over 28%.

Note

To clearly compare performance with and without eRDMA, both training jobs in the following comparison performed the same number of warmup rounds before execution. This data was measured in a specific lab environment and is for reference only. Actual performance may vary depending on your model, instance type, dataset, and network conditions.

image.png

ACK clusters provide the AI Profiling feature, which allows you to analyze training performance from multiple levels, including Torch, Python, and CUDA Kernel, to identify bottlenecks in computation, communication, and memory usage.

Clean up resources

After the training job is complete, run the following command to delete it. This operation deletes all Pods and resources associated with the job but does not delete persistent data such as TensorBoard logs.

arena delete pytorch-swift -n default

Expected output:

INFO[0001] The training job pytorch-swift has been deleted successfully

FAQ

Why don't the logs show "NET/IB : Using erdma_0"?

Possible reasons include:

  • The --device=aliyun/erdma=2 parameter was not included in the submission command.

  • The node does not support eRDMA, or the eRDMA Controller add-on was not installed correctly.

  • The container image is missing the RDMA user-space libraries (such as libibverbs and librdmacm).

To resolve this issue, perform the following steps:

  1. Run kubectl get node <node-name> -o jsonpath='{.status.allocatable}' to check if the node has the aliyun/erdma resource.

  2. Log on to the node and run ibv_devinfo to check if the eRDMA devices are functioning correctly.

  3. Check if the container image contains the necessary RDMA libraries.

Handling NCCL timeout errors

NCCL timeouts are typically caused by network instability or improper configuration. Try the following:

  1. Increase the timeout value: Set --env=NCCL_IB_TIMEOUT=23 (default is 20).

  2. Increase the retry count: Set --env=NCCL_IB_RETRY_CNT=10 (default is 7).

  3. Check the network connectivity between nodes and the status of the eRDMA devices.

Handling "NCCL Cannot allocate memory" errors

This error is usually caused by restrictive ulimit settings on the host machine. Try the following solutions:

  1. Check the ulimit settings of the node or the node's container runtime, focusing on locked memory, open files, and stack size. Note that this change applies globally at the node level and may cause memory fragmentation.

  2. Elevate the Pod's privilege level and set the ulimit values in the Pod's startup parameters. See the following example configuration.

    Important

    Elevating privileges introduces additional security risks. Configure this setting with caution and only after you fully understand the consequences.

    apiVersion: v1
    kind: Pod
    metadata:
      name: custom-ulimit
    spec:
      containers:
      - name: configure
        image: <YOUR_TRAINING_IMAGE>
        command:
        - /bin/sh
        - -c
        - |
          ulimit -l unlimited
          echo "Current memlock limit:"
          ulimit -l
          echo "Sleeping..."
          sleep infinity
        securityContext:
          capabilities:
            add: ["SYS_RESOURCE"]

How to verify eRDMA performance improvement?

You can compare performance using the following methods:

  1. Submit two separate training jobs, one with eRDMA and one without. You can differentiate them by including or omitting the --device=aliyun/erdma=2 parameter.

  2. Compare the completion time for the same number of training steps.

  3. Use the AI Profiling tool to analyze the proportion of time spent on communication.

The performance improvement from eRDMA is typically most significant in scenarios with multiple nodes (two or more) and large models (billions of parameters or more).

Handling Arena "insufficient resources" errors

Possible reasons include:

  • Insufficient GPU or eRDMA resources.

  • Nodes do not meet the scheduling conditions (for example, due to node selectors or taints and tolerations).

To resolve this issue, perform the following steps:

  1. Run kubectl get nodes to view the node status and available resources.

  2. Run kubectl describe pod <pod-name> to view detailed reasons for the Pod scheduling failure.

  3. Adjust the resource requests or add more nodes based on the error message.

Appendix

Key parameters for Arena job submission

Parameter

Description

Recommended Configuration

--name

The name of the job. Must be unique within the cluster.

Use a meaningful name.

--namespace

The namespace to which the job belongs.

Isolate by team or project.

--workers

The number of worker nodes, including the master.

Set to 2 for one master and one worker.

--gpus

The number of GPUs to use per worker.

Set based on model size and memory requirements.

--device=aliyun/erdma

The key parameter to enable eRDMA. Allocates eRDMA resources to each worker.

Must be set to enable eRDMA. For ecs.ebmgn9g, ecs.ebmgn9gc, and ecs.ebmgn9ge instance types, we recommend setting this to 2.

--nproc-per-node

The number of training processes to launch per node.

Usually set to the same value as --gpus.

--clean-task-policy

The Pod cleanup policy.

Set to None to keep Pods for log inspection.

--env

Environment variables.

Used to configure NCCL communication parameters.

NCCL environment variable configuration

When using ecs.ebmgn9g, ecs.ebmgn9gc, or ecs.ebmgn9ge instance types, you can use a preset NCCL communication topology file for fixed communication scenarios that use all 8 GPUs and 2 eRDMA network interfaces on a machine. This speeds up the NCCL initialization process and avoids communication inefficiencies caused by inaccurate topology detection in NCCL versions 2.30 and earlier. To use the topology file, set the NCCL_GRAPH_FILE environment variable to the absolute path of the topology XML file. Use this feature with caution and only after you have a thorough understanding of the NCCL communication process and your specific communication scenario.

Environment Variable

Description

Recommended Configuration

NCCL_IB_DISABLE

Controls whether to disable IB/RoCE.

Set to 0 for eRDMA scenarios. Set to 1 for troubleshooting.

NCCL_SOCKET_IFNAME

Specifies the network interface for communication.

Set to eth0 (the default network interface for ACK clusters).

NCCL_NET_GDR_LEVEL

The maximum topological distance between a GPU and a NIC for using GPU Direct RDMA. Values are LOC, PIX, PXB, PHB, and SYS, corresponding to 0-4.

For eRDMA scenarios, we recommend setting this to SYS.

NCCL_P2P_LEVEL

The maximum topological distance between GPUs for using peer-to-peer (P2P) communication. Values are LOC (0), NVL, PIX (1), PXB (2), PHB (3), and SYS (4).

For eRDMA scenarios, we recommend setting this to SYS to always use P2P within the same node.

NCCL_ALGO

The collective communication algorithm.

Options include Ring and Tree. Choose based on your network topology.

NCCL_DEBUG

The log level.

Set to INFO for debugging. Change to WARN for production environments.

NCCL_IB_HCA

Specifies the RDMA network interface to use.

Use ibstat to view the names of available network interfaces.

NCCL_IB_TIMEOUT

The InfiniBand (IB) communication timeout.

Adjust based on network latency.

NCCL_IB_RETRY_CNT

The number of retries for failed IB communication attempts.

Increase this value for unstable networks.

NCCL_SHM_DISABLE

Controls whether to disable shared memory when P2P is disabled. If disabled, communication falls back to sockets.

Adjust as needed based on your specific environment.

NCCL_GRAPH_FILE

Specifies the absolute path to the NCCL communication topology file.

Depends on the specific hardware topology. Only required for ecs.ebmgn9g, ecs.ebmgn9gc, and ecs.ebmgn9ge instance types. See the sample file.

For more information about NCCL environment variables, see the official NCCL documentation.

Sample Dockerfile

The following Dockerfile installs the eRDMA user-space libraries on top of the official ms-swift image. Use this Dockerfile as a reference for your custom training images.

FROM modelscope-registry.cn-beijing.cr.aliyuncs.com/modelscope-repo/modelscope:ubuntu22.04-cuda13.0.3-py312-torch2.11.0-vllm0.20.1-modelscope1.36.3-swift4.2.0

RUN wget -qO - https://mirrors.aliyun.com/erdma/GPGKEY | apt-key add - && echo "deb [ arch=amd64 ] https://mirrors.aliyun.com/erdma/apt/ubuntu jammy/erdma main" | tee /etc/apt/sources.list.d/erdma.list && apt update && apt install -y libibverbs1 ibverbs-providers ibverbs-utils librdmacm1

LoRA fine-tuning on Qwen3-4B-Instruct-2507

The following example uses two nodes with one GPU each to perform LoRA fine-tuning on the Qwen3-4B-Instruct-2507 model. Use this example as a simple verification scenario.

arena submit pytorch \
    --name=pytorch-swift \
    --namespace=default \
    --workers=2 \
    --gpus=1 \
    --nproc-per-node=1 \
    --device=aliyun/erdma=1 \
    --env=UCX_TLS=tcp \
    --env=UCX_NET_DEVICES=eth0 \
    --env=NCCL_SOCKET_IFNAME=eth0 \
    --env=NCCL_IB_HCA=erdma_0,erdma_1 \
    --env=NCCL_IB_DISABLE=0 \
    --env=NCCL_IB_GID_INDEX=1 \
    --env=NCCL_NET_GDR_LEVEL=SYS \
    --env=NCCL_P2P_LEVEL=SYS \
    --env=NCCL_GIN_TYPE=0 \
    --clean-task-policy=None \
    --image=kube-ai-registry.cn-shanghai.cr.aliyuncs.com/kube-ai/swift:ubuntu22.04-cuda13.0.3-py312-torch2.11.0-vllm0.20.1-modelscope1.36.3-erdma \
    --image-pull-policy=Always \
    --data=mymodels:/models \
    --data=myworkspace:/workspace \
    --tensorboard \
    --logdir=/workspace/logs \
    "torchrun \
      --master_port \${PET_MASTER_PORT} \
      --nproc_per_node=\${PET_NPROC_PER_NODE} \
      --nnodes=\${PET_NNODES} \
      --node_rank=\${PET_NODE_RANK} \
      --master_addr=\${PET_MASTER_ADDR} \
      sft.py \
      --model /models/Qwen/Qwen3-4B-Instruct-2507 \
      --tuner_type lora \
      --dataset 'swift/self-cognition#1000' \
      --num_train_epochs 1 \
      --lora_rank 8 \
      --lora_alpha 32 \
      --learning_rate 1e-4 \
      --gradient_accumulation_steps \$(( 32 / \$PET_NPROC_PER_NODE / \$PET_NNODES )) \
      --eval_steps 100 \
      --save_steps 100 \
      --save_total_limit 2 \
      --logging_steps 5 \
      --model_author swift \
      --model_name swift-robot"