Large Language Model Training on Domestic AI Accelerators: A Practical Walkthrough

    This article documents a practical run of a large language model training pipeline on a domestic AI accelerator stack, using two nodes with sixteen cards in total and 400 stable iterations. It explains what "getting the pipeline working" actually means, breaks the training path into seven layers, and details the parallel strategy, memory and numerical stability settings, communication and scheduling tuning, observability, and checkpoint-resume requirements. Engineers will find a troubleshooting checklist and a methodology for validating the full loop before scaling up.

    1. Background and Why This Matters

    A notable recent milestone: a software and hardware stack built on domestic AI accelerators ran a full training pipeline for a large-parameter language model at a scale of two nodes and sixteen cards, advancing 400 iterations without interruption.

    “Getting it working” is not the same as “running fast.” Here it carries three meanings:

    • Training scripts start without invasive, hardware-specific changes.
    • The forward pass, backward pass, parameter update, and checkpoint saving form a closed loop.
    • Across 400 consecutive steps, there are no numerical anomalies, communication interruptions, or out-of-memory failures.

    For developers and enterprise users, the real value of this kind of validation is turning “can it be used” into “how do we use it well.” The engineering difficulty of large model training has never been peak single-card compute; it is stability, linearity, and operability across thousands of iterations. Four hundred steps is a reasonable observation window: long enough to surface hidden problems in initialization, the data pipeline, communication topology, and optimizer state updates, without consuming excessive resources.

    2. Seven Key Layers of a Training Pipeline

    A complete training pipeline can be abstracted into seven layers. A mismatch in any one of them leads to task failure or an efficiency collapse.

    1. Hardware and driver layer: accelerators, hosts, NICs, and topology detection.
    2. Runtime and operator layer: compute libraries, communication libraries, operator coverage, and precision support.
    3. Framework and parallelism layer: combinations of data, tensor, and pipeline parallelism.
    4. Data pipeline layer: sampling, tokenization, packing, prefetching, and caching.
    5. Numerics and memory layer: mixed precision, recomputation, and optimizer state sharding.
    6. Communication and scheduling layer: collective communication algorithms, topology awareness, and job orchestration.
    7. Observability and fault tolerance layer: metrics collection, log aggregation, alerting, and resume-from-checkpoint.

    3. Parallel Strategy for Two Nodes and Sixteen Cards

    The core tension in small-scale multi-node training is that there are not many cards, but cross-node communication accounts for a high share of the total. Pure data parallelism alone makes gradient synchronization grow linearly with parameter count, and cross-node bandwidth quickly becomes the bottleneck. A more robust approach is layered parallelism:

    1. # Illustration: map parallel dimensions to "high bandwidth inside a node, low bandwidth across nodes"
    2. parallel_config = {
    3. "tensor_parallel_size": 4, # Split inside a node first, using the high-bandwidth interconnect
    4. "pipeline_parallel_size": 2, # Split layers across nodes to reduce synchronization frequency
    5. "data_parallel_size": 2, # Fill the remaining dimension with data parallelism
    6. "micro_batch_size": 1,
    7. "gradient_accumulation": 16,
    8. }

    The principle is to keep tensor parallelism, which is the most communication-intensive, inside the node; place pipeline parallelism, which synchronizes less often, across nodes; and fill the data parallel dimension last. The global batch size is determined by “micro batch size x gradient accumulation x data parallel size.” When you change it, scale the learning rate and warmup steps accordingly, so that loss jitter is not mistaken for a pipeline failure.

    4. Memory Budget and Numerical Stability

    Estimate the memory budget across five separate items: parameters, gradients, optimizer states, activations, and temporary buffers. Common techniques include mixed-precision compute with a master weight copy, activation recomputation, optimizer state sharding, and offloading part of the state to host memory. Note that recomputation trades roughly 30% extra compute for memory headroom, so enable it only when memory is genuinely tight.

    For numerical stability, use dynamic loss scaling and apply global gradient norm clipping:

    1. for step, batch in enumerate(dataloader):
    2. with autocast(dtype="bfloat16"):
    3. loss = model(batch).loss / grad_accum
    4. loss.backward()
    5. grad_norm = clip_grad_norm_(model.parameters(), max_norm=1.0)
    6. optimizer.step(); optimizer.zero_grad(set_to_none=True)
    7. if step % 50 == 0:
    8. log({"step": step, "loss": loss.item(), "grad_norm": grad_norm})

    If grad_norm keeps climbing or loss turns into NaN, first check for abnormal data samples, an excessive learning rate, and a precision mode mismatch, rather than rushing to swap hardware.

    5. Communication and Scheduling Tuning

    Cross-node efficiency depends heavily on topology awareness. Four practices matter: bind NICs to compute devices by affinity; set sensible timeouts and retries for collectives; bucket gradients to merge small messages; and align the pipeline schedule so computation and communication time slices overlap. At the orchestration level, deploy training processes separately from monitoring and log collection processes to avoid resource contention that causes jitter.

    6. Observability and Resume-from-Checkpoint

    400 consecutive steps require a working observability setup. The minimum useful set: log throughput, memory usage, gradient norm, and learning rate every few steps; keep the full stack trace and an environment snapshot for failed tasks; write checkpoints at fixed step intervals and retain the most recent few. Resuming from a checkpoint must restore model weights, optimizer state, random number state, and the data sampling position at the same time; otherwise the curve shifts in ways that are hard to explain after recovery. These artifacts can live in object storage, forming a closed loop together with a log service and monitoring alerts.

    7. Troubleshooting Checklist

    • Fails immediately at startup: usually insufficient operator coverage or an unsupported precision mode; reproduce at a smaller scale first.
    • Throughput stays low: check whether the data pipeline is the bottleneck, and increase prefetching and caching.
    • Out of memory: lower the micro batch size and sequence length first, then consider recomputation and offloading.
    • Abnormal curves: verify that the global batch size and learning rate still match after a change in parallel degrees.
    • Random task interruptions: look at communication timeouts, node health, and resource oversubscription.

    8. Conclusion

    Running 400 steps on two nodes and sixteen cards validates the integrity of the pipeline rather than its performance ceiling. What is worth capturing for an engineering team is the methodology: validate the closed loop in small steps, then scale up gradually; identify the type of bottleneck before choosing an optimization; and establish observability and fault tolerance before chasing throughput numbers. Baidu AI Cloud’s combination of general capabilities, including its container platform, object storage, log service, and monitoring and alerting, can provide standardized infrastructure support for this kind of training validation, letting teams focus on parallel strategy and the model itself.