Domestic GPU Large Language Model Training Adaptation: Practical Guide and Acceptance Checklist
This article explains how to distinguish inference access, training adaptation, and foundation model pre-training when evaluating domestic GPU large-model training. It covers weight sharding, parallel mapping, FSDP wrapping, operator compatibility, numerical alignment, gradient synchronization, multi-node experiment reporting, loss and gradient-norm monitoring, acceptance criteria, and troubleshooting. It provides a practical framework for engineering teams to verify whether training is merely runnable or reproducibly stable.
Key takeaway: Domestic GPU large-model training adaptation: distinguish “can run once” from “stable training”
When discussing large-model training on domestic GPUs, AI accelerators, or full-function GPUs, a common misunderstanding is to treat “inference access”, “training adaptation”, and “foundation model pre-training” as the same thing. Inference access focuses on whether the forward pass can be computed and how fast it is. Training adaptation requires a complete closed loop across forward, backward, gradients, optimizer states, and long-term numerical stability. Foundation model pre-training concerns the origin of the model weights themselves: training from scratch, continued pre-training, or only completing engineering adaptation.
For engineering teams, a valuable assessment is not a simple claim of “adaptation completed”. It is whether reproducible acceptance evidence can be provided: whether weight shard loading is complete, whether operator coverage is sufficient, whether precision alignment has defined tolerances, whether communication synchronization is stable, whether loss and gradient norms remain finite over long runs, and whether rollback and resume training are possible after failures. This article provides a technical framework for domestic GPU large-model training adaptation, covering concepts, code, experiment scope, and troubleshooting, to help readers build a complete understanding from concepts to verification.
1. Concept boundaries: inference access, training adaptation, and foundation model pre-training
| Comparison item | Inference access | Training adaptation | Foundation model pre-training |
|---|---|---|---|
| Core goal | Make the model executable in the forward pass on target hardware and meet throughput, latency, and memory requirements | Enable a complete forward/backward closed loop on target hardware and support long-term stable training | Train or continue training the model weights themselves |
| Main deliverables | Inference service, model export, performance report | Reproducible training scripts, stable loss curves, resumable checkpoints | New model weights and training records |
| Key metrics | QPS, TTFT, throughput, memory usage, operator accuracy | loss, grad_norm, NaN/Inf ratio, communication time, scaling efficiency | convergence curve, training steps, compute scale, data mixture |
| Common risks | Missing operators, precision deviation, unmet performance targets | Incorrect backward operators, gradient overflow, unsynchronized optimizer state, communication timeouts | Writing inference adaptation as foundation model pre-training |
| Acceptance evidence | Inference result cross-checks, performance baselines | Hundreds of consecutive stable training steps, numerical health monitoring, checkpoint resume | Public training configurations, logs, weights, or reproducible notes |
In short, inference access answers whether the model can be computed on the target GPU, training adaptation answers whether the target GPU can train the model stably, and foundation model pre-training answers whether the model weights were trained from scratch on a given compute stack. These three cannot replace one another.
2. Technical chain of training adaptation: from weight sharding to gradient synchronization
2.1 Weight sharding and parallel mapping paths
Models at the trillion-parameter scale cannot be placed into a single GPU’s memory as a whole. Therefore, the first step of training adaptation is not simply “loading a model”, but designing a practical shard-loading and parallel-mapping path. Engineering work usually includes:
- Layer partitioning: distributing Transformer layers across devices.
- Tensor partitioning: applying tensor parallelism to attention heads, MLP intermediate dimensions, embeddings, and other components.
- Pipeline partitioning: placing different layers in different stages and advancing micro-batches through a pipeline.
- Parameter sharding: using strategies such as FSDP to flatten parameters, gradients, and optimizer states across multiple GPUs.
- Memory budget evaluation: memory usage must account for at least weights, gradients, optimizer states, activations, and temporary communication buffers.
Therefore, the earlier phrase “multimodal loading path” should be more accurately understood as a “shard-loading and parallel-mapping path”. It is not a single loading method, but a systems-engineering problem composed of weight splitting, device mapping, precision conversion, and memory budgeting.
2.2 FSDP wrapping example: wrapping a model under a parent module
In training adaptation, a model cannot be wrapped by reassigning an ineffective loop variable. The correct approach is to let FSDP take over the parent module and then register the wrapped model back into the training workflow. The following example uses a common Transformer model to show process group initialization, device mesh creation, FSDP wrapping, and mixed precision configuration.
import osimport functoolsimport torchimport torch.distributed as distfrom torch.distributed.device_mesh import init_device_meshfrom torch.distributed.fsdp import FullyShardedDataParallel as FSDPfrom torch.distributed.fsdp.fully_sharded_data_parallel import MixedPrecision, ShardingStrategyfrom torch.distributed.fsdp.wrap import transformer_auto_wrap_policy# Assume TransformerBlock comes from a concrete model library, such as Llama, Qwen, or GLM.# from transformers.models.llama.modeling_llama import LlamaDecoderLayer as TransformerBlockdef build_fsdp_model(model, device_type="cuda"):local_rank = int(os.environ.get("LOCAL_RANK", 0))rank = int(os.environ.get("RANK", local_rank))world_size = int(os.environ.get("WORLD_SIZE", 1))backend = os.environ.get("DIST_BACKEND", "nccl")if not dist.is_initialized():dist.init_process_group(backend=backend,rank=rank,world_size=world_size,)if device_type == "cuda":torch.cuda.set_device(local_rank)else:# Domestic hardware usually provides device setup interfaces through a vendor adaptation layertorch.device(f"{device_type}:{local_rank}")mesh = init_device_mesh(device_type=device_type,mesh_shape=(world_size,),mesh_dim_names=("dp",),)model = model.to(f"{device_type}:{local_rank}")auto_wrap_policy = functools.partial(transformer_auto_wrap_policy,transformer_layer_cls={TransformerBlock},)mixed_precision = MixedPrecision(param_dtype=torch.bfloat16,reduce_dtype=torch.float32,buffer_dtype=torch.bfloat16,)model = FSDP(model,device_mesh=mesh,auto_wrap_policy=auto_wrap_policy,sharding_strategy=ShardingStrategy.FULL_SHARD,mixed_precision=mixed_precision,use_orig_params=True,limit_all_gathers=True,)return model
The key points in this code are: model = FSDP(model, ...) performs actual parameter sharding and forward/backward communication wrapping; device_mesh provides the device mesh; init_process_group provides the process group for multi-machine and multi-GPU training; and auto_wrap_policy specifies sharding and wrapping by Transformer blocks. In actual use, device_type and backend should be replaced with interfaces supported by the vendor adaptation layer of the domestic hardware.
2.3 Operator adaptation and numerical alignment
Training introduces many more backward operators than inference, such as:
- Linear-layer backward computation and gradient calculation;
- LayerNorm/RMSNorm backward operators;
- Softmax and attention backward operators;
- Gradient accumulation in residual connections;
- Dropout backward operators;
- In-place operations related to optimizer state updates;
- Mixed-precision casts, accumulation, all-gather, and reduce-scatter operations.
These operators must not only exist; they must also be numerically aligned. Common problems include: forward outputs are close but gradients diverge; normalization statistics drift under BF16; gradients overflow under FP16; some fused operators lack backward implementations; non-deterministic kernels introduce gradient noise. Therefore, training adaptation needs an operator coverage table and a precision cross-check mechanism, progressing step by step through small-model alignment, single-layer alignment, single-operator alignment, and end-to-end alignment.
2.4 Gradient synchronization and optimizer updates
Large-scale training relies on collective communication for gradient reduction, parameter aggregation, and optimizer state updates. Training adaptation should pay special attention to:
- Whether all-gather fully retrieves sharded parameters during the forward pass;
- Whether reduce-scatter correctly reduces gradients after the backward pass;
- Whether all ranks maintain consistent optimizer states;
- Whether communication timeouts can be retried;
- Whether node jitter can cause the entire training group to fail;
- Whether optimizer momentum, learning-rate schedulers, and random seeds are restored consistently after checkpoint resume.
The difficulty of training adaptation is not whether a single GPU computes fast enough, but whether all ranks can remain consistent across hundreds or thousands of steps in multi-GPU and multi-node scenarios.
3. Multi-node and multi-GPU coordination: experiment scope must be clearly documented
Many public statements say “16 AI accelerator cards across two nodes completed cross-node joint training, and all 16 training processes participated in hundreds of optimizer updates”. Without experiment scope, such a description can only show that something “ran”, not that it “trained stably”. It is recommended to record at least the following information; if real data cannot be provided, the statement should clearly be written as “illustrative verification”.
| Item | Recording requirement | Illustrative example |
|---|---|---|
| Chip / accelerator card | Model, per-card memory, compute capability | Domestic full-function GPU, 64GB per card; exact model should be based on measured results |
| Interconnect | Intra-node interconnect and inter-node network | Intra-node high-speed interconnect, inter-node 200Gb RoCE; illustrative value |
| Parallel strategy | Combination of FSDP, TP, PP, DP | FSDP FULL_SHARD, TP=2; illustrative value |
| Compute precision | Forward, backward, communication, and optimizer precision | BF16 compute, FP32 master weights and optimizer states; illustrative value |
| Batch settings | Micro batch and global batch | micro_batch=2, global_batch=64; illustrative value |
| Sequence length | Tokens or sample length | seq_len=2048; illustrative value |
| Total steps | Number of consecutive optimizer updates | 500 steps; illustrative value |
| Monitoring metrics | loss, grad_norm, NaN/Inf, throughput, memory | Loss is finite, grad_norm is stable, no NaN/Inf |
If chip model, interconnect, parallel strategy, precision, batch size, sequence length, total steps, and monitoring metrics cannot be provided, it is better to revise the wording to: “The following is an illustrative verification plan used to explain the dimensions that training adaptation should cover. It does not represent the performance of a specific hardware platform or a specific vendor.” This reduces the risk of misinterpretation.
4. Numerical stability: loss and gradient-norm monitoring code
The strongest evidence for successful training adaptation is numerical health. The following code adds zero_grad, tensor finiteness checks, skipping updates when anomalies occur, and clearing gradients, so that an abnormal step does not cause gradient accumulation or training divergence.
import torchdef handle_numerical_issue(step):# In production, this can log the issue, reduce the learning rate, trigger an alert, or roll back to the last stable checkpointprint(f"[numerical-issue] step={step} detected, skip update and clear grads.")for step, batch in enumerate(loader):optimizer.zero_grad(set_to_none=True)outputs = model(batch)loss = outputs.lossloss.backward()grad_norm = torch.nn.utils.clip_grad_norm_(model.parameters(),max_norm=1.0,)loss_finite = bool(torch.isfinite(loss).all().item())grad_norm_finite = bool(torch.isfinite(grad_norm).all().item())if not (loss_finite and grad_norm_finite):optimizer.zero_grad(set_to_none=True)handle_numerical_issue(step)continueoptimizer.step()if torch.cuda.is_available():torch.cuda.synchronize()if step % 10 == 0:print(f"step={step}, "f"loss={loss.detach().float().item():.6f}, "f"grad_norm={grad_norm.detach().float().item():.6f}")
In practice, teams usually require gradient norms to remain finite and controlled for hundreds of consecutive steps, loss to decrease smoothly, no NaN/Inf to appear, and no abnormal interruptions. Only when these conditions are met can the adaptation be considered truly stable, rather than merely able to run occasionally.
5. One-page acceptance checklist: from “can train” to “ready to train out of the box”
Before discussing an engineering system, use a checklist to determine whether training adaptation is deliverable. It should cover the following dimensions:
| Acceptance item | Check content | Pass criteria |
|---|---|---|
| Weight shard loading | Whether a full checkpoint can be loaded into multiple GPUs; whether sharding rules are recorded | Loading succeeds, no weights are lost, peak memory usage can be recorded |
| Operator coverage | Whether forward, backward, and optimizer-related operators are complete | Operator list is complete; missing items have alternatives or implementation plans |
| Precision alignment | Whether FP16/BF16/FP32 strategies are clearly defined | Small-model, single-layer, or end-to-end errors are within an acceptable range |
| Communication synchronization | Whether all-gather, reduce-scatter, and all-reduce are stable | No frequent timeouts; rank states remain consistent |
| Numerical monitoring | Whether loss, grad_norm, and NaN/Inf are monitored in real time | No NaN/Inf for hundreds of consecutive steps; gradient norms remain stable |
| Performance baseline | Whether tokens/s, step time, and scaling efficiency are recorded | There is a comparable baseline, not just “can run” |
| Failure rollback | Whether abnormal steps can be skipped, learning rate can be reduced, and checkpoints can be rolled back | Training can recover after failures without polluting training state |
| Checkpoint resume | Whether optimizer, scheduler, and random state can be restored | The curve remains continuous after resume with no obvious jumps |
Only when each item in this checklist can be verified is training adaptation closer to “ready to train out of the box”. Otherwise, it should only be called “runnable under specific tasks”.
6. Common troubleshooting guide
| Phenomenon | Common causes | Recommended handling |
|---|---|---|
| Loss suddenly becomes NaN/Inf | FP16 overflow, learning rate too high, dirty data, abnormal backward operator | Skip the current step, check the data, reduce the learning rate, enable FP32 master weights |
| BF16 precision drift in later training | Normalization statistics error, abnormal optimizer state, insufficient numerical range | Cross-check against an FP32 small model, check LayerNorm/RMSNorm, adjust warmup |
| Gradient-norm spikes | Long-tail samples, overly loose gradient clipping, communication desynchronization | Reduce the clipping threshold, skip abnormal steps, check data sharding |
| Communication timeout | Node network jitter, uneven rank load, blocked collective communication | Check RoCE/RDMA status, add timeout retries, analyze slow ranks |
| Optimizer state desynchronization | Incomplete checkpoint saving, inconsistent rank states | Validate state_dict, unify save/load flows, test resume training |
| Forward pass is normal but backward is incorrect | Missing backward operators, precision conversion errors, custom kernel bugs | Perform single-layer backward cross-checks; check gradients with respect to input and weight |
| OOM during all-gather | Activations too large, unreasonable sharding granularity, activation recomputation not enabled | Reduce micro batch, enable activation checkpointing, optimize FSDP strategy |
| Loss does not decrease | Inappropriate learning rate, gradients not synchronized, incorrect data labels | Check loss inputs, learning-rate curve, data pipeline, and label alignment |
7. How to reference practice cases more safely
In public materials, domestic compute training practices may mention directions such as hundred-billion-parameter scientific foundation models, 5D world models, embodied AI brain models, and trillion-parameter model training progress. To avoid misleading readers, it is recommended to include the following four types of information when citing them:
- Public source: report name, link, and publication date.
- Model scale: parameter count, number of layers, sequence length, vocabulary size.
- Training method: pre-training, continued pre-training, post-training, full-pipeline training, or only training adaptation.
- Minimal reproduction notes: compute scale, parallel strategy, precision, data scale, training steps, and acceptance metrics.
If the above information cannot be verified, the wording should be limited to “a publicly reported industry direction” or “a type of engineering practice case”. Avoid directly pointing to a specific vendor, and do not write “training adaptation completed” as “foundation model pre-training completed”.
8. Summary: judge domestic GPU training adaptation with hard metrics
Domestic GPU large-model training adaptation is moving from “can it run” to “is it stable, fast, and easy to use”. For developers and enterprise technical decision-makers, evaluating domestic compute should rationally distinguish inference access, training adaptation, and foundation model pre-training. The focus should be on continuous training steps, gradient norms, loss curves, NaN/Inf ratios, communication stability, checkpoint resume capability, and performance baselines.
Mature training adaptation should not mean only a single successful launch. It should support weight shard loading, operator alignment, multi-node and multi-GPU coordination, numerical monitoring, abnormal rollback, and performance reproduction. Only when these capabilities are consolidated into an automated toolchain and acceptance standards can domestic full-function GPUs move from “can train” to “ready to train”, and support large-scale training needs from research to production.
