Training Trillion-Parameter Multimodal Models on 2 Nodes and 16 GPUs: Adaptation Steps and Troubleshooting Checklist

    This article provides a practical guide for training trillion-parameter multimodal models on a 2-node, 16-GPU cluster. It covers configuring parallelism degrees (data, tensor, pipeline, and expert parallel), optimizing inter-node communication, managing multimodal feature packing and memory control, handling data pipelines and checkpoint recovery, and validating the setup through a continuous 400-step stability test. Readers will gain a comprehensive checklist to ensure efficient and stable distributed training.

    1. Confirm the Relationship Between Parallelism and GPU Count

    A 2-node, 16-GPU setup has a total of 16 ranks. The product of parallelism degrees must equal the total number of ranks participating in training and cannot exceed 16. In an original example where data_parallel=8, tensor_parallel=2, and pipeline_parallel=2, the product is 32. This exceeds the available number of GPUs and cannot be directly applied.

    Here is a feasible example where dp×tp×pp=4×2×2=16:

    1. parallel_plan:
    2. data_parallel: 4
    3. tensor_parallel: 2
    4. pipeline_parallel: 2
    5. sequence_parallel: true # Reuses tensor parallel group, does not occupy additional ranks
    6. communication:
    7. topology_aware_rank_mapping: true
    8. overlap_gradient_reduce: true
    9. bucket_size: adaptive
    10. checkpoint:
    11. interval_steps: 50
    12. async_write: true

    If expert parallelism is introduced and it occupies GPUs separately, the expert parallelism degree must be included in the product, ensuring the total does not exceed 16. The selection order is: first determine the splitting lower limit (tp×pp) based on single-GPU memory estimation, then determine the cross-node parallel groups, and finally use data parallelism to expand throughput.

    2. Checklist for Inter-Node Parallel Groups

    Assume node 0 hosts ranks 0 to 7, and node 1 hosts ranks 8 to 15. Numbered by rank = pp_stage×8 + dp_idx×2 + tp_idx, we get the following groups:

    • Tensor parallel groups, e.g., {0,1}, {2,3}, are all located within nodes.
    • Data parallel groups, e.g., {0,2,4,6}, {1,3,5,7}, are all located within nodes.
    • Pipeline parallel groups, e.g., {0,8}, {1,9}, span across nodes and only pass activations of adjacent stages, involving smaller data volumes.

    Follow these steps for evaluation:

    1. Tensor parallel groups must be located within a node. If splitting solely by pipeline parallelism still cannot fit the model in single-GPU memory, prioritize increasing pipeline parallelism depth or increasing the activation recomputation ratio, rather than splitting tensor parallelism across nodes.
    2. Estimate the cross-node communication time per step. The formula is: Communication time ≈ Cross-node bytes per step ÷ Measured effective bandwidth. The cross-node bytes per step are accumulated based on the synchronization count and tensor size of each parallel group.
    3. If the communication time exceeds 30% of the single-step computation time, it is judged as a communication bottleneck. 30% is an initial threshold and should be calibrated with measured data.
    4. For cross-node data parallel synchronization, enable gradient bucketing and overlap gradient reduction with backward computation.

    When bandwidth is insufficient, downgrade in the following order: first, enable gradient bucketing and overlap; second, increase the number of micro-batches in pipeline parallelism to reduce pipeline bubbles (at the cost of increased activation memory); third, increase the activation recomputation ratio for long-sequence scenarios; finally, reduce the number of GPUs participating in training, which will decrease throughput.

    3. Multimodal Feature Packing and Memory Control

    The multimodal feature block for each sample should record the following fields: sample_id, modality_type (image, video, or audio), token_offset, token_len, position_ids, attention_segment_id, and loss_mask. With unified fields, the attention mask and position encoding at the sequence splitting boundaries can be verified segment by segment without relying on manual checks.

    The multimodal token upper limit per sample should start from the 99.9th percentile length of the dataset. Samples exceeding the limit should be downsampled or truncated, and the count should be accumulated. If the count exceeds 0.1% of the total samples, it indicates that the upper limit is set too low or there are issues with data cleaning.

    Dynamic batching should batch by the total token count per micro-batch, rather than a fixed sample count. The token budget can be set to around 80% of the memory allowance limit, leaving a margin for temporary buffers and communication buffers.

    Activation peak recording is performed at the 100-step stage. After the forward pass of each layer, read the memory peak statistics interface provided by the framework, recording the layer number, peak memory, and communication volume for that layer. When a step-like jump appears in the peak curve, it usually corresponds to a specific layer or a specific type of sample, such as an ultra-long video sample.

    4. Data Pipeline and Checkpoint Recovery

    Data sharding is divided by sample level or block level. The prefetch queue depth should cover the duration of 2 to 3 computation steps. A queue that is too shallow will cause data starvation, while one too deep will occupy too much memory. Samples must complete decoding, size verification, and token length statistics before entering training. Samples that fail verification are written to an isolation list and do not enter the training process.

    A checkpoint contains model parameters, optimizer state, learning rate scheduler state, data reading progress, and random number state. An asynchronously written checkpoint must complete writing and pass verification before the latest pointer is updated. This way, even if the process crashes during writing, the recovery logic will only read the last complete checkpoint.

    After recovery, verify item by item according to the following table:

    Item Comparison Method Pass Criteria
    Model parameters Hash value of each shard Consistent with when saved
    Optimizer state Hash of momentum and variance Consistent with when saved
    Learning rate scheduler Current step and learning rate value Exactly equal
    Data reading progress Shard ID and sample cursor Start from the next sample of the save point
    Random number state RNG state of each device Consistent with when saved

    5. Continuous 400-Step Stability Verification

    When verifying, use the following initial thresholds to determine if it passes:

    Metric Measurement Method Initial Threshold
    Loss Relative deviation compared to the original run at the same step (steps 1 to 5 after recovery) Not exceeding 0.5%
    Gradient norm Ratio within the same window Between 0.9 and 1.1
    Memory Peak growth per 100 steps after steady state Not exceeding 2%
    Communication timeout Retry count per step Not exceeding 3 times per step, and not exceeding 10 times for 400 steps
    Loss spike