Migrating the Training Foundation for Large Models: Engineering from General-Purpose GPUs to Domestic AI Accelerators

    This article explains why migrating a large model training foundation to domestic AI accelerators is primarily a software stack effort rather than a hardware swap. It breaks the migration into six dependency layers, examines operator and communication challenges, covers memory budgeting and numerical consistency, and outlines a phased rollout roadmap with risk considerations for long-running pretraining.

    Migrating the Training Foundation for Large Models: Engineering from General-Purpose GPUs to Domestic AI Accelerators

    1. Background: Why Switching Chips Is Not Just Swapping Hardware

    In public reports, a large model team plans to complete the pretraining of its next-generation foundation model on domestic accelerator cards. Before this, domestic compute in that setup mainly handled inference workloads and had not yet entered the pretraining stage. At the same time, the team has open-sourced a set of infrastructure components targeting domestic platforms, forming a one-to-one correspondence with the components it previously open-sourced around general-purpose GPU platforms. The technical implication of this signal is clear: the core migration effort lies not in data centers and power supply, but in the training software stack.

    Pretraining and inference place very different demands on hardware. Inference focuses on single-request latency, batch throughput, and memory usage. Pretraining is a “long run” in which thousands of cards operate continuously for weeks or even months, imposing strict requirements on the stability of collective communication, numerical reproducibility, fault recovery speed, and cluster linear scaling. As a result, using a platform validated on the inference side directly for pretraining often exposes a whole set of problems that were not previously triggered.

    2. A Six-Layer Dependency Model for Migration

    The training foundation can be abstracted into six layers, replaced and validated from top to bottom:

    1. Model and parallelism strategy layer: combinations of data parallelism, tensor parallelism, pipeline parallelism, sequence parallelism, and expert parallelism.
    2. Framework and scheduling layer: training loop, checkpointing, elastic fault tolerance, and job orchestration.
    3. Compilation and graph optimization layer: computation graph capture, operator fusion, memory planning, and automatic differentiation.
    4. Operator and math library layer: high-performance implementations of matrix multiplication, attention, normalization, and optimizer updates.
    5. Communication library layer: collective communication primitives such as all-reduce, all-gather, point-to-point, and reduce-scatter.
    6. Hardware and firmware layer: accelerator cards, inter-card interconnects, and intra-node and inter-node network topology.

    The recommended migration order is to connect layer by layer from the bottom up, then stress-test from the top down: first ensure operators and communication are correct, then validate graph optimization and parallelism strategies, and finally perform long-term stability and efficiency tuning.

    3. Operator Layer: The Main Source of Migration Cost

    High-performance matrix multiplication and attention implementations typically rely on vendor-specific programming models and memory hierarchy assumptions, such as shared memory capacity, register allocation strategies, asynchronous copies, and pipeline depth. Across platforms, these assumptions no longer hold and must be rewritten rather than ported.

    A typical attention forward pass can express its structure in pseudocode; what really needs to change during migration is the tiling and pipeline details:

    1. # Illustration: skeleton of tiled attention; cross-platform differences concentrate in tile size and pipeline scheduling
    2. for block in seq_blocks:
    3. q_tile = load_q(block) # constrained by on-chip memory capacity
    4. acc = zeros_like(q_tile)
    5. for kv in kv_blocks:
    6. k_tile, v_tile = load_kv(kv)
    7. s = matmul(q_tile, k_tile.T) * scale
    8. m_new = max(m_prev, rowmax(s))
    9. p = softmax(s - m_new)
    10. acc = acc * exp(m_prev - m_new) + matmul(p, v_tile)
    11. m_prev = m_new
    12. store(acc / rowsum)

    Practical points:

    • Build a tunable parameter table using the triple of “tile size - on-chip memory usage - pipeline stages,” and re-search for optimal values on each platform rather than copying existing configurations.
    • Establish independent correctness test cases and performance baselines for each key operator to avoid “the whole thing runs but part of it degrades.”
    • Keep interfaces stable for fused operators and encapsulate platform differences inside the implementation to reduce changes to upper-layer model code.

    4. Communication Layer: The Key to Linear Scaling

    The efficiency bottleneck in pretraining is often not compute but communication. When migrating across platforms, three things need to be rechecked: topology awareness, primitive completeness, and overlap with computation.

    • Topology awareness: hierarchical bandwidth differences among inter-card high-speed interconnects, intra-node buses, and inter-node networks determine mapping strategies such as placing tensor parallelism within a node and data parallelism across nodes.
    • Primitive completeness: the implementation quality of all-reduce, all-gather, reduce-scatter, and point-to-point, and whether they support bucketing and tiled pipelining.
    • Overlap capability: whether communication can overlap with backward computation and whether fine-grained tiling is supported, which directly affects end-to-end throughput.

    From an engineering standpoint, it is advisable to first align the parallel mapping with the real topology before discussing operator optimization; otherwise local operator speedups will be swallowed by communication waits.

    5. Memory, Parallelism, and Numerical Consistency

    The memory budget is a hard constraint. After a cross-platform move, available memory, fragmentation behavior, and caching strategies all change, so the following need to be recalculated: parameters, gradients, optimizer states, activations, communication buffers, and temporary workspaces. Common techniques include activation recomputation, optimizer state sharding, sequence parallelism to split long contexts, and offloading part of the state to host memory.

    Numerical consistency is the lifeline of long-term stable training. Differences in accumulation order, mixed-precision strategies, and normalization implementations across platforms can cause the loss curve to drift slowly. Recommendations:

    • Fix random seeds and data order, first perform short-range alignment on a small model, and compare step-by-step loss differences.
    • Define the precision strategy clearly: record the accumulation precision of matrix multiplication, the precision of gradient reduction, and the precision of optimizer master weights.
    • Set drift thresholds and automatic alerts; once exceeded, pause and locate the specific operator.

    6. Compilation, Graph Optimization, and Observability

    Operator fusion, constant folding, and memory reuse planning at the graph level differ significantly across backends. During migration, the layering of “graph capture - optimization - execution” should be preserved so that the same model definition can switch across multiple backends. Observability must also be rebuilt: training throughput, per-step time breakdown, communication ratio, peak memory usage, inter-card and inter-node bandwidth utilization, slow-node identification, and the number of failures and restarts should all be incorporated into a unified monitoring, alerting, and logging service, with a container platform used to ensure environment consistency and job orchestration.

    7. Phased Rollout Roadmap

    1. Single-card operator alignment: compare outputs and performance operator by operator, and build a baseline library.
    2. Single-node multi-card: validate collective communication correctness and inter-card interconnect efficiency.
    3. Small-scale multi-node: validate topology mapping, checkpoint read/write, and recovery from fault injection.
    4. Medium-scale convergence validation: compare loss curves and gradient norms with short-range training.
    5. Long-term stability and efficiency tuning: observe stability, throughput, and linear scaling during continuous runs.
    6. Target-scale pretraining: start the formal long run only after passing all thresholds.

    Set clear “entry/exit” criteria for each stage, such as an upper limit on operator error, an upper limit on communication ratio, and an upper limit on restart recovery time, to avoid moving to the next stage with unresolved problems.

    8. Risk Checklist

    • Ecosystem maturity: incomplete documentation, debugging tools, and performance analysis means take longer to locate problems.
    • Supply and schedule: the pace of hardware delivery and cluster construction affects the training window, so buffer time needs to be reserved.
    • Talent and experience: engineers who understand both parallelism strategies and low-level programming models are scarce.
    • Migration parallelism: maintaining old and new platforms simultaneously amplifies labor costs, so a clear switchover point is needed.

    9. Conclusion

    Betting the “next pretraining run” on domestic compute essentially shifts uncertainty from hardware to the software stack. What truly determines success is the systematic build-out of operator library completeness, communication efficiency, numerical consistency, and long-term stability operations. The takeaway for developers is that migration is not a one-time replacement but an engineering pipeline that is measurable, rollback-capable, and accepted in phases; only by quantifying the threshold of each step can risks be contained during the window of hardware turnover.