Connecting and Tuning the LLM Training Pipeline on Domestic AI Accelerators

    This article explains why getting a large language model training pipeline to run reliably is harder than simply adding more accelerator cards, using a "dual-node, 16-card, 400-step" run as a practical validation scenario. It breaks down the core layers of the training pipeline, the key challenges of adapting it to domestic AI accelerators (operator coverage, numerical consistency, communication library fit, mixed precision, and memory management), and how to partition parallelism across two machines. It also lays out a step-based validation methodology, a troubleshooting checklist keyed to log fields, general performance tuning techniques such as overlapping communication with computation, and a phased rollout strategy for deploying training in enterprise environments. It closes with three practical checklists covering environment, configuration, and validation.

    Introduction: Why “Getting It Running” Is Harder Than “Adding Cards”

    In large model distributed training, the difficulty often lies not in single-card compute power, but in whether the entire training pipeline can be brought up and kept stable. The “pipeline” here refers to the full closed loop: data loading, forward computation, backpropagation, gradient reduction, parameter updates, and checkpoint saving. A problem in any single stage — a missing operator, a communication fault, numerical overflow, insufficient device memory, or a storage failure — can halt training, prevent the loss from converging, or produce corrupted results.

    Taking “running 400 steps across 2 nodes with 16 cards” as a validation scenario is not simply about launching a training job once. It is an end-to-end health check of the underlying hardware and software working together. Common failure classes fall into three groups:

    • Inconsistent configuration among global batch size, data parallel degree, micro-batch size, and gradient accumulation steps.
    • Mismatched driver, framework, and communication library versions, leading to collective communication deadlocks or sudden drops in bandwidth.
    • Non-atomic checkpoint saving, abnormal storage permissions, or weak object storage consistency, causing resume-from-checkpoint to fail.

    1. Core Components of the LLM Training Pipeline

    To understand why bringing the pipeline up is difficult, start by decomposing it. Frameworks may name these parts differently, but the core layers are largely the same:

    Layer Key components Typical failure symptom Validation method
    Training framework Graph construction, auto-differentiation, optimizer, distributed scheduling Dependency conflicts, backend not registered, optimizer state anomalies Check the version manifest, run a minimal training script
    Parallel strategy Data, tensor, pipeline, and expert parallelism Parallel degree inconsistent with batch size, out-of-bounds sharding Verify the relationship between global batch and parallel degree with a formula
    Communication library All-reduce, all-gather, reduce-scatter, and other collectives Communication timeouts, deadlocks, sudden bandwidth drops Run a collective communication benchmark and inspect logs
    Operators and acceleration libraries Attention, normalization, matrix multiplication, fused operators Missing operators, inconsistent precision, performance regression Align single-operator input/output and compare against a reference implementation
    Storage and data Data loading, preprocessing, checkpoint read/write Too few samples, read stalls, corrupted checkpoints Verify resume-from-checkpoint, file checksums, and storage permissions

    In the general-purpose GPU ecosystem, these layers are usually highly mature. In the domestic AI accelerator ecosystem, each layer may require re-adaptation and re-validation. The value of bringing the pipeline up lies in turning “it seems to start” into “verifiable, reproducible, and able to run over the long term.”

    2. Key Challenges in Bringing Up the Pipeline on Domestic AI Accelerators

    Domestic accelerators may differ from the mainstream ecosystem in architecture, instruction set, and software stack. Before adapting, establish verifiable prerequisites: OS version, driver version, firmware version, runtime version, deep learning framework version, operator library version, communication library version, network topology, container image digest, and dependency manifest. Change one variable at a time so that problems remain traceable, and avoid stacking multiple versions at once.

    1. Operator coverage and numerical consistency. Large models rely on many custom fused operators. If an operator is not yet implemented, or its precision path diverges from the reference implementation, the result ranges from a runtime error to a loss that fails to converge. To validate: use identical inputs and the same random seed to compare the reference implementation against the domestic-card implementation; set relative-error and absolute-error thresholds for key operators; and focus on matrix multiplication, normalization, attention, activation functions, and the gradient backpropagation path. As a practical first step, keep the maximum relative error of key operators between 1e-3 and 1e-2, then use a secondary check of whether the final loss curve is smooth.

    2. Communication library adaptation. Multi-card training depends on collective communication primitives such as all-reduce, all-gather, and reduce-scatter. Cross-node scenarios also require high-speed interconnect networks. If the communication library does not align with the accelerator’s memory management, stream scheduling, and event synchronization, deadlocks, timeouts, or sudden bandwidth drops are likely. When validating, check the communication library version, topology detection, NIC binding, timeout thresholds, and environment variable configuration, then run a collective communication stress test with a small model.

    3. Mixed precision support. Training commonly uses low-precision compute with high-precision master weights. The availability of formats such as half precision and bfloat16, the loss scaling strategy, and gradient overflow handling all need to be re-validated on new hardware. Start with a short mixed-precision run and observe whether the loss scaling factor, overflow count, and gradient norm match the reference implementation. If the loss jumps, check overflow handling, normalization numerical stability, and learning rate configuration first.

    4. Memory and operator memory management. Large models are extremely sensitive to memory usage. Since the accelerator’s memory bandwidth and allocator behavior differ from mainstream devices, mechanisms such as activation recomputation, optimizer state sharding, and offloading cold data need to be re-tuned. When validating, record peak memory, allocation counts, fragmentation rate, and per-step memory growth, and avoid reusing configuration values from other hardware based on experience alone.

    3. Distributed Parallel Partitioning for Dual-Node 16-Card Setups

    “Dual-node, 16-card” typically means two machines with 8 cards each, connected by a high-speed network. How you partition parallelism directly determines whether the pipeline runs, and it also affects the room available for later tuning.

    Here is a framework-agnostic example configuration:

    1. parallel:
    2. data_parallel_size: 2 # Data parallel degree: replicate the model, split the batch
    3. tensor_parallel_size: 8 # Tensor parallel degree: shard each layer's matrices, often aligned to per-node card count
    4. pipeline_parallel_size: 1 # Pipeline parallel degree: split into stages by layer
    5. expert_parallel_size: 1 # Expert parallel degree: enabled for mixture-of-experts models
    6. training:
    7. global_batch_size: 1024 # Global batch size
    8. micro_batch_size: 8 # Per-card micro-batch size
    9. gradient_accumulation_steps: 64 # Gradient accumulation steps
    10. precision: "bf16" # Mixed precision
    11. activation_checkpointing: true # Activation recomputation: trade compute for memory

    One key formula must be emphasized here. Unless special partitioning such as sequence parallelism or expert parallelism is enabled, the global batch size usually satisfies:

    1. global_batch_size = data_parallel_size × micro_batch_size × gradient_accumulation_steps

    In the configuration above, the data parallel degree is 2, the per-card micro-batch is 8, and the gradient accumulation steps are 64, so:

    1. 2 × 8 × 64 = 1024

    The global batch size is 1024, and the configuration is self-consistent.

    If memory is constrained, you can keep the global batch size at 1024 while shrinking the micro-batch and increasing the gradient accumulation steps, for example:

    1. micro_batch_size: 1
    2. gradient_accumulation_steps: 512
    3. data_parallel_size: 2
    4. global_batch_size: 1024

    In this case:

    1. 2 × 1 × 512 = 1024

    As a counterexample: if you configure a data parallel degree of 2, a micro-batch of 1, and 64 gradient accumulation steps, then the global batch size should be 128, not 1024. Writing 1024 here would distort batch statistics, learning rate scaling, logging, and experiment comparisons.

    Three principles guide parallel design. First, place tensor parallelism within a node, because its communication is frequent and highly bandwidth-hungry, and intra-node interconnect is typically faster than cross-node links. Second, spread data parallelism across nodes so that gradient reduction, which carries relatively less communication pressure, travels over the cross-node link. Third, use gradient accumulation to enlarge the effective batch, trading time for space when memory is limited.

    Note that setting the tensor parallel degree to 8 to match the per-node card count is a typical and safe choice, but it assumes the intra-node interconnect topology is good enough and that the relevant operators support this kind of sharding. If the intra-node interconnect is a bottleneck, or some operators do not support sharding, lower the tensor parallel degree and switch to pipeline parallelism or another strategy rather than copying the configuration mechanically.

    4. The Methodological Value of a 400-Step Run

    Why run the full step count instead of just launching one forward pass? Because different problems surface at different stages:

    • First few steps: validate the data pipeline, operator correctness, and whether the initial loss sits in a reasonable range.
    • Dozens of steps: validate that gradient reduction is correct, that the loss trends downward overall, and whether numerical overflow appears.
    • Hundreds of steps: validate long-running stability, exposing cumulative issues such as memory leaks, communication timeouts, and checkpoint read/write anomalies.

    For this reason, running 400 steps is a reasonable “health-check window.” It is long enough to cover a fairly complete training iteration cycle, without consuming excessive resources. The acceptance criteria usually include three points: the loss curve decreases smoothly; throughput is roughly consistent across all cards; and the entire run proceeds without interruption or abnormal alerts. Only when all three are satisfied can you conclude the pipeline is truly connected, rather than having run a few steps by luck.

    At minimum, the logs should record the following fields:

    1. step, rank, loss, learning_rate, grad_norm,
    2. tokens_per_second, samples_per_second, iteration_time,
    3. communication_time, memory_allocated, memory_peak,
    4. overflow_count, checkpoint_time, checkpoint_path

    The following is a common troubleshooting checklist:

    Symptom Key log fields Checks Actions
    Out of memory (OOM) memory_peak, memory_allocated, step Is the micro-batch too large, the sequence too long, or activation recomputation off? Lower micro_batch_size, enable activation recomputation, shard optimizer state
    Communication timeout or deadlock communication_time, rank, timeout Cross-node network, topology detection, communication library version, timeout config Re-test collective communication, check environment variables, adjust timeout and inspect the link
    Loss not decreasing or diverging loss, grad_norm, overflow_count Learning rate, gradient clipping, data labels, numerical precision Reduce the learning rate, disable the abnormal optimizer, compare against the reference implementation
    Memory leak memory_allocated growing with step Unreleased tensors, cache accumulation, checkpoint buildup Compare memory curves at fixed step intervals, use memory profiling tools
    Corrupted checkpoint checkpoint_time, storage_error, fs_error Storage space, permissions, atomic writes, object storage consistency Add checksums, retry on failure, enable multiple replicas or version management

    Below is a sample checkpoint-saving logic that is convenient for log analysis and resume-from-checkpoint:

    1. for step in range(total_steps):
    2. loss = train_one_step(step)
    3. if step % log_interval == 0:
    4. log_metrics(
    5. step=step,
    6. loss=loss,
    7. lr=get_lr(step),
    8. throughput=tokens_per_sec,
    9. grad_norm=grad_norm,
    10. mem_peak=mem_peak,
    11. )
    12. if step % save_interval == 0:
    13. save_checkpoint(
    14. step,
    15. atomic=True,
    16. verify=True,
    17. )

    Here, atomic=True means writing to a temporary file first and then atomically replacing the official file once the write is confirmed complete; verify=True means running a basic integrity check after saving, to avoid a checkpoint that appears to succeed but is actually corrupted.

    5. A General Approach to Performance Tuning

    Getting the pipeline running is only the starting point; running it stably and fast is the goal. Before tuning, establish a baseline covering throughput, memory, communication time, operator time, and per-step time. Measure under the same inputs, the same parallel configuration, and the same precision mode, and keep a rollback plan so that a single change does not become impossible to attribute.

    1. Overlapping communication with computation. Hiding gradient reduction under the backward computation is a core technique for improving multi-card utilization. The general approach is to skip synchronization for the first several micro-batches and trigger reduction only once at the end of the accumulation cycle, so it overlaps with the forward and backward computation.

    Note in particular that the no_sync condition should be decided by taking the modulo against the gradient accumulation cycle, not simply written as a fixed prefix:

    1. for i, micro_batch in enumerate(data_loader):
    2. # Skip synchronization only when the current micro-batch is not the last one in the accumulation cycle
    3. if (i + 1) % accum_steps != 0:
    4. ctx = no_sync()
    5. else:
    6. ctx = nullcontext()
    7. with ctx:
    8. loss = model(micro_batch)
    9. loss.backward()
    10. if (i + 1) % accum_steps == 0:
    11. # If the framework requires explicit gradient synchronization, call it here
    12. # finalize_grad_sync()
    13. optimizer.step()
    14. optimizer.zero_grad()

    This approach depends on several conditions: the framework must support no_sync or an equivalent mechanism; the communication library must support asynchronous collective communication or multi-stream scheduling; the bucket size must be reasonable — too large increases per-communication latency, too small increases scheduling overhead; the communication stream and compute stream must be able to run concurrently; and the framework, driver, and communication library versions must be stable and consistent. If the operator layer contains many implicit synchronization points, the benefit of overlapping communication with computation drops noticeably, and you should optimize the operators or the scheduling path first.

    2. Memory optimization. Techniques such as activation recomputation, optimizer state sharding, and offloading cold data to host memory can support larger batches or longer sequences within limited memory. The cost is extra compute or transfer overhead, so throughput must be weighed. During tuning, focus on peak memory, per-step time, and memory fragmentation rate, and avoid chasing large batches at the expense of a significant throughput drop.

    3. Operator and scheduling optimization. Use fused operators to reduce kernel launch overhead, set a reasonable number of compute streams to raise device utilization, and re-measure baseline data for the accelerator’s characteristics. Do not reuse empirical parameters from other hardware directly, because operator implementations, memory hierarchies, and communication paths differ substantially across hardware.

    6. Recommendations for Enterprise Deployment

    For enterprises that want to deploy large model training on heterogeneous compute, follow a path of “layered validation, progressive scale-up”: first confirm operator correctness and numerical stability on a single card, then validate intra-node parallelism and communication on a single machine with multiple cards, and finally validate cross-node communication, checkpoints, and overall stability. Each step should have clear acceptance criteria, a log baseline, and a rollback plan.

    At the infrastructure level, you can use a general-purpose container platform to deliver reproducible training environments, use object storage to hold datasets, code packages, and checkpoints, and use monitoring and alerting services to track throughput, memory, communication status, and storage errors in real time. The general capabilities offered by cloud or container platforms help teams focus on models, algorithms, and training strategies rather than low-level operations.

    Pay special attention to checkpoint storage, permissions, data recovery, and risk warnings. Configure least-privilege access for checkpoints, and avoid giving training jobs excessive delete permissions; enable multiple replicas, version management, or off-site backup for important checkpoints; and periodically rehearse restoring training from a checkpoint to verify that the loss curve, optimizer state, and random number state remain consistent after recovery. At the same time, monitor storage capacity, object storage error codes, filesystem alerts, and permission-change events to prevent loss of training results from corrupted or accidentally deleted checkpoints.

    Conclusion

    “Running 400 steps across 2 nodes with 16 cards” may look like just a specific number, but behind it lies a complete engineering methodology: understanding the pipeline’s composition, identifying adaptation challenges, partitioning parallelism sensibly, designing validation scientifically, and tuning performance continuously. Readers can refer directly to the three checklists below:

    1. Environment checklist: are the driver, framework, operator library, communication library, network topology, and container image versions consistent and traceable?
    2. Configuration checklist: does the global batch size satisfy the product relationship among parallel degree, micro-batch, and gradient accumulation steps, and is there a counterexample check?
    3. Validation checklist: have you completed the 400-step long run, recorded throughput, memory, communication, and loss curves, and ensured the ability to recover from checkpoints and troubleshoot?

    With this method in hand, no matter what hardware provides the compute, teams can systematically advance large model training deployment and turn the “it runs” milestone into stable, efficient, and repeatable production capability.