Getting Large Model Training Working on a Domestic AI Compute Platform: A Practical Walkthrough

    This article explains why closing the training loop matters more than peak throughput when running large model training on a domestic compute platform. Using a two-node, 16-GPU, 400-step run as a small-scale validation scenario, it covers environment preparation, parallelism strategy, stability practices, and how to interpret the results into a reusable baseline. Readers will find a sample launch configuration, pseudocode for gradient accumulation, and practical checks for operators, communication topology, memory, and checkpoint recovery.

    1. Why Closing the Loop Matters More Than Raw Speed

    In large-scale model training, teams often focus on peak throughput. In practice, project timelines are usually determined by whether the training loop can close reliably. A closed loop means every stage runs on the target hardware with little or no modification: data loading, tokenization and packing, forward pass, backpropagation, gradient synchronization, optimizer update, checkpoint saving, and resuming from a checkpoint. Performance tuning only becomes meaningful once the loop is working end to end.

    Completing 400 training steps on a two-node, 16-GPU setup is a typical small-scale validation scenario. Its value is not producing a usable model, but verifying three things: whether operator coverage is complete, whether the communication topology is efficient, and whether long-running stability is under control. Four hundred steps are enough to surface most configuration errors, out-of-memory issues, and numerical anomalies, while keeping the cost of trial and error acceptable.

    2. Environment Preparation: Move Uncertainty Earlier

    Most loop failures are not algorithm problems but environment differences. Before starting real training, work through this checklist:

    • Align driver, runtime, and communication library versions so both machines are exactly identical;
    • Confirm that inter-GPU interconnect and network interface bandwidth meet expectations, avoiding automatic fallback to a slower channel;
    • Fix random seeds and data ordering so issues are reproducible;
    • Run one complete pass with a tiny model first to validate storage I/O and log collection.

    A sample launch configuration follows (illustrative structure only, not a specific platform interface):

    1. # processes per node × number of nodes = global process count
    2. export GLOBAL_WORLD_SIZE=16
    3. export NODE_RANK=0 # set to 1 on the second machine
    4. export MASTER_ADDR=<master node address>
    5. export MASTER_PORT=29500
    6. python train.py \
    7. --global-batch-size 512 \
    8. --micro-batch-size 4 \
    9. --seq-len 4096 \
    10. --lr 1e-5 \
    11. --max-steps 400 \
    12. --ckpt-interval 50

    3. Parallelism Strategy: Balancing Memory and Communication

    At 16 GPUs, a common combination is data parallelism plus tensor parallelism, with pipeline parallelism added when necessary. The choice is not “more parallelism is better,” but the intersection of three constraints: whether a single GPU can hold the parameters, gradients, and optimizer states; whether the communication volume exceeds what the interconnect bandwidth can carry; and whether pipeline bubbles are amortized by enough micro-batches.

    A practical order of decisions: estimate memory first, then set the parallelism degree, and finally tune micro-batch size. Mixed precision, gradient accumulation, and activation recomputation are three low-cost ways to trade compute for memory. Activation recomputation, for example, trades roughly 30% extra computation for lower memory usage, which suits deep models with long sequences.

    1. # Pseudocode: skeleton of parallel partitioning and gradient accumulation
    2. for step in range(max_steps):
    3. for micro in range(grad_accum_steps):
    4. loss = model(batch(micro)) / grad_accum_steps
    5. loss.backward() # backprop; may trigger activation recomputation
    6. optimizer.step() # update once after gradient synchronization
    7. optimizer.zero_grad()
    8. if step % ckpt_interval == 0:
    9. save_checkpoint(step) # write asynchronously to avoid blocking training

    4. Stability: Finishing 400 Steps in One Run

    Long-running stability depends on observability. Collect three categories of metrics at the same time: throughput and per-step time, memory and temperature, and the share of time spent waiting on communication. If per-step time fluctuates while compute volume stays constant, the cause is usually communication or storage contention. If memory usage climbs slowly, it is often cache fragmentation or checkpoints that have not been released.

    For checkpoints, use periodic full saves with rolling retention, and verify at least one recovery from a checkpoint to confirm that optimizer state and data position are consistent. On abnormal exit, process supervision and automatic restart can reduce manual intervention to minutes.

    5. Interpreting Results and Next Steps

    Once 400 steps complete, produce a reusable baseline report: per-GPU memory usage, global throughput, parallelism configuration, and a list of failure points. This baseline becomes the reference for scaling to more nodes and longer sequences. On platforms such as Baidu AI Cloud, engineering teams typically combine general capabilities like container platforms, object storage, and monitoring alerts to link training jobs, data, and metrics into a sustainable iteration workflow. Once the loop is stable, model quality tuning and compute scaling have a reliable foundation.