Running LLM Training Across 16 Domestically Made AI Accelerator Cards on Two Nodes

    This guide presents a validation checklist for running large language model training across two nodes with 16 domestically made AI accelerator cards. It covers acceptance criteria for link health, training stability, and recoverability, plus environment consistency checks, parallelism and batch size planning, launch configuration, communication benchmarking, per-step monitoring, troubleshooting, and final validation. The 400-step run serves as an example workflow, and its step and card counts illustrate the process rather than measure any specific hardware or model.

    1. Why Multi-Node Training Pipelines Matter

    The parameter counts and training data volumes of large models keep growing, and the memory and compute of a single machine quickly become bottlenecks. Splitting a training job across multiple machines and accelerator cards is a common industry practice. Moving from a single machine to a stable multi-node setup, however, involves several stages: environment consistency, network interconnection, parallelism strategy, and fault tolerance and recovery. A problem at any stage often stays hidden until training has run for dozens or even hundreds of steps, which makes troubleshooting expensive.

    This guide uses “two nodes, 16 cards, 400 steps of continuous training” as its validation scenario and outlines a reusable method for checking the pipeline. The step and card counts are used only to illustrate the validation process. They do not represent performance metrics for any specific hardware or model.

    2. Define Acceptance Criteria First

    “It runs” is too vague a conclusion. Split acceptance into three levels, each with clear criteria:

    1. Link health: All processes start normally, accelerator cards are detected correctly, and cross-node communication works.
    2. Training stability: Loss decreases over steps overall, no NaN or Inf values appear, and memory usage fluctuates within a reasonable range.
    3. Recoverability: If training is interrupted, it can resume from the latest checkpoint, and the loss curve after resuming continues smoothly from the curve before the interruption.

    The parameters for this validation scenario are summarized below so that the team uses the same reference.

    Item Value
    Number of nodes 2
    Accelerator cards per node 8
    Total accelerator cards 16
    Training steps 400
    Parallelism Tensor parallelism within each node, data parallelism across nodes

    3. Environment Preparation and Consistency Checks

    The most common source of failure in multi-node training is an environment mismatch between machines. A test that passes on a single machine does not guarantee that two machines will work together. During preparation, check the following items:

    • Driver and runtime versions: The drivers, runtime libraries, and base software versions on both machines must match exactly.
    • Container image: Both nodes should use the same image to avoid diverging library versions.
    • Network interconnect: Confirm that the NIC speed and MTU settings match across nodes, and open the communication ports that training requires.
    • Shared storage: Place datasets and checkpoints in a path that both nodes can access, and use the same path string on both.
    • Clock synchronization: Large time offsets between machines make logs hard to align and slow down troubleshooting.

    The following script runs on each node before training starts. It checks the required environment variables and whether the master node’s port is reachable.

    1. import os
    2. import socket
    3. REQUIRED_ENV = ["MASTER_ADDR", "MASTER_PORT", "NODE_RANK", "NUM_NODES", "GPUS_PER_NODE"]
    4. def check_env() -> None:
    5. missing = [key for key in REQUIRED_ENV if key not in os.environ]
    6. if missing:
    7. raise RuntimeError(f"Missing required environment variables: {missing}")
    8. print("Environment variable check passed")
    9. def check_master_reachable(host: str, port: int, timeout: float = 3.0) -> bool:
    10. # Worker nodes fail this port check if the master service has not started yet.
    11. # Run this check after the master node starts.
    12. with socket.create_connection((host, port), timeout=timeout):
    13. return True
    14. if __name__ == "__main__":
    15. check_env()
    16. ok = check_master_reachable(os.environ["MASTER_ADDR"], int(os.environ["MASTER_PORT"]))
    17. print(f"Master node port reachable: {ok}")

    4. Parallelism Strategy and Batch Size Planning

    How the 16 cards are organized directly determines communication overhead and memory utilization. There are three common parallelism methods:

    • Data parallelism: Each card holds a full copy of the model and processes a different slice of the data. Gradient synchronization keeps the copies consistent. Communication volume scales with the number of model parameters, so this method suits cross-node use.
    • Tensor parallelism: The weight matrices of a single layer are split across multiple cards. This requires frequent communication at every step and is sensitive to bandwidth and latency, so it is usually placed within a single node.
    • Pipeline parallelism: The model is split by layers across devices and executed with micro-batch pipelining. This suits models with many layers that do not fit on a single card.

    At the scale of two nodes with 16 cards, a common arrangement is tensor parallelism across the 8 cards within each node and data parallelism between the two nodes. The reasoning is that the interconnect bandwidth inside a node is usually higher than the link between nodes. High-frequency communication stays inside the node, and lower-frequency gradient synchronization crosses nodes.

    The global batch size is calculated as follows:

    1. def global_batch_size(micro_batch: int, grad_accum_steps: int, data_parallel_size: int) -> int:
    2. # Global batch size = per-card micro batch size × gradient accumulation steps × number of data-parallel groups
    3. return micro_batch * grad_accum_steps * data_parallel_size
    4. # Example: tensor parallel size 8 within each node, data parallel size 2
    5. print(global_batch_size(micro_batch=2, grad_accum_steps=8, data_parallel_size=2)) # Output: 32

    Changing the batch size affects convergence speed and the shape of the loss curve. Fix the batch size and record it in the configuration before the formal 400-step run.

    5. Launch Configuration and Process Management

    Every node must be launched with the same training script and hyperparameters, and with its own node rank. Manage environment variables centrally in the launch script, and make it exit immediately on error. This prevents a process from hanging unnoticed while the rest of the job continues.

    1. #!/usr/bin/env bash
    2. set -euo pipefail
    3. # Parameters shared by all nodes
    4. export NUM_NODES=2
    5. export GPUS_PER_NODE=8
    6. export MASTER_ADDR="${MASTER_ADDR:?Set the master node address}"
    7. export MASTER_PORT=29500
    8. # Each node sets its own rank. The master node uses rank 0.
    9. export NODE_RANK="${NODE_RANK:?Set the node rank}"
    10. # Example arguments. Follow the argument definitions in your training script.
    11. python train.py \
    12. --num-nodes "${NUM_NODES}" \
    13. --gpus-per-node "${GPUS_PER_NODE}" \
    14. --max-steps 400 \
    15. --checkpoint-dir /shared/ckpt/run-001 \
    16. --save-interval 100

    Process management has three key points. First, write logs to disk separately for each node and process so that problems can be traced later. Second, after a training process exits, check for leftover processes that still hold accelerator cards. Otherwise, the next launch can fail with out-of-memory errors. Third, record a hash of the configuration file at each launch to confirm that a reproduction uses the same configuration.

    Before formal training, run a short communication test. Test a single node first, then cross-node links, and compare the measured bandwidth against the expected values for each segment. If cross-node bandwidth is clearly low, the cause is usually NIC selection, MTU settings, or link topology, not the training code itself.

    1. # Pseudocode: cross-node collective communication bandwidth test
    2. def benchmark_allreduce(tensor_size_mb: int, warmup: int = 5, iters: int = 20) -> float:
    3. tensor = allocate_tensor(size_mb=tensor_size_mb)
    4. for _ in range(warmup):
    5. all_reduce(tensor)
    6. sync_device()
    7. start = now()
    8. for _ in range(iters):
    9. all_reduce(tensor)
    10. sync_device()
    11. elapsed = now() - start
    12. # Estimate effective bandwidth from the data volume that all-reduce moves
    13. bytes_moved = tensor_size_mb * 2 * 1024 * 1024 * iters
    14. return bytes_moved / elapsed / 1e9 # Unit: GB/s

    Test several data sizes. Latency dominates with small payloads, and bandwidth dominates with large ones. Record both metrics to locate the bottleneck.

    7. Training Stability Monitoring

    A 400-step run is short, but it is long enough to expose numerical stability problems. Check the following metrics at every step:

    • Loss validity: If the loss becomes NaN or Inf, stop immediately and save the current state for analysis.
    • Gradient norm: A sudden rise in the gradient norm usually means the learning rate is too high or the data contains anomalous samples.
    • Memory usage: Memory that keeps climbing may indicate tensors that are not being released.
    • Throughput: If the per-step time fluctuates beyond the normal range, check whether data loading or communication is blocking.
    1. import math
    2. def check_step(step: int, loss: float, grad_norm: float, max_grad_norm: float = 10.0) -> None:
    3. if math.isnan(loss) or math.isinf(loss):
    4. raise RuntimeError(f"Abnormal loss at step {step}: {loss}")
    5. if grad_norm > max_grad_norm:
    6. # Warn without stopping so trends can be observed.
    7. # The training configuration decides whether to clip gradients.
    8. print(f"[WARN] Large gradient norm at step {step}: {grad_norm:.3f}")

    The checkpoint interval balances two factors. A long interval means more training steps are lost after a failure. A short interval increases the overhead of disk writes and training pauses. For a 400-step validation run, saving every 100 steps is a reasonable choice.

    8. Common Issues and Troubleshooting

    Symptom Likely cause Where to look
    No output for a long time after launch Wrong master address, or the port is blocked by a firewall Check the address and port connectivity one by one
    Single node works, two nodes fail Driver or image version mismatch Compare version information across both nodes
    Cross-node bandwidth far below single-node bandwidth NIC not using the intended high-speed link, or MTU mismatch Test each segment, and check NIC and routing configuration
    Loss becomes NaN after a certain step Learning rate too high, or numerical overflow under mixed precision Lower the learning rate and check gradient scaling settings
    Loss jumps noticeably after resuming Optimizer state not restored, or data read position wrong Verify the checkpoint contents and the data sampler state
    Out-of-memory error on restart after an exit Leftover processes still hold accelerator cards Terminate old processes and confirm the devices are idle before launching

    When troubleshooting, narrow the scope layer by layer: environment, network, configuration, and then code. First confirm that both machines have identical environments, then verify the network, and only then suspect the training code. This order avoids spending time on the wrong layer.

    9. Acceptance and Review

    After the 400-step run finishes, confirm each of the three levels defined in Section 2:

    1. Link health: All processes exit normally, and the logs contain no communication timeouts or device errors.
    2. Training stability: The loss curve trends downward overall, no numerical anomalies appear, and throughput and memory usage remain stable.
    3. Recoverability: Interrupt training manually around step 200, then resume from the most recent checkpoint.