Getting Large Model Distributed Training Running on Domestic AI Accelerators: A Practical Guide

    This guide walks through the end-to-end process of standing up distributed training for large models on domestic AI accelerators. It covers why getting the training pipeline running is the critical first hurdle, how to align the software stack from drivers and firmware to communication and compute libraries, how to handle framework adaptation and operator compatibility, and how to design a parallel architecture (data, tensor, and pipeline parallelism) for a dual-node, 16-card setup. It also explains how to verify training stability and convergence through loss trends, gradient norms, memory and throughput, and learning-rate scheduling, along with common performance bottlenecks and troubleshooting approaches. Readers will come away with a repeatable, layered methodology for building a reliable training baseline that holds steady and scales out.

    1. Why “Getting the Pipeline Running” Is the First Hurdle in Large Model Deployment

    When developing large models with tens or hundreds of billions of parameters, the real difficulty often lies not in a single algorithmic innovation, but in running the entire training flow—from data loading, forward computation, and backpropagation to parameter updates—completely and stably. “Getting the training pipeline running” means that on a given hardware and software stack, the model can go through the full process from initialization to several hundred consecutive iterations, with a loss curve that decreases smoothly.

    This step may look basic, but it is the most critical and most easily underestimated part of adapting to domestic compute. Its value shows up in three main ways:

    • Validating the correctness of the hardware and software stack: ensuring computed results match expectations numerically, with no precision drift or incorrect updates.
    • Surfacing hidden problems: issues such as missing operators, communication anomalies, and memory overflow are often hard to reproduce on a single card or with a small model; they only show up clearly in a real distributed environment.
    • Establishing a scalable baseline: only when small-scale, small-step iterations converge stably can you smoothly scale up to a thousand-card cluster.

    For this reason, engineering practice usually starts with a small-scale environment such as two nodes with 16 cards and runs a few hundred iterations to confirm that the loss curve decreases smoothly and that memory and compute usage are reasonable, before scaling up step by step. The rest of this guide follows that thread.

    2. Environment Setup: From Hardware Abstraction to Software Stack Alignment

    The first task in cross-platform training is getting the software stack working. The defining characteristic of domestic compute is the differentiation of the hardware abstraction layer—drivers, communication libraries, operator libraries, and programming models often differ from the traditional ecosystem and must be aligned from the bottom up.

    A workable setup order looks like this:

    1. Drivers and firmware: confirm that the accelerator card drivers and firmware versions match, and that cards can recognize and interconnect with each other both within a node and across nodes.
    2. Communication library: install and verify a communication library that supports collective operations (AllReduce, AllGather, ReduceScatter, and so on). This is the foundation for multi-card, multi-node coordination.
    3. Compute framework and adaptation layer: choose a deep learning framework that provides adaptation support for your target hardware, and confirm it can correctly invoke the underlying operators.
    4. Dependency pinning: pin exact versions of the Python runtime, CUDA-like toolchain, framework, and its plugins to avoid subtle inconsistencies caused by version drift.

    It helps to confirm the environment is usable with a minimal verification program, for example:

    1. import torch
    2. import torch.distributed as dist
    3. # Initialize the process group to verify multi-card / multi-node communication
    4. dist.init_process_group(backend="nccl") # Replace the backend with your platform's collective communication backend
    5. rank = dist.get_rank()
    6. world_size = dist.get_world_size()
    7. print(f"rank {rank} / {world_size} joined the communication group")
    8. # A single AllReduce self-check to confirm collective communication works
    9. tensor = torch.ones(1).to("cuda") * rank
    10. dist.all_reduce(tensor)
    11. print(f"rank {rank} received the aggregated result: {tensor.item()}")

    This code surfaces basic issues around communication topology, backend selection, and rank assignment at the earliest stage, preventing environment defects from carrying over into later training debugging.

    3. Framework Adaptation and Operator Compatibility: The Core Difficulty

    Getting the framework running is only the beginning; operator compatibility is the most time-consuming part of getting the pipeline working. Large model training relies on a large number of custom or highly optimized operators (such as normalization, attention, and fused optimizer operators). When the target platform’s operator library has incomplete coverage or differing implementations, the following situations can occur:

    • Missing operators: the framework calls an operator that has no corresponding implementation at the lower level, causing an immediate error.
    • Precision differences: the same operator has different numerical implementations on different hardware, causing abnormal fluctuations in the loss curve.
    • Performance degradation: the operator exists but lacks optimization and runs extremely slowly, making training effectively unusable.

    There are usually three strategies for handling these problems:

    • Prioritize the platform’s officially adapted operator library: mature platforms typically provide high-performance implementations for mainstream operators, and you should call these wherever possible.
    • Fall back to composite implementations: when a fused operator is unavailable, replace it with a combination of basic operators, trading some performance for usability.
    • Localize differences layer by layer: compare a single operator’s output against a reference implementation to pinpoint the source of numerical deviation.

    At the same time, enable mixed-precision training (such as BF16/FP16) to reduce memory usage and improve throughput, but pair it with loss scaling and FP32 fallback on critical paths to prevent gradient underflow or numerical overflow under low precision.

    4. Parallel Architecture Design for Dual-Node Multi-Card Training

    In a dual-node, 16-card scenario, how you split the model and data determines the upper limit of training efficiency. Large model training usually combines three parallelism strategies:

    1. Data Parallelism
    Replicate the full model on every card, have each card process a different data shard, and synchronize gradients via AllReduce. It is simple to implement and scales well, but it demands high memory per card and cannot host very large models on its own.

    2. Tensor Parallelism
    Split the weight matrices within a single layer across multiple cards by rows or columns, coordinating through frequent collective communication to complete a forward/backward pass. It significantly reduces per-card memory pressure, but the frequent communication usually restricts it to high-speed interconnect within a single node.

    3. Pipeline Parallelism
    Split the model by layer into multiple stages distributed across different cards, with data passed between stages like an assembly line. It can cross machine boundaries, but you must handle pipeline bubbles, and it is usually combined with micro-batch splitting to improve utilization.

    A typical combination is a hybrid split of “data parallelism + tensor parallelism + pipeline parallelism.” The semantics of an example configuration are as follows:

    1. world_size = 16
    2. tensor_parallel_size = 4 # Tensor parallelism within a node, using high-bandwidth interconnect
    3. pipeline_parallel_size = 2 # Pipeline split across stages
    4. data_parallel_size = world_size / (tensor_parallel_size * pipeline_parallel_size) = 2

    In addition, you need memory optimization techniques, such as optimizer state sharding (splitting optimizer state across cards), activation recomputation (trading compute for memory), and gradient accumulation (simulating a larger batch size when memory is limited). Together, these techniques determine whether the model can fit on a limited number of cards and actually run.

    5. Training Stability and Convergence Verification

    The ultimate criterion for a working pipeline is a smoothly decreasing loss. To judge whether training is truly “running,” watch for the following signals:

    • Loss trend: over several hundred iterations the loss should decrease overall, with small fluctuations allowed, but no sustained divergence or sudden NaN.
    • Gradient norm: an abnormally large gradient norm is often an early sign of numerical instability; you can apply gradient clipping to constrain it.
    • Memory and throughput: monitor whether per-card memory usage leaves headroom and whether per-step time is stable, avoiding occasional OOM caused by memory fragmentation.
    • Learning-rate schedule: be sure to configure learning-rate warmup to avoid loss oscillation in the early stages caused by an overly large learning rate.

    A simplified skeleton of the training loop is shown below:

    1. for step, batch in enumerate(loader):
    2. with autocast(dtype=torch.bfloat16): # Mixed precision
    3. loss = model(batch) / grad_accum_steps # Gradient accumulation
    4. loss.backward()
    5. if (step + 1) % grad_accum_steps == 0:
    6. torch.nn.utils.clip_grad_norm_(model.parameters(), max_norm=1.0) # Gradient clipping
    7. optimizer.step()
    8. optimizer.zero_grad()
    9. if step % log_interval == 0:
    10. log({"loss": loss.item(), "lr": scheduler.get_last_lr()[0],
    11. "grad_norm": compute_grad_norm(model)})

    During the convergence-verification stage, it is advisable to save periodic checkpoints so that, if the loss behaves abnormally, you can quickly roll back to a stable state rather than rerunning from scratch.

    6. Performance Tuning and Troubleshooting Common Issues

    Once the pipeline runs, the next step is usually performance optimization. Common problems and troubleshooting approaches include:

    • Communication becoming the bottleneck: if GPU utilization is low while the network is busy, the workload is stuck on communication. This can be alleviated with gradient bucketing, overlapping communication with computation, and tuning communication library parameters.
    • Excessive pipeline bubbles: increase the number of micro-batches or use a more balanced layer-splitting scheme to improve pipeline parallelism utilization.
    • Insufficient memory: prioritize enabling activation recomputation and optimizer state sharding, then consider increasing the parallelism dimensions or adjusting the micro-batch size.
    • Load imbalance: uneven compute or data distribution across cards drags down the overall pace; check whether data sharding and split strategies are balanced.

    7. Practical Recommendations

    Based on the process above, here are a few reusable engineering recommendations:

    1. Validate step by step, from small to large: go from a single card, to multi-card on one node, to dual-node multi-card, confirming the environment and communication are correct at each level before scaling up.
    2. Pin versions and固化 the environment: package the full software stack with containers to keep the training environment reproducible and portable. General-purpose capabilities such as Baidu AI Cloud’s container platform, object storage, and monitoring and alerting can respectively handle environment orchestration, storage of massive training datasets, and observability of training metrics, helping teams focus on the algorithms themselves.
    3. Put stability before performance: do not rush into tuning before the pipeline is stable; first confirm correct convergence over a few hundred iterations.
    4. Build an observability system: establish a unified monitoring view for loss, gradient norm, memory, and throughput so that problems can be located and traced.

    Summary: Getting the training pipeline running for a large model on a domestic compute platform is essentially a systems-engineering effort—it requires hardware, drivers, communication libraries, the framework, parallelism strategies, and training stability to form a complete closed loop. Using dual-node 16-card, few-hundred-iteration validation as the milestone, and systematically ruling out operator compatibility and communication bottlenecks layer by layer, the ultimate goal is not merely to “get it running” but to “keep it stable and make it scale out.” With this methodology, teams can quickly establish a reliable training baseline across different compute platforms and lay a solid foundation for large-scale model development.