Domestic GPU Adaptation for Large Model Training: A Practical Engineering Guide

    This article examines the engineering practice behind adapting a nearly 3-trillion-parameter open-source flagship large model for training on domestic GPUs. It distinguishes inference deployment, training adaptation, large-scale training, and foundation-model pretraining; explains a native FSDP2 training path covering model loading, shard scheduling, gradient synchronization, and stability guards; and provides practical guidance on parallelism strategy, precision alignment, cross-node communication, long-running stability, cloud training infrastructure, and a phased implementation checklist.

    1. Introduction: From “Running One Step” to “Finishing Training Stably”

    A domestic full-featured GPU vendor recently announced that it had completed training adaptation for an open-source flagship large model with nearly 3 trillion parameters. In the experiment, two nodes with 16 flagship training-and-inference AI accelerator cards performed cross-node joint training. A total of 16 training processes completed 400 optimizer updates continuously. Throughout the run, the loss and gradient norms remained finite, with no numerical overflow or abnormal interruption. The vendor also stated that it had built a native FSDP2 multimodal training path, covering the complete chain from model loading and sharding to gradient synchronization.

    For AI infrastructure teams, the value of this type of progress is not the “400 steps” alone, but the engineering methodology behind it. Compared with inference, training places requirements on a computing platform that are an order of magnitude higher:

    • Backpropagation requires every forward operator to have a correct and efficient gradient implementation.
    • Distributed training requires parameters, gradients, and optimizer states to remain consistent across dozens or even thousands of devices.
    • Long-running jobs may last for weeks, and instability on any single node can cause the entire run to regress.

    Connecting these three requirements together and sustaining them over time is the key to moving domestic GPUs from “usable” to “production-ready.” This article abstracts training adaptation into a reusable engineering methodology for teams involved in technology selection, platform construction, and algorithm engineering.

    2. Concept Clarification: Adaptation Success Does Not Mean Pretraining Was Done on the Chip

    2.1 Four Easily Confused Capability Levels

    Level Main Work Validation Method Resource Scale
    L1 Inference Deployment Load weights, perform forward inference, complete missing operators Output accuracy and throughput meet targets Single machine or a small number of cards
    L2 Training Adaptation Run forward pass, backward pass, and optimizer updates Loss and gradient norms behave normally Single-node multi-card to dual-node setups
    L3 Large-Scale Training Thousand-card or ten-thousand-card parallelism, fault tolerance, performance tuning Long-running stability and scaling efficiency Large-scale clusters
    L4 Foundation-Model Pretraining Train from scratch using raw compute Final model quality The largest compute scale

    In industry discussions, “Day 0 adaptation for a newly open-sourced model” usually refers to L1: the model can be loaded and used for inference on the target hardware on the day of release. The case described above clearly falls under L2. It is not only able to “run” on domestic GPUs, but can also complete the full forward pass, backward pass, and parameter update, providing the foundation for further pretraining or post-training. Neither case is L4. A successful adaptation does not mean that pretraining of the base model was performed on these chips.

    2.2 An Industry Example

    The technical report of a recent open-source model described validation of two different hardware routes and also presented validation on a fine-grained expert parallelism scheme. Based on the disclosed information, this is closer to inference-side operator and parallelism validation. The source of the original compute used for base-model pretraining was not disclosed. This example reinforces the point that hardware adaptation and the origin of base-model training compute must be understood separately.

    2.3 Implications for Technology Selection

    During technology selection, it is advisable to ask vendors or platform providers for evidence at three levels:

    • Functional evidence: training logs and loss curves for the target model at the target scale.
    • Precision evidence: alignment data against reference hardware, rather than relying only on the observation that “outputs look normal.”
    • Stability evidence: continuous run duration, fault injection records, and checkpoint/resume records.

    3. Chain Breakdown: What a Native Sharded Training Path Does

    In the original case, the vendor built a “native FSDP2” training path. “Native” means that the training framework provides native support for the domestic GPU, meaning the device backend, communication backend, and operator library are deeply adapted rather than relying on a compatibility layer that replaces operators one by one. “FSDP2” refers to the second-generation implementation of Fully Sharded Data Parallelism. Its core change is the use of DTensor to describe the sharding layout of each parameter, replacing the flattened parameter representation used in earlier versions. This makes parameter-level sharding more intuitive and makes combinations with tensor parallelism and pipeline parallelism clearer.

    This path consists of four parts.

    3.1 Model Loading: Avoid Materializing the Full Model on Every Card

    Traditional single-card training can directly load the complete weights. This is not feasible for ultra-large models. If every card first materializes the complete model, memory may be exhausted during the loading stage alone. The common approach to sharded loading is as follows:

    1. First create an empty “meta device” model that contains only structure and shape information, without real weight data.
    2. Apply sharding and parallel transformations to the model according to the training parallelism strategy.
    3. Each rank reads only the portion of the weight file that belongs to it and writes that shard into local GPU memory.

    Multimodal models also need to handle structural differences among the visual encoder, modality projection layers, and language model backbone. This requires registering separate parameter groups for each module and configuring freezing strategies, differentiated learning rates, and weight decay.

    3.2 Shard Scheduling: Sharding Parameters, Gradients, and Optimizer States Together

    Consider a model with parameter count P. With BF16 mixed precision and an AdamW-style optimizer, the approximate relationship between resident memory per card and parameter count is as follows, excluding activations:

    Item Full Replica per Card Fully Sharded Data Parallel
    BF16 parameters 2 × P 2 × P / N
    BF16 gradients, optionally cast to FP32 2 × P, or 4 × P 2 × P / N, or 4 × P / N
    FP32 master weights 4 × P 4 × P / N
    Optimizer first moment 4 × P 4 × P / N
    Optimizer second moment 4 × P 4 × P / N
    Total 16 × P, or 18 × P About 16 × P / N, or 18 × P / N

    Here, N is the data-parallel degree. For a model of about 236 billion parameters, a full replica on one card would require about 3.8 TB of memory, which no single card can hold. With 16-way full sharding, parameter-related states require about 240 GB per card, which is still high. In practice, the following measures are often needed:

    • Optimizer offloading: move master weights and optimizer states to host memory to further reduce GPU memory pressure. The tradeoff is the data movement overhead during the update phase.
    • More aggressive sharding: combine with tensor parallelism or other dimensions.

    It is important to emphasize that activations do not decrease with sharding. When training long contexts, high-resolution visual inputs, or multimodal sequences, activations are often the real memory bottleneck. Gradient checkpointing, sequence parallelism, and similar techniques are needed to control them.

    “Shard scheduling” also includes runtime communication orchestration. The following code shows its key logic:

    1. # Illustrative pseudocode: forward and backward scheduling for fully sharded data parallelism (framework-agnostic)
    2. for layer in model.layers:
    3. # 1. After the previous layer's backward completes and gradient reduction finishes, prefetch the next layer to overlap communication and computation
    4. if backward_started:
    5. prefetch_all_gather(next_layer)
    6. # 2. Temporarily aggregate the current layer's shards when full parameters are needed for forward or backward
    7. params = all_gather(layer.sharded_params) # After aggregation, only the current layer remains in full form
    8. output = layer.forward(params, input)
    9. # 3. After the current layer's backward completes, immediately reduce and scatter gradients, then release full parameters
    10. if backward_started:
    11. grads = reduce_scatter(layer.grads) # Reduced results are written back to each rank's corresponding shard
    12. release(params)

    This logic has three design points:

    • On-demand aggregation: at any moment, only the full parameters of the current layer are resident, limiting peak memory to roughly one layer.
    • Prefetch overlap: aggregation communication for the next layer overlaps with computation of the current layer, hiding communication latency.
    • Immediate release: gradient reduction and release follow backward computation closely, avoiding peak memory accumulation.

    3.3 Gradient Synchronization: BF16 for Compute, FP32 for Master Weights

    In fully sharded mode, gradient synchronization relies on Reduce-Scatter. While gradients are summed or averaged across cards, each card retains only the gradients corresponding to its own parameter shard.

    For precision, a common approach is to compute the forward and backward passes in BF16 while maintaining FP32 master weights. The optimizer updates parameters based on the FP32 master weights and then casts them back to BF16 for the next round of computation. This leverages the throughput and memory advantages of BF16 while avoiding the problem where low-precision updates are effectively “lost.”

    3.4 Training Loop and Stability Guards

    The following illustrative training loop focuses on stability guards:

    1. # Illustrative pseudocode: numerical stability guards in a sharded training loop (framework-agnostic)
    2. for step, batch in enumerate(dataloader, start=1):
    3. with autocast(dtype="bfloat16"):
    4. loss = model(batch).loss / grad_accum_steps
    5. backward(loss) # Sharded parameters are materialized on demand; gradients are scattered automatically
    6. if step % grad_accum_steps == 0: # Gradient accumulation: update only after several micro-batches
    7. grad_norm = clip_grad_norm_(model, max_norm=1.0)
    8. # Guard 1: Skip this update if grad_norm is non-finite (NaN/Inf)
    9. if not isfinite(grad_norm):
    10. log.warning("step %d: non-finite grad_norm, skip", step)
    11. optimizer.zero_grad(set_to_none=True)
    12. continue
    13. optimizer.step() # Update FP32 master weights, then cast back to low precision
    14. optimizer.zero_grad(set_to_none=True)
    15. # Guard 2: Log key metrics for cross-node consistency checks
    16. if step % log_interval == 0:
    17. local_loss = all_reduce_mean(loss) # Cross-node consistency: all ranks aggregate the same value
    18. log.metrics(step=step, loss=local_loss, grad_norm=grad_norm,
    19. lr=get_lr(), mem_peak=max_memory_allocated())

    Guard 1 corresponds to the result in the original case: the run remained finite with no abnormal interruption. In practice, the loss occasionally becoming NaN is not rare. Common causes include anomalous labels in individual samples, numerical issues in a specific operator under a specific shape, and hardware bit flips on a particular card. Explicitly detecting such cases and skipping the update when necessary can prevent a single anomaly from contaminating all parameters and also makes root-cause analysis easier.

    4. Parallelism Strategy: First Estimate What Fits on One Card, Then Decide How to Split

    The selection of a parallelism strategy follows the principle of “estimate first, split later”: first calculate single-card memory usage, then determine which parallelism dimensions are required. A typical decision path is as follows:

    1. If it fits on one card: prioritize DDP, or Distributed Data Parallelism. Each card holds a full model replica, and gradients are synchronized through All-Reduce at each step. This is the simplest to implement and usually has the highest communication efficiency.
    2. If it does not fit but can be sharded: use FSDP2 or ZeRO-3-style full sharding. Memory usage is reduced to approximately 1/N of the original, at the cost of additional parameter aggregation and gradient reduction communication at each layer.
    3. If even one layer cannot fit, or the model is extremely deep: introduce the following parallelism dimensions:
      • Tensor parallelism: split operators of a single layer across multiple cards. Communication is required at each layer, so this should generally be kept within high-speed intra-node interconnects.
      • Pipeline parallelism: split layers across different cards. Pipeline bubbles must be handled.
      • Sequence or context parallelism: in long-sequence scenarios, split activations along the sequence dimension.
      • Expert parallelism: for mixture-of-experts models, distribute experts across cards. All-to-All communication is used to route tokens.

    Complex models are often organized as a multi-dimensional grid, such as “tensor parallelism × pipeline parallelism × data parallelism,” where each card belongs to multiple communication groups at the same time. In the original case, the open-source model with nearly 3 trillion parameters typically uses a sparse mixture-of-experts architecture, where only a subset of experts is activated in a single forward pass. For such models, All-to-All communication in expert parallelism and load imbalance are often the main bottlenecks. Fine-grained expert parallelism schemes are designed to address exactly this problem.

    Based on the original case, a general selection order can be summarized as follows:

    1. Use FSDP2 to establish functional correctness and align precision.
    2. When sequences are long and activation pressure is high, introduce sequence parallelism.
    3. When training MoE models, evaluate the communication cost and load balancing of expert parallelism.
    4. Only when a single card cannot fit even one layer should cross-node tensor parallelism or pipeline parallelism be introduced.

    5. Precision Alignment: The Most Underestimated Part of Training Adaptation

    “Being able to produce a loss” and “training correctly” are two different things. Small differences in operator implementations can be gradually amplified over thousands or tens of thousands of iterations, causing the final model quality to deviate from expectations. Operator precision validation should cover at least the following categories:

    • Reduction operators: such as Softmax, LayerNorm, and RMSNorm. Low-precision accumulation can introduce significant error, so FP32 accumulation should be used internally.
    • Approximate functions: such as exponential functions, error functions, including the approximation used in GELU, and inverse square roots. Different implementations may choose different approximation methods.
    • Fused operators: such as fused attention. Different tiling strategies and reduction orders can cause numerical differences.
    • Non-deterministic behavior: such as atomic adds and certain reduction strategies. These can cause small differences between runs, so it is necessary to confirm whether they are within an acceptable range.

    A “three-layer validation method” is recommended:

    1. Single-operator level: use results from mainstream hardware as the reference. With fixed random inputs, compare maximum absolute error and relative error, and set clear thresholds.
    2. Single-step training level: fix random seeds, data order, and hyperparameters. Compare parameter differences after one training step starting from the same initial weights.
    3. Short-run training level: compare the deviation of the loss curve over hundreds of steps and confirm that it remains within a normal fluctuation range.

    In cloud practice, these benchmarks can be run separately on different compute resources within the same platform to form a reproducible precision baseline. This baseline can then be included in regression testing for every software stack upgrade.

    6. Cross-Node Communication: Engineering Points for Dual-Node, 16-Card Scenarios

    When scaling from single-node multi-card to dual-node 16-card setups, the nature of the problem changes. Multiple cards within a single node generally communicate through high-bandwidth interconnects, while cross-node communication relies on the network, where latency and bandwidth are typically lower by an order of magnitude. The following engineering points require attention:

    • Aligning parallel groups with topology: communication-intensive dimensions such as tensor parallelism should remain within the same node whenever possible. Cross-node traffic should mainly carry data parallelism or pipeline parallelism communication.
    • High-speed network configuration: when using RDMA-class networks, verify that affinity settings between devices and network cards are correct to avoid unintended communication paths.
    • Communication and computation overlap: FSDP2 prefetch depth and gradient bucketing directly affect overlap effectiveness. Small-scale parameter sweeps can be performed under representative workloads.
    • Slow-node detection: in distributed training, all cards synchronize at collective communication points, and one slow card can slow down the entire job. Periodically measuring per-rank step time helps identify nodes affected by frequency throttling or link anomalies.
    • Fault tolerance and checkpoint resume: training may last for weeks, so sharded checkpoint saving and restoration must be implemented. Recovery must restore model weights, optimizer states, the learning-rate scheduler state, and data-loader progress.

    7. Long-Running Stability: What Comes After 400 Steps?

    Completing 400 consecutive updates is a valuable interim result, but it mainly validates chain connectivity and numerical health. Moving from short-term validation to long-running training requires answering the following questions:

    • Minute-to-hour level: Are scheduling mechanisms such as learning-rate warmup, gradient clipping, and weight decay functioning correctly? Does the loss decrease smoothly rather than oscillating repeatedly?
    • Day-to-week level: Accumulated hardware errors, such as memory bit flips, memory fragmentation, software-stack memory leaks, and occasional communication timeouts.
    • Cluster level: Node failures, network jitter, storage I/O bottlenecks, and scheduling preemption.

    Corresponding engineering measures include:

    • Full-chain observability: collect compute metrics, communication metrics, and hardware metrics together.
    • Automatic fault localization: combine training logs, hardware logs, and job logs to attribute interruptions quickly to a specific node or operator.
    • Elastic fault tolerance: automatically resume training from the latest checkpoint to reduce manual intervention.

    This is consistent with the vendor’s stated capability in the original case: “from fast inference deployment to full-chain stable training.” Full-chain support means that observability, fault tolerance, and recovery mechanisms are also part of the training infrastructure.

    8. Engineering System: From “Able to Train” to “Train-Ready Out of the Box”

    The original case also mentions that the vendor has achieved results in multiple domestic-chip/domestic-model practice cases, including:

    • Complete from-scratch training of a scientific foundation model with about 236 billion parameters.
    • Full-stack native training of a 5D world model.
    • Full-process training of an embodied-brain model completed jointly with research institutions.

    The vendor is also advancing training for a trillion-parameter-scale large model.

    These workloads place different demands on the platform. Scientific foundation models emphasize long-running stability and numerical consistency. World models involve multimodal long sequences. Embodied models emphasize joint training of multimodal perception and decision-making. The ability to support all of them indicates that the software stack has a degree of generality.

    “Train-ready out of the box” is a sign of a mature training infrastructure. It can be broken down into four verifiable capabilities:

    • Out-of-the-box runnable: mainstream model structures can run without deep modification, relying on an adapted operator library and device backend.
    • Out-of-the-box fast: with reasonable parallelism strategies, the platform approaches the theoretical upper limit of hardware compute utilization.
    • Out-of-the-box stable: complete monitoring, fault tolerance, and checkpoint/resume capabilities are available.
    • Out-of-the-box efficient: toolchains for performance analysis, memory optimization, and communication tuning lower the tuning barrier.

    9. Cloud Deployment: Common Components of Training Infrastructure

    For enterprises preparing to run large-model training on domestic GPUs, cloud platforms can provide the following common capabilities:

    • Heterogeneous compute scheduling: allocate compute resources according to job requirements and support elastic scaling for different training scales.
    • High-performance storage and data management: object storage can hold training datasets, while a parallel file system can handle checkpoint and log writes.
    • Containerized training platforms: container images unify software-stack versions across nodes and ensure environment consistency.
    • Message queues: asynchronous decoupling for task orchestration and data-preprocessing pipelines.
    • Logging services and monitoring alerts: central collection of training logs and hardware metrics, threshold-based alerts, and support for quickly locating anomalous nodes.

    Baidu AI Cloud has related capabilities in these areas. Enterprises can combine these capabilities into a training platform for domestic GPUs, avoiding duplicated infrastructure construction.

    10. Practice Checklist: A Phased Roadmap

    A four-stage progressive roadmap is recommended, with clear acceptance criteria for each stage:

    • Stage 1: Single-card validation. Run forward, backward, and update on a small-scale model, and record loss and gradient norms.
    • Stage 2: Small-scale multi-card alignment. Conduct short-run training on 8 or 16 cards and compare loss curves with reference hardware.
    • Stage 3: Multi-node scaling. Complete cross-node training and validate communication efficiency, slow-node detection, and checkpoint resume.
    • Stage 4: Target-model long-run training. Run continuously at the target scale, observe metric trends, and establish alerting and emergency mechanisms.

    The acceptance criteria for each stage are as follows:

    Stage Functional Validation Precision Validation Stability Validation
    Single-card validation Forward, backward, and update all run successfully Single-operator error is within threshold No NaN or Inf
    Small-scale multi-card alignment Data parallelism converges normally Loss curve is largely consistent with reference hardware Hundreds of consecutive steps without interruption
    Multi-node scaling Cross-node communication and resume work Loss remains smooth before and after resume Slow nodes can be identified and isolated
    Target-model long-run training Full-chain metrics are observable Metrics meet expectations Faults can be recovered automatically

    11. Conclusion

    The completion of training adaptation for an open-source flagship large model with nearly 3 trillion parameters, together with stable 400-step continuous updates on dual nodes and 16 cards, marks a substantive step forward for domestic full-featured GPUs in the large-model training chain. However, maturity in training capability is not the result of a single adaptation effort. It is the accumulation of long-term refinement in operator precision, parallelism strategies, communication optimization, fault-tolerant operations, and toolchains.

    For application teams, the key is to establish training engineering standards from day one that are “verifiable, observable, and recoverable”:

    • Use precision alignment as the baseline.
    • Use full-chain monitoring as the main control mechanism.
    • Use checkpoint resume as the safeguard.

    Only in this way can large-model training on domestic compute truly move from “able to train” to “train-ready out of the box.”