Large Language Model Training Adaptation on Domestic Accelerators: An End-to-End Guide
In the domestic accelerator ecosystem, "training adaptation completed" is one of the most frequently used phrases in model announcements and vendor materials, and one of the easiest to misread. This guide first separates training adaptation from pretraining a model from scratch, then explains why adaptation matters even for teams that will never run a from-scratch pretraining job. It walks through FSDP2 sharding with a runnable example, how to configure the collective communication backend for multi-node training, and how to measure numerical stability with explicit test conditions. It closes with the full-stack engineering system behind stable training operations, a four-stage model of platform maturity, and a troubleshooting guide for the failures teams hit most often. Readers will learn what training adaptation does and does not claim, how to check readiness before starting, how to verify that an adaptation really works, and what it takes to move from "it trains" to "ready to train out of the box."
1. Training Adaptation Is Not Training from Scratch
Within the domestic accelerator ecosystem, “we completed training adaptation for model X” is a phrase that comes up constantly, and is just as constantly misread. The first thing to pin down is that training adaptation does not mean “pretraining a large model from zero on domestic chips.” It means making an existing, state-of-the-art model load correctly, compute correctly, and update its parameters correctly on a stack of domestic hardware, drivers, communication libraries, frameworks, and runtime components, while keeping the training run observable, reproducible, and recoverable.
Put differently, training adaptation validates that a given software and hardware stack can carry the model’s training loop reliably. It does not claim that the model’s final weights were produced by that compute. The two differ sharply in goals, cost, risk, and acceptance criteria.
| Dimension | Training adaptation | From-scratch pretraining |
|---|---|---|
| Core goal | Verify the model can train correctly on domestic compute | Produce new model weights |
| Inputs | An existing open-source base model, training code, sample data | Massive corpora, training objectives, compute planning |
| Success criteria | Loads, forward pass, backward pass, continuous parameter updates | Convergence, generalization, controllable compute cost |
| Main risks | Missing operators, communication failures, numerical overflow, insufficient memory | Data quality, training stability, scheduling at extreme scale |
| Engineering focus | Compatibility validation, performance profiling, fault recovery | Data mixing, training strategy, scaling out |
So when you see “training adaptation completed,” the accurate reading is: the model’s key training paths now run on this platform and can run continuously under a stated test configuration. Reading it as “the model was pretrained on this platform” produces a real misperception.
2. Why Training Adaptation Is a Critical Step for Domestic Compute
Even teams that will never run a from-scratch pretraining job still get substantial value from training adaptation. It solves at least three engineering problems.
First, it validates software stack maturity. Large model training code typically contains large numbers of custom operators, mixed-precision logic, parallelism strategies, and dynamic graph operations. A training adaptation exercise surfaces gaps in operator coverage, communication primitives, memory management, and graph execution quickly. Once those gaps are identified, they become concrete requirements for the next iteration of the software stack.
Second, it underpins fine-tuning and post-training. Most industry work is not training from zero. It is supervised fine-tuning, parameter-efficient fine-tuning, and reinforcement learning alignment on top of an open-source base. If the base model cannot train stably on the target platform, everything downstream — fine-tuning, evaluation, deployment — is blocked.
Third, it enables unified training and inference. Once training works, backward propagation, gradient synchronization, and optimizer updates are proven available. That is the foundation for continual learning, online fine-tuning, and mixed training and inference deployments.
In practice, teams should build a checklist before starting an adaptation effort:
- Operator checklist: Are attention, normalization, activation, loss, and optimizer-related operators all present?
- Communication checklist: Are the collective communication primitives required for data, tensor, and pipeline parallelism available?
- Memory checklist: Can a single device hold parameters, gradients, optimizer states, and activations?
- Precision checklist: Is the mixed-precision strategy sound, and are there overflow or truncation risks?
- Fault tolerance checklist: Are heartbeats, timeouts, checkpoint saving, and resume supported?
- Observability checklist: Are loss, gradient norm, throughput, memory usage, and communication time recorded?
3. FSDP2 Sharded Training: How It Works and a Minimal Example
Once parameter counts reach the hundreds of billions, a single device cannot hold parameters, gradients, optimizer states, and activations at the same time. Distributed parallelism becomes mandatory. FSDP2, the second generation of Fully Sharded Data Parallel, is one of the most important tools for this.
The core idea of FSDP2 is to shard parameters, gradients, and optimizer states more finely along the data-parallel dimension. Each device keeps only the shard it owns, gathers parameters on demand during the forward pass, and reduces gradients after the backward pass. This lowers peak per-device memory and makes it clearer to combine with other forms of parallelism.
In practice, FSDP2 is usually paired with activation checkpointing, mixed precision, and gradient clipping. The pseudocode below shows the order of sharded wrapping, parameter gathering, gradient reduction, and the update step. Interfaces differ across frameworks. On domestic accelerators, use a framework build adapted by the accelerator vendor, and record the framework version, driver version, firmware version, communication library version, and model code version.
import torchfrom torch.distributed.fsdp import fully_shard, MixedPrecision# Pseudocode: follows the FSDP2 interface available in PyTorch 2.3 and later# Domestic accelerators require the vendor-adapted framework, driver, and communication library combinationmodel = build_model().to(device)# Sharded wrapping: shard parameters, gradients, and optimizer states across the data-parallel dimensionmodel = fully_shard(model,mp_policy=MixedPrecision(param_dtype=torch.bfloat16,reduce_dtype=torch.float32))optimizer = build_optimizer(model)for step, batch in enumerate(dataloader):# Forward pass: each rank AllGathers the parameter shards it needs, then releases the full parametersloss = model(batch).loss# Backward pass: gradients are reduced with ReduceScatter, leaving each rank with its own gradient shardloss.backward()# Gradient norm must be computed before the update and before clippinggrad_norm = compute_grad_norm(model)# Gradient clipping: guard against exploding gradientsif grad_norm > max_grad_norm:grad_scale = max_grad_norm / (grad_norm + 1e-6)scale_gradients(model, grad_scale)# Optimizer updates only the local shard stateoptimizer.step()optimizer.zero_grad(set_to_none=True)# Record key metrics to judge whether training is healthylog(step=step,loss=loss.item(),grad_norm=grad_norm.item(),learning_rate=optimizer.param_groups[0]["lr"])
A few details in this code deserve attention.
AllGather temporarily assembles the full parameters for computation and must be released afterwards, or peak memory will get out of control. ReduceScatter handles gradient reduction, so each device ends up holding only its own gradient shard, which reduces both communication and storage overhead. The gradient norm has to be computed before the optimizer step, because once gradients are cleared or parameters are updated, the measurement no longer means anything. And the mixed-precision policy needs to state explicitly the precision of parameters, the precision used for gradient reduction, and how numerically sensitive operations are protected, so that accumulation in low precision does not produce anomalies.
4. Multi-Node Training: The Communication Backend Must Be Configurable
Real-scale training usually crosses the boundary of a single machine into multi-node, multi-device territory. At that point communication decides whether training can run stably at all. Compared with single-node multi-device training, cross-node training faces higher latency, more complex topologies, and a larger failure surface.
In a domestic compute environment, you cannot assume every device uses the same generic communication backend. Different accelerator cards are generally paired with collective communication libraries provided by their respective vendors. Some domestic accelerators use a vendor-built library, for example HCCL in the Ascend ecosystem, CNCL in the Cambricon ecosystem, or ECCL in the Enflame ecosystem. The actual choice must follow the accelerator card, driver, firmware, framework version, and the vendor’s compatibility list.
For that reason, the communication backend should be injected as a deployment parameter rather than hard-coded. The following is an illustrative initialization snippet:
import osimport torch.distributed as dist# Inject the communication backend from an environment variable instead of hard-coding itbackend = os.environ.get("DIST_BACKEND")if not backend:raise RuntimeError("DIST_BACKEND is not configured")rank = int(os.environ.get("RANK", "0"))world_size = int(os.environ.get("WORLD_SIZE", "1"))dist.init_process_group(backend=backend,init_method=os.environ.get("DIST_INIT_METHOD", "env://"),rank=rank,world_size=world_size)
When deploying, pay particular attention to the following parameters and conditions:
- Master node address and port: Every node must be able to reach it, and the port must not already be in use.
- Rank and world size: These must match the numbering assigned by the launcher.
- Communication timeout: Cross-node training needs a sensible timeout to avoid waiting indefinitely.
- Device visibility: Each rank must correctly identify the local accelerator device IDs.
- Network environment variables: Including NIC selection, topology discovery, congestion control, and retry policy.
- Communication library version: Must match the adapted versions of the driver, firmware, and framework.
- Compatibility matrix: Use the support list published jointly by the accelerator vendor and the framework community.
Cross-node training also needs health checks and fault tolerance. Common practices include periodic heartbeats, retries on failure, checkpointing, and automatic recovery. Checkpointing matters most in multi-node setups. A checkpoint must store not only model parameters but also optimizer states, the learning rate scheduler state, data loader progress, and random number generator states. To support recovery at a different scale, the checkpoint format should support elastic resharding, meaning it can be re-split and loaded even when the node count or parallel layout changes.
5. Numerical Stability: Training Must Keep Running Correctly, Not Just Run
In training adaptation, the most common problem is not that the program refuses to start. It is that loss goes abnormal, gradients explode, or processes hang after running for a while. Numerical stability is therefore a core indicator of adaptation quality.
Two signals are usually watched. The first is the loss curve: in healthy training, loss should trend down or stay stable, and should not remain infinite, NaN, or anomalous over long stretches. The second is the gradient norm: it should stay within a reasonable range, neither exploding suddenly nor sitting near zero indefinitely.
To make results credible, state the test conditions explicitly rather than quoting a vague device count. A description like this works:
“On a 2-node, 16-device environment, using a 7B parameter model, sequence length 2048, global batch size 64, BF16 mixed precision, we completed 300 consecutive optimizer updates. Loss and gradient norm remained finite, with no abnormal interruptions. This result is intended only to validate pipeline stability and is not a claim about throughput, convergence speed, or production performance.”
That kind of wording prevents readers from mistaking an adaptation result for a performance conclusion. Test conditions should state at least: framework version, model size, sequence length, global batch size, parallelism strategy, mixed precision, node count, network environment, optimizer type, number of training steps, and the data sample used.
Common techniques for keeping numerics stable include:
- Using a sound mixed-precision policy and keeping numerically sensitive computations at higher precision;
- Enabling gradient clipping to cap the gradient norm;
- Using learning rate warmup to avoid overly large steps early in training;
- Inserting anomaly detection at key computation points to locate where non-finite values appear;
- Validating data batches to rule out anomalous or corrupted samples;
- Retaining intermediate checkpoints so problems can be reproduced and rolled back.
6. The Full-Stack Engineering System: Adaptation Is the Entry Point, Stable Operation Is the Capability
Getting one training run to complete is not hard. What is hard is making training reproducible, scalable, portable, and sustainable. That requires an engineering system that covers the whole pipeline.
A complete domestic compute training platform is usually layered as follows:
- Operator layer: Correct implementation, performance optimization, and precision alignment for core operators.
- Parallelism strategy layer: Support for combining data, tensor, pipeline, and expert parallelism.
- Scheduling and fault tolerance layer: Job scheduling, failure detection, resuming from checkpoints, and elastic scaling.
- Toolchain layer: Performance profiling, memory analysis, communication diagnostics, and automatic hyperparameter tuning.
- Observability layer: Logs, metrics, traces, and alerts that let teams see training status in real time.
In cloud environments, a training platform has to work with general-purpose infrastructure rather than relying on training scripts alone. Common components include:
- Container orchestration: Job scheduling, resource isolation, node management, and restart on failure.
- Object storage: Training data, checkpoints, and intermediate artifacts.
- Message queues: Decoupling tasks, asynchronous callbacks, and job status notifications.
- Logging services: Centralized collection of training logs, error stacks, and user commands.
- Monitoring and alerting: Node health, job status, resource usage, and communication anomalies.
- Image registries: Container images for frameworks, drivers, communication libraries, and training code.
For operations, a unified metrics table is worth building. For example:
| Metric | Purpose | Anomaly signal |
|---|---|---|
| Training loss | Whether training is converging | Flat for a long time, or non-finite values |
| Gradient norm | Whether gradients are stable | Explosion, sudden drop, or zero for long stretches |
| Step time | Compute and communication efficiency | Sudden increase or excessive variance |
| Memory usage | Whether resources are sufficient | Approaching the limit or frequent overflow |
| Communication time | Cross-node bottlenecks | Continuously rising or timing out |
| Heartbeat status | Whether nodes are alive | Missing, delayed, or disconnected |
| Recovery time | Fault tolerance capability | Too long, or failure to recover |
7. From “It Trains” to “Ready to Train Out of the Box”: Roadmap, Choices, and Common Questions
The maturity of domestic compute support for large model training can be split into four stages:
- Inference works: The forward pass is complete and inference services are supported.
- Training works: Backward propagation and gradient synchronization are working, and fine-tuning is supported.
- Training is stable: Numerical stability and fault tolerance hold up in multi-node, multi-device, long-running jobs.
- Ready to train out of the box: Users can start training through a standard toolchain without deep customization.
Many platforms today are in the critical transition from stage two to stage three. Reaching stage four is not a matter of point optimizations. It requires systematic maturity across operators, communication, scheduling, monitoring, and the toolchain.
When choosing an adaptation approach, start with these questions:
- How do you judge whether a given domestic accelerator suits the target model? Check the vendor compatibility list, framework support status, and existing adaptation case studies.
- How do you choose a parallelism strategy? Weigh model size, memory capacity, network bandwidth, and training efficiency together.
- How do you verify that adaptation genuinely succeeded? Look at the number of consecutive optimizer updates, loss stability, gradient norm behavior, and the ability to recover from checkpoints.
- How do you handle out-of-memory errors? Try sharding strategies, activation checkpointing, sequence parallelism, smaller batch sizes, or gradient accumulation.
- How do you handle a training hang? Check heartbeats, communication timeouts, node load, network links, and rank assignment.
- How do you handle numerical anomalies? Check the mixed-precision configuration, gradient clipping, data batches, and operator precision implementations.
For routine troubleshooting, this order works well:
- Non-finite values: Check learning rate, gradient norm, mixed precision, and anomalous samples first.
- Out-of-memory errors: Check whether parameter sharding is complete, whether activation checkpointing is enabled, and whether optimizer states are too large.
- Hanging processes: Check whether the communication backend matches the hardware, whether nodes can reach each other, and whether timeouts are reasonable.
- Abnormal throughput: Check whether communication and computation overlap, whether there is a bandwidth bottleneck between nodes, and whether rank load is uneven.
Conclusion
Training adaptation on domestic compute for large models is not just about making code run. It is a combined test of operator correctness, distributed scalability, numerical stability, and engineering maturity. Understanding the difference between training adaptation and from-scratch pretraining, and mastering FSDP2 sharded training, configurable cross-node communication backends, explicit numerical stability test conditions, and full-stack engineering practice, is what moves domestic compute from “it trains” toward “training is stable,” and ultimately to “ready to train out of the box.”
