Making Large Model Training Work on Domestic AI Accelerators: A Practical Guide

    This article walks through the engineering practice of running a complete large model training pipeline on domestic AI accelerators, using a two-node, sixteen-card setup trained for 400 steps. It covers pre-flight environment checks across the driver, communication, framework, and data layers, how to choose a parallel strategy under memory and communication constraints, overlapping communication with computation, and the observability and checkpointing needed for stability beyond the first few hundred steps. Readers will find a reusable deployment checklist and a fault-diagnosis table for common failures.

    1. Why Getting the Training Pipeline Working Matters More Than Benchmarks

    In the domestic AI accelerator ecosystem, single-card compute figures are only the starting point. What actually decides whether a deployment succeeds is whether a complete large model training pipeline can run stably end to end. The training pipeline here means the full closed loop: data loading, model construction, forward and backward computation, gradient synchronization, optimizer updates, checkpoint saving, and metric reporting. A two-node, sixteen-card run of 400 steps is not large, but it is enough to expose most engineering problems: device discovery failures, mismatched communication library versions, operator precision drift, memory fragmentation, and uneven data supply. Completing 400 steps means the pipeline is sustainable under a real workload, not a one-off demo.

    2. Environment Preparation: Move Uncertainty Forward

    The first principle of training on domestic hardware is to eliminate uncertainty before launch. Prepare in four layers:

    1. Driver and runtime layer: confirm that the accelerator driver, runtime, and container image versions form a matched combination, and avoid mixed installations from unverified sources.
    2. Communication layer: confirm that both intra-node and inter-node interconnect topologies are correctly detected, and that link bandwidth and latency meet expectations. Where necessary, record a baseline using standard bandwidth and latency test tooling.
    3. Framework layer: prefer a training framework version with mature hardware support, pin dependency versions, and generate a reproducible environment manifest.
    4. Data layer: convert data into a unified sharded format and pre-generate indexes and checksums so that corrupted data does not interrupt training midway.

    Illustrative pre-launch self-check logic:

    1. def preflight_check(world_size, expected_gpus_per_node):
    2. assert world_size % expected_gpus_per_node == 0, "Node and card count do not match"
    3. assert visible_device_count() == expected_gpus_per_node, "Device visibility anomaly"
    4. assert collective_allreduce_smoke_test(), "Collective communication self-check failed"
    5. return True

    3. Parallel Strategy: A Sensible Split Across Two Nodes and Sixteen Cards

    At sixteen cards, the common combination is data parallelism stacked with tensor parallelism or pipeline parallelism. Three factors drive the choice: model parameter count and activation memory footprint, communication overhead share, and implementation complexity. If the model fits on a single card, pure data parallelism is the simplest option. If it does not, prefer tensor parallelism to split the computation of individual layers first, then scale throughput with data parallelism. Parallelism is not better the larger it gets: inter-node communication costs can quickly consume the gains, so reserve the inter-node links for dimensions with lower communication volume.

    A practical decision sequence:

    • Can a single card hold the parameters, gradients, and optimizer states with three times the redundancy?
    • Is peak forward and backward memory below the safe watermark?
    • Does the estimated communication volume make inter-node bandwidth the bottleneck?
    • If the bottleneck is inside the node, increase intra-node parallelism; if it is between nodes, reduce the frequency of cross-node synchronization.

    4. Overlapping Communication and Computation: Hide the Waiting Time

    The core of performance tuning is not making a single computation faster, but hiding communication behind computation. Techniques include gradient bucketing, triggering synchronization per bucket during the backward pass, and running computation and transfer on multiple parallel streams. Note also that gradient accumulation changes the effective batch size and learning rate calibration, so the scheduling strategy must be adjusted accordingly. Illustrative configuration:

    1. config = {
    2. "bucket_size_mb": 128,
    3. "overlap_grad_reduce": True,
    4. "gradient_accumulation_steps": 4,
    5. "mixed_precision": "bf16",
    6. "activation_checkpointing": True,
    7. }

    Mixed precision significantly reduces memory and bandwidth pressure, but you must keep a master copy of the weights and enable loss scaling or use a format with a friendlier numerical range, to avoid silent precision collapse.

    5. Stability and Observability: What Comes After 400 Steps

    The real test of a training pipeline comes hundreds of steps in. Track three categories of metrics: throughput (time per step, samples per second), resources (peak memory, interconnect utilization), and correctness (loss curve smoothness, gradient norm, magnitude of parameter updates). A sudden change in any category should trigger an alert. For checkpointing, use asynchronous saving with rolling retention so that after a failure you can resume from the most recent valid point instead of starting from zero.

    Common failures and how to locate them:

    Symptom Possible cause Diagnostic approach
    Hangs at startup Collective communication initialization failure Check device visibility and run the communication self-check
    Step time jitter Data supply bottleneck Watch the data loading queue depth
    Loss spikes Precision or learning rate issue Review gradient norm and loss scaling
    Out of memory Fragmentation or underestimated peak Record the peak and adjust sharding and recomputation

    6. A Reusable Deployment Checklist

    Consolidate the above into a checklist: pin and archive version combinations; complete communication and device self-checks before launch; validate with a small number of steps before a long stability run; derive the parallel strategy from both memory and communication constraints; enable computation-communication overlap and mixed precision; build dashboards for throughput, resources, and correctness; make checkpointing asynchronous and rehearse recovery regularly. Following this path, a large model training pipeline on domestic AI accelerators can move from “it starts” to “it is deliverable,” and the same approach carries over to general-purpose compute and containerized environments such as those offered by Baidu AI Cloud.