Domestic GPU Adapted for Trillion-Parameter Multimodal Training

    This article documents the adaptation of a domestic GPU platform for trillion-parameter multimodal training, covering the challenges posed by dynamic sparse MoE routing, joint image-text training, and combined memory and communication pressure. It explains a unified compute graph approach built on FSDP2 sharding with communication overlap, details a dual-node 16-card test configuration and its stability results over 400 optimizer updates, and shows how gradient-level assertions verify that the vision branch is genuinely optimized. Key optimizations and the boundaries of the validation are also discussed.

    1. Background: What Trillion-Scale Multimodal Models Demand from the Training System

    As native multimodal large models have become the industry’s direction of evolution, parameter counts have reached the trillion scale and context lengths have expanded to the million-token level. These models typically combine a Mixture-of-Experts (MoE) architecture, hybrid attention mechanisms, and a vision encoding branch, along with visual understanding and tool-calling capabilities. Compared with pure language models, their training workloads show three distinct characteristics:

    • Dynamic sparsity: Expert routing and dynamic sparse retrieval mean the proportion of activated parameters per step is not fixed, so operator shapes and communication volumes fluctuate with the input.
    • Joint image-text training: The vision encoder, cross-modal projection modules, and the language backbone must be included in the same forward, backward, and parameter update flow, which lengthens the gradient backpropagation path.
    • Dual memory and communication pressure: Parameters, gradients, and optimizer states stack on top of activations from very long sequences, so per-card memory is easily exhausted, while cross-card and cross-node communication frequency rises sharply.

    Whether the training system can run stably therefore depends on the coordinated capability of the compute chips, the software stack, the parallelism strategy, and the operator library.

    2. Adaptation Approach: A Unified Compute Graph and Native Training Flow

    The core goal of this adaptation was “do not alter the model’s native semantics; only fill in backend capabilities.” The work centered on four modules — attention computation, dynamic routing, vision encoding, and cross-modal projection — wiring them into the existing training framework’s native forward, backward, and parameter update flow. The framework’s own model definitions and automatic parallelism wrappers were preserved, avoiding forked code introduced purely for adaptation.

    FSDP2 was used as the parallelism foundation: model parameters, gradients, and optimizer states are sharded across different GPUs, parameter shards are all-gathered on demand during the forward and backward phases and released immediately after computation, reducing per-card memory from “the whole model” to “a shard plus the current layer’s temporary tensors.” Cross-card and cross-node collective communication is handled by the vendor’s in-house communication library and overlapped with the compute stream to hide communication latency.

    The configuration logic can be abstracted as:

    1. # Pseudocode: sharding + communication overlap + chunked loss
    2. for step in range(total_steps):
    3. with shard_params(model): # Gather parameter shards on demand
    4. out = model(batch) # Vision tower + projector + language backbone
    5. loss = chunked_loss(out, labels) # Chunked computation to lower peak memory
    6. loss.backward() # Triggers gradient reduce-scatter during backward
    7. optimizer.step() # Update only the local optimizer shard

    3. Test Configuration and Stability Results

    The validation environment was two servers with a total of 16 flagship AI training and inference cards, forming a dual-node, 16-card topology. To cover the critical paths with limited resources, the model used a trimmed configuration: a 13-layer language backbone with 16 routed experts and Top-8 routing, while the full 27-layer vision tower and cross-modal projection modules were retained. Training data was an image-text question answering dataset, with a global batch size of 16, sequence length of 1024, and 16 training processes running synchronously.

    Results over 400 consecutive optimizer updates:

    Metric Start End
    Training loss (mean of steps 21–70 → mean of last 50 steps) 8.9365 2.1802
    Validation loss (step 100 → step 400) 6.5297 4.6873
    Peak sampled memory — 44.80 GiB

    No numerical overflow (NaN/Inf) or abnormal interruption occurred throughout, indicating that loss scaling, gradient clipping, and communication synchronization under mixed precision are self-consistent at this scale. Peak memory stayed stable at 44.80 GiB, showing that the sharding strategy and activation management left reasonable headroom.

    4. Verifying the Vision Branch Is Effective

    A common “fake training” problem in multimodal training is that the vision branch is treated only as a data input and gradients never actually flow back. Gradient-level checks are therefore required, targeting the vision tower’s image embedding layer, its first and last layers, and the cross-modal projection module. The results showed non-zero gradients and accompanying parameter updates at all of these locations, confirming that vision encoding genuinely participates in optimization rather than sitting on a bypass.

    In engineering practice, it is advisable to harden this kind of check into an assertion in the pipeline:

    1. for name, p in model.named_parameters():
    2. if "vision" in name or "projector" in name:
    3. assert p.grad is not None and p.grad.abs().sum() > 0, name

    5. Key Optimizations

    • FSDP2 combined with expert parallelism: Sharding dimensions and expert dimensions are split jointly to avoid repeatedly all-gathering routed expert parameters.
    • Parameter prefetching and gradient communication scheduling: The next layer’s parameter aggregation is issued ahead of time, and gradient reduction is overlapped with computation during the backward phase.
    • High-performance KDA operators: Operator-level fusion for the linear and sparse branches in hybrid attention reduces intermediate tensor materialization.
    • Chunked loss computation: The vocabulary dimension is split into chunks and the loss accumulated, significantly lowering peak memory at the output layer; this was actually enabled in the 400-step test, while the other three items can support larger configurations once adaptation is complete.

    6. Conclusion and Scope

    This validation used a randomly initialized trimmed configuration and constitutes a functional correctness and stability check of the training pipeline; it is not equivalent to full-scale pretraining of the complete model and does not represent final model quality. Its value lies in providing a reusable adaptation path for domestic compute: first unify the compute graph, then control memory with sharded parallelism, then improve throughput with operator and scheduling optimizations, and finally confirm training authenticity through both gradient assertions and loss curves. Enterprises planning to run training on massive-parameter multimodal models can use this to design small-step smoke tests, memory watermark monitoring, and communication bottleneck diagnosis, then scale up gradually.