Adapting Qwen 3.7-2.8T Open-Source Flagship Models to Domestic GPUs: A Complete FSDP2 Training Guide

    This article examines the engineering behind training a 2.8-trillion-parameter multimodal open-source flagship model on domestic GPUs through a native FSDP2 (Fully Sharded Data Parallel) path. It walks through the memory, communication, and scheduling constraints of trillion-parameter training, explains why a native FSDP2 approach is more sustainable than patching around external tools, and breaks down the full adaptation pipeline—from model loading and sharded scheduling to precision strategy, gradient synchronization, checkpointing, fault tolerance, data pipelines, and observability. It closes with staged correctness validation, performance-tuning guidance, and a practical checklist for before, during, and after training.

    When open-source models cross into the trillion-parameter range, “can we train it” stops being purely an algorithmic question and becomes a systems-engineering problem spanning memory, communication, scheduling, and fault tolerance. This article uses the practice of training a 2.8-trillion-parameter multimodal open-source flagship model natively with FSDP2 on domestic GPUs as its backdrop. Without reference to any specific vendor or product, it systematically lays out the methodology and engineering essentials for adapting trillion-parameter training.

    1. Background: Trillion-Parameter Training Is Becoming Routine

    1.1 What happened

    Recently, an open-source community released a flagship multimodal model with roughly 2.8 trillion parameters and opened its weights. A domestic GPU vendor built training support for this model on its flagship training-and-inference accelerator and in-house software stack, establishing a native FSDP2 multimodal training path that connects the full pipeline—from model loading and sharded scheduling to gradient synchronization.

    1.2 Why it matters

    • Open source and hardware advancing on two fronts. Open-weight ultra-large-scale models give universities, small and mid-sized teams, and even individuals a chance to participate in continued pre-training, fine-tuning, and secondary development.
    • Domestic compute becomes trainable. Moving from “can infer” to “can train,” and then to “natively supports mainstream parallelism paradigms,” signals that domestic compute is shifting from a validation phase toward scaled production.
    • The engineering paradigm is changing. The focus of training adaptation is moving from “patching things until the program runs” toward “systematic adaptation built on a parallel framework’s native path.”

    1.3 Three questions this article answers

    • What are the core constraints of trillion-parameter training?
    • Why is a “native FSDP2 path” more sustainable than patching around the periphery?
    • What stages should a complete training adaptation include, and what checks must it pass?

    2. First Principles: Do the Math Before You Adapt

    2.1 The memory ledger: static cost at trillion-parameter scale

    For the AdamW optimizer commonly used in mixed-precision training, the approximate memory required per parameter is:

    Item Typical Precision Bytes per Parameter (Est.)
    Model parameters BF16 2
    Gradients BF16/FP32 2–4
    Master weight copy FP32 4
    First moment (m) FP32 4
    Second moment (v) FP32 4
    Total — ~16–18

    Estimating for 2.8 trillion parameters:

    • Model, gradients, and optimizer states alone require roughly 44.8–50.4 TB of memory.
    • Adding forward activations, temporary buffers, and memory fragmentation, actual usage is typically even higher.

    Even with 512 accelerators each holding 80 GB, the theoretical total of about 40 TB cannot fit the static states alone. This shows that trillion-parameter training has never been a “single-card or multi-card” problem; it is a system of memory, compute, and communication that must be co-designed.

    2.2 Additional variables from multimodality

    A pure language model’s memory footprint is relatively predictable. Multimodal models introduce several sources of uncertainty:

    • Vision side: High-resolution images are split into large numbers of tiles, and video adds a temporal dimension, so visual token counts can far exceed text token counts. Self-attention cost grows quadratically with sequence length, and the vision encoder’s activations often become the main source of memory peaks.
    • Data side: If image decoding, scaling, and augmentation all happen synchronously on the CPU, GPUs easily end up starved and idle.
    • Shape side: Resolution, tile count, and video frame count change across training stages, so the computation graph’s shape keeps shifting and repeatedly triggers recompilation.

    2.3 The communication ledger

    Once the model is sharded, parameters must be aggregated before computation and reduced after backpropagation, so memory pressure turns into communication pressure. The core of parallel-strategy design is confining high-volume, high-frequency operations to the highest-bandwidth region. In typical hardware topologies, intra-node interconnect bandwidth is far higher than cross-node network bandwidth, which is why “how parallel dimensions map onto the physical topology” must be answered first.

    2.4 Parameter count is only one difficulty

    Total parameter count does not directly reflect training difficulty. In models using a sparse expert structure, the parameters actually activated per token are usually only a fraction of the total. Yet all expert parameters must stay resident in memory and be repeatedly swapped in and out during routing. The core challenges of such models are:

    • All-to-all communication introduced by expert parallelism;
    • Dynamic shapes caused by load balancing;
    • Load skew caused by sparse routing.

    3. Paradigm Evolution: Why Choose the Native FSDP2 Path

    3.1 From data parallelism to sharded data parallelism

    In traditional data parallelism, each card holds the full model and only gradients are globally reduced, so memory cannot be amortized as the cluster scales. Sharded data parallelism (FSDP), centered on “parameter sharding,” evenly partitions parameters, gradients, and optimizer states across the cards in the same parallel group:

    • Before forward computation, the current layer’s parameters are aggregated on demand;
    • They are released immediately after computation completes;
    • During backpropagation, they are re-aggregated, then gradients are synchronized via a “scatter–reduce” scheme;
    • Each card always holds only a small fraction of the full parameters.

    3.2 First-generation implementation vs. second-generation approach

    Early sharded data parallelism flattened a group of parameters into a single flat tensor before sharding it as a whole. The advantage is efficient communication, but the limitations are:

    • Parameter names, shapes, and shard positions are hard to obtain directly, which constrains combination with structured parallelism;
    • Custom framework operators, quantization, or sparsification changes struggle to act precisely on a specific parameter.

    The second-generation approach (commonly known in the industry as FSDP2) uses “sharded tensors” as an explicit carrier for parameter sharding and scheduling:

    • Parameters keep their original names and shapes logically, with a visible, queryable sharding layout;
    • They combine more naturally with structured methods such as tensor parallelism and expert parallelism;
    • They connect more easily with toolchains like computation-graph compilation and checkpoint saving.

    This is why the industry treats native FSDP2 as the “foundation” for trillion-parameter training.

    3.3 Adaptation is layered engineering

    Training adaptation for domestic accelerators typically splits into three layers:

    Layer Core Question Typical Work
    Hardware & operator layer Is each operator correct and fast Operator implementation and precision alignment; communication libraries and collective communication primitives
    Framework & parallelism layer Can large models be sharded and run stably Parallel strategy, sharded scheduling, checkpoints and fault tolerance
    Training strategy layer Does the model learn well Precision modes, learning-rate scheduling, data mixture

    In practice, “single-operator precision alignment” and “stability at ten-thousand-card scale” are often harder to solve than “peak compute.”

    4. Breaking Down the End-to-End Training Pipeline

    A reproducible, evolvable training adaptation should cover at least the following seven stages.

    4.1 Model loading: from “full load on every card” to “metadata first, shard on demand”

    Problems with the naive approach: When loading model weights in a conventional saved format, each card must read the complete weights, then split and discard most of them. With weights at the tens-of-TB scale, this brings three-fold overhead:

    • Loading takes hours;
    • Host memory comes under enormous pressure;
    • Storage bandwidth is multiplied.

    Recommended flow:

    1. Build the model structure on a “meta device” based on the model config, recording only tensor shapes without allocating real memory;
    2. Read the checkpoint index and compute the shard range this card is responsible for;
    3. Read only the data blocks this card needs;
    4. Load the shards directly into the corresponding parameters;
    5. Apply sharding wrappers to the model.

    Illustrative code (pseudocode, expressing intent only):

    1. # 1) Metadata first: build structure only, no memory allocation
    2. with device("meta"):
    3. model = build_model_from_config(cfg)
    4. # 2) Compute and read the shard this card owns, by current rank
    5. shard_plan = plan_shard(model, ckpt_index, rank, world_size)
    6. local_tensors = load_slices(ckpt_index, shard_plan)
    7. # 3) Load shard + validate structure
    8. load_shard(model, local_tensors, assign=True, strict=True)
    9. # 4) Apply sharded parallelism (illustrative)
    10. fully_shard(model, mesh=device_mesh, mp_policy=mixed_precision_policy)

    Here, strict=True in step 3 means strict validation: any missing or extra parameter keys raise an error immediately, preventing shape mismatches from surfacing only midway through training.

    4.2 Sharded scheduling and parallel strategy: balancing communication and memory

    Common parallel dimensions and their mapping suggestions:

    Dimension Sharding Target Main Communication Mapping Suggestion
    Tensor parallelism Weight matrices within a single layer Intra-layer aggregation (high frequency) Prefer intra-node high-bandwidth interconnect
    Expert parallelism Sparse expert layers Routing all-to-all Combine with data parallelism and tensor parallelism
    Pipeline parallelism Layers divided into stages Point-to-point between adjacent stages Suits cross-node; needs a reasonable micro-batch count
    Sharded data parallelism Parameters, gradients, optimizer states Parameter aggregation; gradient scatter-reduce Usually outermost; can layer a “shard + replica” secondary structure

    Three key points:

    1. Prioritize high bandwidth. Confine the most communication-intensive dimension to within a node as much as possible.
    2. Reduce redundant replicas. When data-parallel replica count exceeds the model-parallel degree, enable a two-level “shard within node, replicate across nodes” structure that balances memory and communication efficiency.
    3. Tune parameter scale and micro-batch size together. The larger the model, the more significant the parameter-aggregation cost of a single shard unit, so weigh the compute-to-communication overlap ratio against micro-batch size.

    4.3 Precision strategy: balancing stability and efficiency

    • Mixed precision: Use BF16/FP16 for computation, and prefer FP32 accumulation for gradient reduction to limit numerical error accumulation during large-scale reduction.
    • Optimizer states: Keep them in FP32. Master weights are likewise maintained in FP32 and converted back to low precision after each update.
    • Attention implementation: Use memory-friendly attention operators, and apply document masking for variable-length samples so unrelated samples do not “see” each other.
    • Gradient clipping: Must compute the global gradient norm under sharded semantics. Local clipping and global clipping yield different results, a common misalignment point during precision alignment.

    4.4 Gradient synchronization: both correct and efficient

    Using a typical sharded data parallel backward flow as an example:

    1. # Illustrative code: gradient synchronization under sharded semantics
    2. for layer in reversed(model.layers):
    3. # If the parameter shards needed for backward are freed, re-aggregate
    4. params = all_gather(layer.params)
    5. # Compute gradients; by default keep only the gradient shard this card owns
    6. grad_shard = backward(layer, params)
    7. # Reduce-sum gradient shards across cards
    8. grad_shard = reduce_scatter(grad_shard, op="sum", dtype=float32)
    9. # Apply updates only on the parameter shard this card owns
    10. optimizer.step(layer.params_shard, grad_shard)

    A few details that are easy to get wrong:

    • Gradient accumulation: Gradients across multiple micro-batches should be accumulated locally, with cross-card reduction performed only on the final micro-batch; otherwise communication volume multiplies.
    • Update scope: Parameter updates must act only on the shard the card holds. Writing code that iterates over the “full parameters” directly causes repeated updates or incorrect results in a multi-card setting.
    • Optimizer-state alignment: Optimizer states must correspond one-to-one with parameters in sharded form; otherwise training cannot resume correctly.

    4.5 Checkpoints and fault tolerance: the lifeline of large-scale training

    Checkpoint design essentials:

    • Decouple format from layout: Save logical shards rather than physical device numbers, making it easier to continue training after changing the parallel configuration.
    • Atomic writes: Write to a temporary directory first, then atomically rename after everything completes, avoiding a half-written, corrupted checkpoint if the system crashes.
    • Asynchronous saving: Move disk writes to a background process to reduce training pauses, but ensure the previous save finishes before the next begins.
    • Inference-format export: After training, merge the sharded weights into a standard format for inference engines to load.

    Resume-consistency checklist: Besides model and optimizer states, save and restore the following:

    • Learning-rate scheduler progress;
    • Data sampler cursor;
    • Random number generator states;
    • Gradient accumulation count.

    Omitting any one can cause the loss curve to “jump” after resuming.

    Failure recovery: Common mechanisms include:

    • Readiness checks: begin training only when all members are healthy;
    • Collective communication timeouts: quickly identify “stuck” members;
    • Heartbeat detection: promptly detect unreachable nodes;
    • Periodic saving and automatic restart.

    4.6 Data pipeline: don’t let GPUs wait for input

    • Move decoding forward: Perform vision data decoding and augmentation in the data-loading process or preprocessing stage as much as possible.
    • Bucket by shape: Group samples with similar resolution and tile counts into the same batch to reduce repeated compilation and memory fluctuation.
    • Load balancing: Pre-compute the sampling order based on the data distribution so each card and each expert carries a similar load per step, reducing pipeline “bubbles.”
    • Caching strategy: For frequently accessed datasets, use a shared file system or local caching to ease storage pressure.

    4.7 Observability: make problems locatable

    Collect at least the following metrics during training:

    • Training quality: loss, gradient norm, parameter update magnitude;
    • Performance: tokens processed per second, compute-communication overlap ratio, per-stage timing;
    • Resources: memory usage, intra-node interconnect bandwidth utilization, network bandwidth utilization;
    • Stability: recompilation count, slow-node flags, checkpoint duration.

    With metric collection and alerting configured, anomalies such as “slowdowns” and “hangs” can be detected outside the training process itself.

    5. Correctness Validation and Performance Tuning

    5.1 Staged validation: align first, then accelerate

    Stage Method Pass Criteria
    Operator-level Compare against a reference implementation Error within a preset threshold
    Single-step Fixed input; compare parameter diff before/after Single-card and multi-card update results consistent (allowing float error)
    Convergence Overfit a small batch of data Loss drops noticeably within the expected number of steps
    Scale-level Scale up and compare loss curves Basically overlaps the baseline curve, with no spikes or plateaus

    5.2 Performance tuning

    • Profile before optimizing. Use performance-profiling tools to separate the shares of compute, communication, and data loading, avoiding “gut-feel” tuning.
    • Overlap vs. offload tradeoffs. If parameter aggregation and gradient reduction do not fully overlap with computation, increase the shard unit size, adjust bucketing, or offload optimizer-state updates to host memory. The latter trades bandwidth for memory and requires measurement to judge whether it pays off.
    • Recomputation strategy. Activation recomputation significantly lowers memory peaks but adds compute; prioritize recomputing parts like attention that are cheap to compute but expensive in memory.
    • Fragmentation control. When long training runs hit “enough total memory but allocation fails,” it is usually related to fragmentation, which memory-allocation strategies can mitigate.
    • Shape control. Controlling the number and variety of computation-graph shapes significantly reduces repeated-compilation overhead.

    5.3 Stability engineering

    • Pre-release stress testing: Run continuous long training and observe whether memory and performance curves stay stable.
    • Fault drills: Proactively disconnect some members or limit bandwidth to verify that timeout detection and automatic recovery work.
    • Capacity planning: Reserve ample space for checkpoint storage, logs, and metrics. A single checkpoint of a trillion-parameter model can reach tens of TB, so plan tiered storage (high-speed and low-cost tiers) and cleanup policies.

    6. Deployment Checklist

    Before training:

    • Memory and communication bandwidth budgets are estimated, and cluster scale and parallel topology are decided
    • The mapping between parallel strategy and physical topology is verified
    • Operator precision comparisons pass, with key-operator error within threshold
    • Single-step updates yield consistent results on single-card and multi-card setups

    During training:

    • Loss curve is smooth and basically consistent with a same-scale baseline
    • Tokens per second and per-stage timing are stable, with no persistent upward drift
    • Memory usage is stable, with no continuous growth
    • Metric collection and alerting pipelines run normally

    After training:

    • Resume testing passes, with no loss jump after recovery
    • Checkpoints can migrate across different parallel configurations
    • Standard-format weights export successfully and pass inference-side loading verification

    7. Conclusion: From “It Runs” to “Stable and Fast”

    The meeting of trillion-parameter open-source models and domestic compute marks the entry of large-model training adaptation into a systematic phase. The value of a native FSDP2 training path lies not just in getting things to run, but in providing a reproducible, portable, and continuously evolvable engineering foundation.

    For engineering teams, three main threads are worth holding onto:

    1. Memory is the first constraint. Every parallel and optimization strategy should return to the starting point of “doing the math.”
    2. Native beats patched. Try to let hardware and operator capabilities be scheduled by the framework through standard paths, rather than relying on local hacks.
    3. Observability and fault tolerance set the scale ceiling. Getting a single card to run is just the start; stable long runs are the goal.

    At the scale of thousands or tens of thousands of cards, what often determines a project’s success is not peak compute but the engineering capability to be “reproducible, portable, and sustainable.” For hands-on implementation, you can also draw on general-purpose capabilities from platforms such as Baidu AI Cloud—elastic compute, containerization, object storage, and monitoring/alerting—to build the training pipeline, leaving more energy for the model and data themselves.