Trillion-Parameter LLM Training on Domestic AI Accelerators: A Practical Adaptation Guide

    This guide covers how to adapt trillion-parameter large language model training to domestic AI accelerators. It explains how to estimate the GPU memory a trillion-parameter model needs, why communication and stability matter as much as single-GPU FLOPS, and a layered "five-layer alignment, four-step validation" methodology. It then walks through the core workflow of model loading, Fully Sharded Data Parallel (FSDP), and gradient synchronization, and addresses MoE communication, multimodal training paths, MFU-based performance evaluation, layered fault tolerance with checkpoint resume, cloud deployment, and a deployment checklist. The goal is training that is correct, stable, efficient, reproducible, and operable.

    When model size grows from hundreds of billions of parameters to trillions, training adaptation changes from “getting the code to run” to “reproducing training results correctly, stably, and efficiently on new hardware.” As requirements for compute self-sufficiency and auditable compliance keep rising, how domestic AI accelerators and a unified software stack take on trillion-parameter training has become a question every engineering team must answer. This guide offers a practical playbook covering how to estimate memory, the common mistakes when adapting domestic chips, how to tune FSDP, and how to handle MoE communication.

    Why Trillion-Parameter Training Requires Rethinking the Adaptation Approach

    The defining change of a trillion-parameter model is not simply a larger parameter count but a fundamental shift in the training paradigm. First, the memory demand of weights, gradients, and optimizer states far exceeds the capacity of a single accelerator. Second, sharding parameters produces frequent collective communication, and network bandwidth easily becomes the bottleneck. Third, a training run may last several weeks, making fault tolerance, checkpoint resume, and performance tuning hard requirements rather than nice-to-haves.

    Trillion-parameter models today generally adopt a Mixture-of-Experts (MoE) architecture. MoE uses sparse activation to reduce per-token computation, making trillion-parameter models feasible to train, but it also introduces new challenges: expert routing, capacity control, All-to-All communication, and load balancing. For domestic compute, the adaptation difficulty lies not only in the hardware’s peak FLOPS, but more in the software-hardware coordination layers: drivers, runtime, communication libraries, operator libraries, framework interfaces, numerical behavior, and long-run stability.

    Common adaptation mistakes include:

    • Estimating memory from total parameter count alone, ignoring activations, communication buffers, and memory fragmentation;
    • Focusing only on theoretical peak FLOPS while ignoring communication overhead and network topology;
    • Starting large-scale training before completing numerical alignment;
    • Having no sharded checkpointing, so a failure forces an expensive rerun from scratch.

    Given all this, the goal of trillion-parameter adaptation should be: correct, stable, efficient, reproducible, and operable.

    Estimate Memory First: How Many GPUs Does a Trillion-Parameter Model Need?

    Take a model of roughly 2.8 trillion parameters as an example. Under mixed-precision training, the base memory for parameters, gradients, and optimizer states can be estimated from bytes per parameter:

    Memory component Data type Bytes per parameter Total (approx.)
    Model weights FP16/BF16 2 5.6 TB
    Gradients FP16/BF16 2 5.6 TB
    Master weights FP32 4 11.2 TB
    First moment FP32 4 11.2 TB
    Second moment FP32 4 11.2 TB
    Total (excluding activations and temporary buffers) — 16 ~45 TB

    The above is an order-of-magnitude estimate. If a single GPU has 80 GB of memory, weights, gradients, and optimizer states alone require about 560 GPUs — before accounting for activations, checkpoints, communication buffers, memory fragmentation, and temporary framework tensors.

    In practice, budget extra headroom for:

    • Activations: strongly dependent on batch size, sequence length, number of layers, and recomputation strategy. Enabling activation recomputation can significantly reduce activation memory, at the cost of extra compute.
    • Communication buffers: All-Gather, Reduce-Scatter, and All-to-All all consume buffers; deeper prefetch needs larger buffers.
    • Memory fragmentation: sharding, dynamic shapes, variable-length sequences, and multimodal inputs all worsen fragmentation, so reserve a 10%-20% margin.
    • Host memory: if you offload parameters or optimizer states, also evaluate host memory bandwidth and PCIe pressure.

    The conclusion is clear: trillion-parameter training must rely on sharded parallelism, slicing parameters, gradients, and optimizer states across hundreds to thousands of GPUs so each holds only a part of the full model.

    Communication and Stability: Beyond Single-GPU FLOPS

    Once parameters are sharded, communication becomes the dominant cost. The high-frequency communication patterns include:

    • Parameter aggregation: before executing a layer in the forward or backward pass, All-Gather the layer’s full parameters.
    • Gradient reduction: after the backward pass, Reduce-Scatter to sum gradients.
    • Expert dispatch and return: MoE layers use All-to-All to send tokens to the devices hosting the experts and to bring results back.
    • Pipeline bubbles: pipeline parallel stages exchange activations and gradients via point-to-point transfers.

    If communication runs serially with computation, training efficiency drops noticeably. Worse, if network topology and parallel-dimension mapping are mismatched, cross-node traffic may saturate intra-node bandwidth, and All-to-All tail latency may drag down overall throughput.

    On stability: trillion-parameter training often lasts several weeks. GPU faults, node failures, and job preemption can all occur. If every failure forces a rerun from scratch, effective compute utilization drops sharply. So you must adopt a layered fault-tolerance scheme of “job-level rescheduling + shard-level resume,” always keeping the most recent checkpoint.

    Multimodal models add heterogeneous inputs, parameter grouping, loss combination, and load skew. Differences in image resolution, video frame counts, and text length cause compute imbalance across devices, requiring extra design in data batching and parallel strategy.

    A Layered Adaptation Methodology: From “Runs” to “Runs Well”

    This section draws on publicly released adaptation materials from a domestic chip vendor; for specific chip models, software stack versions, and validation timelines, refer to the vendor’s official documentation. The overall method can be summarized as “five-layer alignment, four-step validation.”

    Five-Layer Alignment

    Layer Adaptation scope Key objective
    Hardware and driver Driver, runtime, device management Devices enumerable and monitorable, memory measurable
    Collective communication Communication library, topology awareness All-Gather, Reduce-Scatter, All-to-All correct and high-performance
    Framework Device abstraction, operator registration, memory management Framework recognizes the new device without intrusion, compute graph executes correctly
    Parallel strategy Data, sharding, tensor, pipeline, and expert parallelism Memory under control, communication fully overlapped with computation
    Model and data Multimodal training path, data loading Multimodal joint training converges, stable throughput

    Four-Step Validation

    1. Numerical correctness: fix the framework version, driver version, communication-library version, dataset subset, random seed, and a reference baseline, then compare the first-step parameter update and the loss curve.
    2. Operator-level validation: compare core operators’ outputs layer by layer, watching for max absolute error, relative error, and abnormal NaN/Inf.
    3. Convergence validation: run a small proxy model or a short training run, requiring the loss trend to match the reference implementation within an acceptable threshold.
    4. Performance validation: use MFU, per-GPU throughput, communication ratio, and All-to-All latency to locate bottlenecks.

    Key Workflow: Model Loading, Fully Sharded Parallelism, and Gradient Synchronization

    Model Loading: Getting the Trillion Parameters In

    A trillion-parameter model’s weight files can be several TB. The loading stage must solve three problems:

    1. Format and layout conversion: public weights are usually split by layer or by file, while the training framework requires tensor layouts organized by device and shard. You must ensure a traceable mapping of “weight filename → tensor name → shard location.”
    2. Precision mapping: during loading, convert between FP16/BF16 and FP32 according to the training strategy, and correctly identify small parameters that must stay high precision, such as normalization-layer weights.
    3. Memory and host-memory peak control: use “meta-device initialization + layer-by-layer streaming load” — build the model structure first, then load real weights layer by layer into target shards, avoiding memory or host-memory peaks during construction.

    The following code is illustrative pseudocode showing meta-device initialization and layer-by-layer loading. build_model, shard_module, Fp32Optimizer, and save_checkpoint are custom placeholder interfaces that must be replaced with concrete framework and version implementations; the code cannot be run as-is.

    1. # Illustrative pseudocode: meta-device initialization + layer-by-layer loading to control memory peaks
    2. # Note: all interfaces below are placeholders and must be replaced with concrete framework/version implementations.
    3. # 1) Build the model structure on the meta device; no real storage is allocated yet
    4. model = build_model(config, device="meta")
    5. # 2) Shard the model across devices following the FSDP strategy
    6. model = shard_module(model, device=gpu_device, strategy="full_shard")
    7. # 3) Load real weights layer by layer into the corresponding shard
    8. for name, param in model.named_parameters():
    9. tensor = ckpt.load_tensor(name) # Read from the sharded checkpoint file
    10. tensor = convert_dtype(tensor, param.dtype) # Convert according to training precision mapping
    11. param.data.copy_(shard_of(tensor, param)) # Copy only the slice this GPU owns

    Fully Sharded Parallelism: How FSDP Works

    FSDP treats each layer of the model as an independent sharding and communication unit. A training iteration typically includes:

    1. Forward: All-Gather a layer’s parameters before executing it, and release them immediately after the computation.
    2. Backward: All-Gather the layer’s parameters again to compute gradients, then Reduce-Scatter to sum gradients.
    3. Optimizer: each GPU updates only the parameter shard it holds, and keeps only the corresponding optimizer-state slice.

    When tuning, focus on these parameters:

    Parameter Purpose Tuning recommendation
    Sharding granularity Determines communication frequency and memory layout Use the Transformer layer as the unit to reduce communication launches
    Prefetch depth Aggregates the next layer’s parameters ahead of time Increase prefetch to hide communication, but it increases memory usage
    Compute precision Forward/backward compute precision Commonly BF16/FP16, keep master weights in FP32
    Reduce precision Gradient reduction precision FP32 recommended for numerical stability at scale
    Gradient accumulation Reduces synchronization frequency Accumulate locally during the window, synchronize only at the end

    Shard Scheduling: Matching Communication to Computation

    The core of shard scheduling is “scheduling order matches execution order.” Key points:

    • Compute-graph order awareness: register shard units in the model’s actual execution order, ensuring parameters that need aggregation arrive in time.
    • Communication-computation overlap: let All-Gather and Reduce-Scatter run in parallel with backward computation, using streams and events to preserve correct dependencies.
    • Backward pre-aggregation: backward propagation has cross-layer gradient accumulation dependencies; when pre-aggregating the next layer’s parameters, manage it uniformly via flags or a parameter-aggregation context to avoid holding extra memory or reading a stale version.

    The following training loop is also illustrative pseudocode, showing the relationship between FSDP forward, backward, gradient accumulation, and local update. Actual execution requires replacing it with concrete framework interfaces.

    1. # Illustrative pseudocode: single training step under fully sharded parallelism
    2. # Assumes N=64 GPUs, each holding only 1/64 of the full model.
    3. # Note: these are placeholder interfaces and cannot be run directly.
    4. config = dict(
    5. shard_unit="transformer_block", # Use the Transformer layer as the sharding unit
    6. compute_dtype="bf16", # Forward/backward compute uses BF16
    7. param_dtype="fp32", # Sharded master weights stay in FP32
    8. reduce_dtype="fp32", # Gradient reduction uses FP32
    9. backward_prefetch=0.5, # Prefetch the next layer's parameters to hide aggregation latency
    10. )
    11. model = shard_module(model, device=gpu, strategy="full_shard", **config)
    12. opt = Fp32Optimizer(model, adamw, betas=(0.9, 0.95), eps=1e-8)
    13. for step, batch in enumerate(loader):
    14. with opt.accumulate_steps(gradient_accumulation_steps=8):
    15. loss = model(batch) # Forward: layer-by-layer All-Gather -> compute -> release
    16. (loss / 8).backward() # Backward: layer-by-layer All-Gather -> compute -> Reduce-Scatter gradients
    17. opt.clip_grad_(max_norm=1.0) # Gradient clipping is done on local shards
    18. opt.step() # Local shard update
    19. opt.zero_grad(set_to_none=True)

    Gradient Synchronization: Precision, Topology, and MoE Communication

    Gradient synchronization must consider precision, topology, and communication patterns together.

    • Reduce precision: at trillion-parameter scale, rounding error from low-precision reduction can accumulate with parameter count, so gradient reduction commonly uses FP32.
    • Topology awareness: All-Gather and Reduce-Scatter should preferably complete over the node’s high-bandwidth interconnect; gradients can first be reduced locally or partially, then summed across nodes — i.e., hierarchical reduction.
    • Gradient accumulation: skip cross-GPU reduction during accumulation and sum locally, significantly reducing communication frequency.
    • MoE’s All-to-All: under expert parallelism, the volume of token dispatch and return grows with the number of experts, sequence length, and capacity factor. To be precise, MoE typically computes target experts by top-k routing and reorders tokens; whether to deduplicate tokens depends on the specific implementation, capacity-factor policy, and communication-library design. Common practices include:
      • Setting a per-expert token cap based on the capacity factor;
      • Using drop or overflow strategies to control the tail;
      • Deduplicating tokens in some implementations to reduce repeated transfers, while allowing overflow or duplicate computation in others;
      • Overlapping All-to-All with expert computation.
    • Load balancing: early in training, experts tend to “clump,” so people often add an auxiliary load-balancing loss and routing jitter to improve balance. But this makes the communication pattern dynamic, so you should measure throughput under different batch sizes and expert counts.

    Multimodal Training Paths: Scheduling Heterogeneous Inputs

    Multimodal models usually need extra handling:

    1. Parameter grouping: the vision encoder, projection layer, and language-model backbone may use different freezing strategies, learning rates, and weight decay.
    2. Batch construction: sort by vision-token count and bucket into batches to reduce padding waste within a batch and lower load skew across devices.
    3. Loss combination: text next-token prediction and cross-modal alignment losses may coexist, needing unified scaling, backward, and reduction so that per-GPU gradients share a consistent convention.

    The following config is illustrative pseudocode showing parameter grouping, data bucketing, and multimodal loss computation.

    1. # Illustrative pseudocode: multimodal model parameter grouping and loss combination
    2. # Note: these are placeholder interfaces and must be replaced with concrete framework implementations.
    3. param_groups = [
    4. dict(params=vision_encoder.parameters(), lr=1e-5, weight_decay=0.0, freeze=True),
    5. dict(params=projector.parameters(), lr=1e-3, weight_decay=0.0),
    6. dict(params=language_model.parameters(), lr=1e-4, weight_decay=0.1),
    7. ]
    8. opt = build_optimizer(param_groups, adamw, master_dtype="fp32")
    9. buckets = token_length_bucket(image_text_pairs, max_tokens=8192)
    10. image_embeds = projector(vision_encoder(images))
    11. loss = lm_loss(input_embeds=concat(image_embeds, text_embeds), labels=labels)
    12. (loss / gradient_accumulation_steps).backward()

    Performance Evaluation: MFU and Peak FLOPS

    MFU measures how effectively the hardware’s peak compute is utilized by the model:

    1. MFU = effective model FLOPs per step ÷ (peak FLOPS per GPU × number of GPUs × time per step)

    Notes on calculating MFU:

    • The denominator should uniformly use the chip vendor’s published BF16 or FP16 dense peak FLOPS, noting whether sparse acceleration is included.
    • For MoE models, effective compute should be scaled by the activated-expert ratio or activated parameter count, not estimated directly from total parameters.
    • In large-scale training, MoE’s MFU is usually lower than a dense model’s, due to All-to-All communication, uneven expert load, and routing overhead.

    Optimization directions include: setting batch size and sequence length reasonably, adjusting the communication-computation overlap ratio, choosing a better parallel-strategy combination, and tuning the expert capacity factor and routing-balance strategy.

    Stability: Layered Fault Tolerance and Checkpoint Resume

    Adopt “job-level rescheduling + shard-level resume”:

    1. After a failure, the training framework detects the device anomaly and pauses the related tasks.
    2. The scheduler reallocates resources and launches a new process group.
    3. Each GPU restores parameters, optimizer states, and the data-loader position from the most recent sharded checkpoint.

    Checkpoint saving should be as sharded as possible, letting each GPU write its local state in parallel and avoiding a single-point bottleneck of writing tens of TB. Recovery should support re-sharding across different GPU counts.

    1. # Illustrative pseudocode: sharded checkpoint saving and elastic recovery
    2. ckpt = dict(
    3. model=model.state_dict(),
    4. optimizer=opt.state_dict(),
    5. step=step,
    6. data_loader_state=loader.state_dict()
    7. )
    8. save_checkpoint(ckpt, path=f"ckpt/step_{step}", shard="local")
    9. state = load_checkpoint(path, world_size=current_world_size)
    10. model.load_state_dict(state["model"])
    11. opt.load_state_dict(state["optimizer"])

    Cloud Deployment: From Self-Hosted Clusters to Elastic Training

    Enterprises training at trillion-parameter scale don’t necessarily need to build a complete cluster up front. They can leverage mainstream cloud platforms for elastic training:

    • Compute layer: provision heterogeneous compute instances on demand, with RDMA high-speed networks between nodes to meet All-Gather and All-to-All bandwidth needs.
    • Storage layer: keep training data and checkpoints in high-throughput object storage, with the data loader prefetching in batches to avoid small-file random reads slowing training.
    • Scheduling layer: use a container platform to orchestrate distributed training jobs, with automatic rescheduling on failure.
    • Observability layer: use log services and monitoring/alerting to continuously collect GPU utilization, memory, communication latency, and the loss curve.
    • Inference side: models produced by training can be deployed as online inference services, with auto-scaling to control inference cost.

    On compliance: training data should have a clear authorized source and a traceable data inventory; before release, the model should undergo any required compliance review or assessment; content-safety capabilities can help reduce output risk.

    Deployment Checklist

    Stage Check item Acceptance criteria
    Pre-adaptation Memory accounting, parallel-strategy planning, network-topology matching Theoretical memory has headroom, communication volume matches network capacity
    Loading Weight conversion, precision mapping, sampling comparison Parameter error within tolerance, mapping traceable
    Training Numerical validation, convergence validation, logging Loss curve matches reference trend, no abnormal NaN/Inf
    Tuning MFU, communication ratio, expert load Bottleneck identified, one round of targeted optimization completed
    Runtime Checkpoints, monitoring, fault tolerance Checkpoint resume capability, key metrics observable
    Compliance Data authorization, traceable inventory, filing/assessment, content safety Training data sources clear, launch process meets compliance

    Conclusion

    Adapting trillion-parameter models to domestic compute is not a single-point operator swap but systems engineering spanning memory, communication, parallel strategy, numerical stability, fault tolerance, and compliance governance. For developers and enterprises, the critical path can be summarized as:

    • Use fully sharded parallelism to solve the memory bottleneck;
    • Use topology awareness and communication-computation overlap to solve the communication bottleneck;
    • Use numerical validation and sharded fault tolerance to ensure long-term stability;
    • Use MFU, communication ratio, and expert-load metrics to drive continuous tuning;
    • Use data authorization, traceability, and compliance review to ensure compliant deployment.

    Grasping the methodology of “layered adaptation, four-step validation, metrics-driven, compliance-first” turns trillion-parameter training from a one-off engineering attempt into a sustainable, repeatable production practice.