Training Adaptation for Large Language Models: From Inference Deployment to Stable Training Practice

    This article explains how training adaptation differs from Day 0 support for new open-source models, and why the two should not be treated as equivalent. It outlines three questions for judging what a validation covers, an FSDP2-based multimodal training setup with example PyTorch code, and a checklist for testing long-running training stability and software stack coverage.

    1. Training Adaptation Is Not the Same as Pretraining Support

    Many articles treat “Day 0 adaptation” as proof of a chip’s capability, but the two mean different things. Day 0 adaptation usually means a chip can load and run a newly released open-source model for inference or fine-tuning. Foundation model pretraining requires the chip to work stably across the full pipeline of forward propagation, backward propagation, gradient aggregation, and parameter updates. That pipeline typically runs for weeks or longer.

    To determine which category an adaptation falls into, start with three questions:

    1. Does the validation cover inference or training?
    2. Does it cover backpropagation and optimizer updates?
    3. Does it run for long periods across multiple nodes and multiple cards?

    Some open-source model technical reports present results for several hardware platforms. These results often focus on validating inference operators. Readers who want to know which hardware was used for a model’s pretraining should check the original report directly.

    The case referenced in this article involves a general-purpose AI computing platform. The platform has disclosed that its flagship AI training and inference card has completed training adaptation for an open-source model with nearly 3 trillion parameters. Such a result shows that the training pipeline works end to end. It does not, by itself, prove that all of that model’s pretraining ran on the same hardware.

    2. A Multimodal Training Path Based on FSDP2

    FSDP2 (Fully Sharded Data Parallel 2) shards parameters, gradients, and optimizer states across GPUs. Each card stores only its own portion, so peak memory per card drops significantly. When a model is larger than a single card’s capacity, this approach makes training possible.

    Building a multimodal training path usually involves three issues:

    • Module differences: The vision encoder and the language model body differ noticeably in parameter count, compute density, and activation size. They may need different sharding granularity.
    • Overlapping communication and computation: After sharding, parameter gathering and gradient reduction add communication overhead. Overly fine sharding increases the number of communication calls, while overly coarse sharding raises peak memory.
    • Numerical precision: Parameters and computation typically use BF16. Gradient reduction can use FP32 to balance speed and numerical stability.

    The example below uses PyTorch’s FSDP2 interface. It assumes the model has a blocks attribute and uses the NCCL communication backend. In a CUDA environment, it can serve as a starting point. On other hardware, replace the communication backend name and device type with the values from the vendor’s documentation.

    1. import os
    2. import torch
    3. import torch.distributed as dist
    4. import torch.nn as nn
    5. from torch.distributed.fsdp import fully_shard, MixedPrecisionPolicy
    6. def setup_distributed():
    7. local_rank = int(os.environ["LOCAL_RANK"])
    8. dist.init_process_group(backend="nccl")
    9. torch.cuda.set_device(local_rank)
    10. return local_rank
    11. def wrap_model(model: nn.Module) -> nn.Module:
    12. mp_policy = MixedPrecisionPolicy(
    13. param_dtype=torch.bfloat16,
    14. reduce_dtype=torch.float32,
    15. )
    16. # Shard each block individually. Parameters are gathered when the block
    17. # is computed and released afterward.
    18. for block in model.blocks:
    19. fully_shard(block, mp_policy=mp_policy)
    20. fully_shard(model, mp_policy=mp_policy)
    21. return model
    22. def train(model, optimizer, dataloader, loss_fn, max_norm=1.0):
    23. model.train()
    24. for step, (x, y) in enumerate(dataloader):
    25. x, y = x.cuda(), y.cuda()
    26. loss = loss_fn(model(x), y)
    27. if not torch.isfinite(loss):
    28. raise RuntimeError(f"step {step}: loss is not finite")
    29. loss.backward()
    30. grad_norm = torch.nn.utils.clip_grad_norm_(model.parameters(), max_norm)
    31. optimizer.step()
    32. optimizer.zero_grad(set_to_none=True)
    33. if step % 10 == 0 and dist.get_rank() == 0:
    34. print(f"step={step} loss={loss.item():.4f} grad_norm={grad_norm:.4f}")

    The launch command below assumes 8 cards per machine, with 2 machines and 16 cards in total. Adjust it to match your actual cluster configuration.

    1. torchrun --nnodes=2 --nproc_per_node=8 \
    2. --rdzv_backend=c10d --rdzv_endpoint=<master-node-IP>:29500 train.py

    Two points need attention. First, the import path for FSDP2 changes between PyTorch versions, so refer to the official documentation for the version you use. Second, max_norm=1.0 is only a starting point. Determine the gradient clipping threshold through baseline experiments.

    3. Stability Validation Across Two Nodes and 16 Cards

    According to the platform, 16 training processes across two machines completed 400 consecutive optimizer updates. Loss and gradient norm stayed finite throughout, with no numerical overflow or interruptions. Under these test conditions, the training pipeline ran continuously for 400 steps. This result does not directly support a conclusion that long-term stable training is guaranteed.

    To reproduce this test or design your own, check the following items:

    • Runtime duration: Go beyond 400 steps and run for longer periods. Record the number of interruptions and the recovery time for each.
    • Numerical metrics: Log loss and gradient norm continuously, and watch for non-finite values or spikes.
    • Precision strategy: BF16 typically does not require dynamic loss scaling, while FP16 training does. Choose the strategy based on measured results.
    • Communication quality: Record inter-node bandwidth, retransmission counts, and timeout counts. Check whether these increase as training progresses.
    • Fault injection: Simulate the failure of a single card or node, and verify that the recovery process completes.
    • Throughput baseline: Record tokens/s for each step, compare it against the baseline, and start an investigation when fluctuations exceed a set threshold.

    The following thresholds are suggested starting points, not test results. Adjust them for your model and cluster. For example, treat a gradient norm more than 10 times its historical median as abnormal, and start an investigation when throughput drops by more than 15%.

    4. Checklist for the Software Stack

    Whether training adaptation can be deployed in practice depends on how much of the software stack is covered. The following checklist can help teams judge whether a target platform is ready.

    • Operator coverage: List all operators the model uses, including FlashAtt