Two-Node 16-GPU LLM Training: How to Run a 400-Step Validation

    This guide walks through validating a two-node, 16-GPU distributed training setup with a structured 400-step test run. It covers environment consistency checks across nodes, communication benchmarking, parallel rank mapping and verification, data pipeline and checkpoint validation, stability monitoring, and concrete pass/fail criteria, plus a troubleshooting table for common failures.

    1. Verify That Both Nodes Have Identical Environments

    The most common hidden failure in two-node training is environment inconsistency between nodes. A driver that differs by a minor version, or a missing dependency on one machine, can cause initialization failures or errors that only surface on specific operators. Before starting, compare the key versions on both machines.

    Check the following:

    • Accelerator driver, firmware, and runtime versions.
    • Communication library version and the name of the training NIC. Both nodes should use the same NIC name, for example eth1.
    • MTU of the training NIC. Both ends and the switch should use the same value, as defined by your network plan. Mismatched MTUs cause fragmentation or dropped large packets, showing up as low and unstable throughput.
    • Python and training framework versions. Ideally, deliver via a single container image — identical image digests mean identical environments.
    • System clock skew. Check with chronyc tracking; the offset should stay within the range agreed by your team.
    • Hostname resolution. Use getent hosts node-1 to confirm both nodes can resolve each other.
    • Passwordless access and firewall. ssh -o BatchMode=yes node-1 hostname should return the hostname directly, and the port range used by distributed communication (starting from 29500 in the examples) must be open.

    The script below collects key information from each node and reports differences. The accelerator query commands are placeholders — replace them with the tools provided by your platform.

    1. import subprocess
    2. from collections import defaultdict
    3. NODES = ["node-0", "node-1"]
    4. CHECKS = {
    5. "driver": "accel-smi --query driver", # placeholder: replace with platform tool
    6. "firmware": "accel-smi --query firmware", # placeholder: replace with platform tool
    7. "runtime": "accel-smi --query runtime", # placeholder: replace with platform tool
    8. "comm_lib": "accel-smi --query comm-lib", # placeholder: replace with platform tool
    9. "python": "python3 -c 'import sys; print(sys.version.split()[0])'",
    10. "train_nic_mtu": "cat /sys/class/net/eth1/mtu", # replace with your training NIC name
    11. }
    12. class RemoteError(RuntimeError):
    13. pass
    14. def run_remote(node, cmd):
    15. # cmd is a fixed string; no external input is concatenated
    16. try:
    17. result = subprocess.run(
    18. ["ssh", "-o", "BatchMode=yes", node, cmd],
    19. capture_output=True, text=True, timeout=30, check=False,
    20. )
    21. except subprocess.TimeoutExpired as exc:
    22. raise RemoteError(f"{node} timed out: {cmd}") from exc
    23. if result.returncode != 0:
    24. raise RemoteError(f"{node} returned {result.returncode}: {result.stderr.strip()}")
    25. return result.stdout.strip()
    26. def collect_env(nodes):
    27. report, errors = defaultdict(dict), []
    28. for node in nodes:
    29. for key, cmd in CHECKS.items():
    30. try:
    31. report[node][key] = run_remote(node, cmd)
    32. except RemoteError as exc:
    33. errors.append(str(exc))
    34. report[node][key] = "ERROR"
    35. return report, errors
    36. def find_mismatch(report):
    37. mismatches = []
    38. keys = next(iter(report.values())).keys()
    39. for key in keys:
    40. values = {node: info[key] for node, info in report.items()}
    41. if len(set(values.values())) > 1:
    42. mismatches.append((key, values))
    43. return mismatches
    44. if __name__ == "__main__":
    45. report, errors = collect_env(NODES)
    46. for err in errors:
    47. print(f"[ERROR] {err}")
    48. for key, values in find_mismatch(report):
    49. print(f"[MISMATCH] {key}: {values}")
    50. if not errors and not find_mismatch(report):
    51. print("Key environment info is consistent across nodes")

    The script is read-only and changes no configuration. When a [MISMATCH] appears, the owner should first confirm which node is the reference, then align the other node or rebuild the image, and re-run the script. When an [ERROR] appears, fix remote connectivity first — do not proceed with incomplete results.

    2. Validate Communication Separately with a Benchmark

    Computation finishes quickly within a single GPU, but gradient synchronization requires all nodes to exchange data — the slower the network, the longer each step waits. Communication issues should be isolated with a benchmark first, not guessed at after a full training run fails.

    The examples below use PyTorch with NCCL-style environment variables. If your platform uses a different communication library, substitute the corresponding variable names and backend.

    Intra-node test, using only the 8 GPUs on node-0:

    1. export NCCL_DEBUG=INFO
    2. export NCCL_SOCKET_IFNAME=eth1 # pin the training NIC to avoid picking the management network
    3. torchrun --nproc_per_node=8 comm_bench.py --size-mb 256 --iters 50

    Cross-node test, run on both machines with NODE_RANK set to 0 and 1 respectively:

    1. export NCCL_DEBUG=INFO
    2. export NCCL_SOCKET_IFNAME=eth1
    3. torchrun --nnodes=2 --nproc_per_node=8 --node_rank=$NODE_RANK \
    4. --master_addr=node-0 --master_port=29500 \
    5. comm_bench.py --size-mb 256 --iters 50

    The benchmark script comm_bench.py:

    1. import argparse
    2. import os
    3. import time
    4. import torch
    5. import torch.distributed as dist
    6. def main():
    7. parser = argparse.ArgumentParser()
    8. parser.add_argument("--size-mb", type=int, default=256)
    9. parser.add_argument("--iters", type=int, default=50)
    10. parser.add_argument("--warmup", type=int, default=10)
    11. args = parser.parse_args()
    12. dist.init_process_group(backend="nccl") # replace with the platform's backend if needed
    13. rank, world = dist.get_rank(), dist.get_world_size()
    14. torch.cuda.set_device(int(os.environ["LOCAL_RANK"])) # replace with the platform's device API
    15. numel = args.size_mb * 1024 * 1024 // 4
    16. buf = torch.ones(numel, dtype=torch.float32, device="cuda")
    17. # Speed test only; repeated accumulation overflows, so values are not meaningful for correctness
    18. for _ in range(args.warmup):
    19. dist.all_reduce(buf)
    20. torch.cuda.synchronize()
    21. start = time.perf_counter()
    22. for _ in range(args.iters):
    23. dist.all_reduce(buf)
    24. torch.cuda.synchronize()
    25. elapsed = (time.perf_counter() - start) / args.iters
    26. # all_reduce bus bandwidth estimate: 2 * (n - 1) / n * data size / elapsed time
    27. size_gb = args.size_mb / 1024
    28. bus_bw = 2 * (world - 1) / world * size_gb / elapsed
    29. if rank == 0:
    30. print(f"world={world} size={args.size_mb}MB "
    31. f"avg={elapsed * 1000:.2f}ms busbw={bus_bw:.2f}GB/s")
    32. dist.destroy_process_group()
    33. if __name__ == "__main__":
    34. main()

    Keep the measurement methodology consistent. busbw is the all_reduce bus bandwidth estimate and can be compared directly against the network reference values in your platform’s documentation. Record intra-node and cross-node results separately. If the two differ greatly, check NIC selection and topology mapping first. If the cross-node output shows Socket instead of NET/IB, the high-performance network is not active and RDMA configuration needs investigation.

    Pass thresholds should be defined by the team before validation. One reference approach: cross-node busbw should be no less than 70% of the platform’s documented reference value. This is a suggested value and must be confirmed against your actual network.

    3. Parallel Rank Mapping and Verification

    How the 16 GPUs are organized determines communication volume and memory usage. This validation uses data parallel 2, tensor parallel 4, and pipeline parallel 2:

    world_size = dp × tp × pp = 2 × 4 × 2 = 16

    The mapping principle: tensor-parallel and pipeline-parallel groups stay within a single node; only data-parallel gradient synchronization crosses nodes. With 8 GPUs per node, node-0 hosts dp=0 and node-1 hosts dp=1. The rank numbering rule is:

    rank = dp_idx × (tp × pp) + pp_idx × tp + tp_idx

    The script below computes coordinates and verifies that all three types of communication groups land where expected:

    1. GPUS_PER_NODE = 8
    2. DP, PP, TP = 2, 2, 4
    3. WORLD_SIZE = DP * PP * TP
    4. def rank_to_coord(rank):
    5. tp_idx = rank % TP
    6. pp_idx = (rank // TP) % PP
    7. dp_idx = rank // (TP * PP)
    8. return dp_idx, pp_idx, tp_idx
    9. def coord_to_rank(dp_idx, pp_idx, tp_idx):
    10. return dp_idx * (TP * PP) + pp_idx * TP + tp_idx
    11. def nodes_of(ranks):
    12. return {rank // GPUS_PER_NODE for rank in ranks}
    13. def verify_placement():
    14. for d in range(DP):
    15. for p in range(PP):
    16. tp_group = [coord_to_rank(d, p, t) for t in range(TP)]
    17. if len(nodes_of(tp_group)) != 1:
    18. raise AssertionError(f"Tensor-parallel group spans nodes: {tp_group}")
    19. for d in range(DP):
    20. for t in range(TP):
    21. pp_group = [coord_to_rank(d, p, t) for p in range(PP)]
    22. if len(nodes_of(pp_group)) != 1:
    23. raise AssertionError(f"Pipeline-parallel group spans nodes: {pp_group}")
    24. for p in range(PP):
    25. for t in range(TP):
    26. dp_group = [coord_to_rank(d, p, t) for d in range(DP)]
    27. if len(nodes_of(dp_group)) != DP:
    28. raise AssertionError(f"Data-parallel group does not span nodes: {dp_group}")
    29. print("Parallel mapping verification passed")
    30. if __name__ == "__main__":
    31. verify_placement()
    32. for rank in range(WORLD_SIZE):
    33. dp_idx, pp_idx, tp_idx = rank_to_coord(rank)
    34. print(f"rank={rank:2d} node={rank // GPUS_PER_NODE} "
    35. f"dp={dp_idx} pp={pp_idx} tp={tp_idx}")

    After running, ranks 0–7 should be on node-0 and ranks 8–15 on node-1. If verification fails, check the rank-to-node binding order in the launch script first — do not change the parallel configuration directly.

    Training is launched with torchrun. The training script train.py is provided by your team:

    1. torchrun --nnodes=2 --nproc_per_node=8 --node_rank=$NODE_RANK \
    2. --master_addr=node-0 --master_port=29500 \
    3. train.py --dp 2 --pp 2 --tp 4 --max-steps 400 \
    4. --ckpt-dir /data/ckpt --ckpt-interval 100

    4. Data Pipeline, Checkpoints, and Stability Monitoring

    The data pipeline is often overlooked. If accelerators frequently wait for data, training throughput drops while the loss curve still looks normal. Measure per-step data waiting time directly:

    1. import time
    2. def timed_batches(loader):
    3. it = iter(loader)
    4. while True:
    5. t0 = time.perf_counter()
    6. try:
    7. batch = next(it)
    8. except StopIteration:
    9. return
    10. yield batch, time.perf_counter() - t0 # second item: seconds spent waiting for data this step

    In the training loop, log the waiting time and total step time for each step, and compute the waiting ratio. A suggested pass threshold is below 5%. Above that, first tune data-loading concurrency, prefetch depth, and sharding before looking at storage performance.

    Checkpoints need two things verified: that saving works, and that the curve is continuous after resume. In this validation, checkpoints are saved every 100 steps; training is interrupted after step 200, resumed from the checkpoint, and run to step 400. The loss from step 201 to 210 after resume should essentially match an uninterrupted reference run.

    1. def check_resume(ref_log, resumed_log, start_step, steps=10, tol=1e-2):
    2. # ref_log and resumed_log are {step: loss} dicts; tol is the relative error limit
    3. failures = []
    4. for step in range(start_step + 1, start_step + 1 + steps):
    5. ref, got = ref_log[step], resumed_log[step]
    6. rel = abs(ref - got) / max(abs(ref), 1e-12)
    7. if rel > tol:
    8. failures.append((step, ref, got, rel))
    9. return failures

    The value of tol must be determined by the team based on the framework’s determinism settings. If non-deterministic operators are enabled, small fluctuations are acceptable, but they should not grow continuously with steps.

    Checkpoint cleanup carries risk. Before deleting old checkpoints, confirm the new checkpoint has passed load verification and get sign-off from the owner. This article does not provide an automated deletion script — it only recommends manually listing the files to be cleaned up, reviewing them, and then deleting.

    Stability monitoring should cover:

    • Per-step time and throughput, broken down per node, to catch a single slow machine.
    • Loss and gradient norm — alert and stop training immediately on NaN or Inf.
    • Accelerator utilization and memory usage; continuously growing memory usually means unreleased caches or graphs.
    • Data waiting ratio and checkpoint write time.
    • Network error counters between nodes; rising retransmissions call for network investigation.

    5. 400-Step Validation Results and Pass Criteria

    The table below lists validation items, pass criteria, and the measured values to fill in. Measured values must come from the scripts in this article and the training logs — never estimated in advance.

    Validation item Pass criterion Measured value
    Environment consistency Environment script shows no [MISMATCH] or [ERROR] output TBD
    Intra-node busbw Compared against platform reference value, with test size recorded TBD
    Cross-node busbw No less than 70% of the platform reference value (suggested) TBD
    Rank mapping Verification script prints “Parallel mapping verification passed” TBD
    Training completion Runs continuously to step 400 without interruption TBD
    Numerical stability No NaN or Inf throughout TBD
    Loss convergence Average loss of the last 50 steps is lower than that of the first 50 steps TBD
    Data waiting ratio Below 5% TBD
    Checkpoint resume Relative error over 10 steps after resume is within the team-defined tol TBD
    Memory Peak memory does not exceed 90% of per-GPU capacity (suggested) TBD

    Only when all items pass can the two-node 16-GPU pipeline be considered working in this environment. If any item fails, troubleshoot using the table below, fix it, and re-validate from the corresponding step — do not jump straight to step 400.

    6. Troubleshooting Common Issues

    Symptom Possible cause How to check
    Initialization timeout Port not open, hostname resolution failure, wrong master_addr Check firewall and getent hosts; confirm master_addr is identical on both ends
    Cross-node bandwidth far below reference Wrong NIC selected (management network), MTU mismatch, RDMA not enabled Check the NIC name in NCCL_DEBUG output; compare MTU on both ends
    Intra-node bandwidth fine, cross-node very poor Training NIC not pinned or wrong topology mapping Run the rank mapping script; confirm tp groups are within one node
    Loss becomes NaN after a number of steps Learning rate too high, mixed-precision overflow, bad data samples Check learning rate and loss scale; locate the data batch at the failing step
    One machine has noticeably lower throughput Driver or runtime version differences, uneven node load, slow disk Compare environment script output; check that node’s data waiting ratio
    Loss jumps after resume Optimizer state or random seed not restored together Check whether the checkpoint includes optimizer and LR scheduler state
    Memory keeps growing Unreleased tensors, accumulating caches Record peak memory per step; check whether growth is linear with steps

    By validating each item in the order above, you can confirm whether the training pipeline truly works in a two-node 16-GPU environment.