Optimizer Evolution in Large-Scale Model Training: Engineering Practices

    This article examines why optimizer states become the dominant memory consumer as models scale to hundreds of billions or trillions of parameters, and compares element-wise adaptive methods with matrix-level orthogonalized updates. It includes a simplified Muon-style update implementation, outlines practical boundaries such as hybrid optimizer configurations and numerical stability, and provides a deployment checklist covering memory budgeting, small-scale validation, monitoring, and cost review for large-scale and long-context training.

    1. Where the Problem Starts: Optimizers Become the Main Memory Consumers

    As models grow from billions to hundreds of billions or even trillions of parameters, the training bottleneck is often no longer compute but GPU memory. An easily underestimated fact is that in mixed-precision training, optimizer states frequently consume more memory than the model weights themselves.

    Take element-wise adaptive optimizers as an example. To maintain an adaptive step size for each parameter, they store two statistics per parameter: the first moment and the second moment. A rough estimate makes the scale clear: with 1.6 trillion parameters, weights and gradients at 2 bytes each account for about 6.4TB. If the two optimizer states are stored in fp32 at 4 bytes each, they require about 12.8TB. In other words, optimizer states alone consume memory in the tens of terabytes.

    The engineering implications are straightforward:

    • Memory occupied by state variables leaves less room for larger batch sizes and longer context lengths.
    • Mechanisms such as sharding, offloading, and recomputation, introduced to accommodate these states, add communication and compute overhead.
    • Once training scales up, the cost curve tends to grow superlinearly.

    This is the fundamental reason matrix-level optimization has regained attention.

    2. Two Technical Paths: Element-wise Adaptation vs. Matrix-level Orthogonalization

    How the Element-wise Path Works

    Element-wise adaptive optimizers treat a weight matrix as N independent scalars. They estimate first- and second-order gradient statistics for each scalar and determine its update step size accordingly. The advantages are strong adaptivity and tolerance for sparse and noisy gradients. The costs are state overhead proportional to the parameter count and fine-grained updates that lack a global constraint on the geometry of the parameter space.

    How the Matrix-level Path Works

    Matrix-level orthogonalized updates treat the entire weight matrix as a single, indivisible high-dimensional geometric object. They first orthogonalize the matrix formed by combining the gradient and momentum, commonly using an iterative approximation such as a polynomial approximation based on several Newton-Schulz iterations, and then apply the resulting orthogonal matrix to the weights in one step.

    A useful analogy: element-wise methods act like individuals fighting separately, each requiring an individual step-size instruction; matrix-level methods first arrange the individuals into a formation and then advance them together at a unified pace. The difference in coordination overhead is obvious.

    It is worth emphasizing that orthogonalization is not merely about neatness; it has a clear mathematical motivation. It balances the scale of updates across singular directions, preventing updates from being dominated by a few principal singular directions, and thus yields more effective descent directions within the same number of steps.

    3. A Simplified Orthogonalized Update Implementation

    The following code only illustrates the computation flow. It is a simplified teaching version that omits distributed sharding, communication, and numerical stability handling:

    1. import torch
    2. def zeropower_via_newtonschulz5(G, steps: int = 5):
    3. # Normalize to avoid overflow during iteration
    4. X = G / (G.norm() + 1e-7)
    5. a, b, c = (3.4445, -4.7750, 2.0315)
    6. for _ in range(steps):
    7. A = X @ X.transpose(-1, -2)
    8. B = b * A + c * (A @ A)
    9. X = a * X + B @ X
    10. return X
    11. def muon_update(param, grad, momentum, lr=0.02, beta=0.95):
    12. # Momentum accumulation (one state only, not two)
    13. momentum.mul_(beta).add_(grad)
    14. update = zeropower_via_newtonschulz5(momentum)
    15. # Scale correction based on matrix shape; tune empirically in practice
    16. scale = max(1.0, param.size(-2) / param.size(-1)) ** 0.5
    17. param.add_(update, alpha=-lr * scale)

    From an engineering perspective, the key benefit here is that momentum requires only one state, and the orthogonalization iterations are pure matrix multiplications that can fully utilize tensor cores. The cost is several additional matrix multiplications and iterations, so measured throughput is needed to verify whether the tradeoff is worthwhile.

    4. Controversies and Boundaries: Can the Formation Go to Battle?

    The most concentrated criticism after matrix-level methods emerged is that real battlefields require skirmish lines, and whether neat formations are merely attractive but impractical. This criticism is reasonable from an engineering standpoint, and the applicable boundaries need to be defined:

    • Parameter structure: Orthogonalization is most natural for high-dimensional hidden-layer weight matrices. For 1D parameters (biases, normalization scales), embedding layers, and output heads, element-wise adaptive methods are typically still used, forming a hybrid optimizer structure.
    • Numerical stability: Iterative orthogonalization is sensitive to extreme values and requires normalization, iteration-step control, and precision strategies.
    • System overhead: Additional matrix multiplications interact with parallel sharding and communication scheduling, and the benefits may be diluted on small-scale clusters.
    • Convergence validation: Any optimizer replacement must be judged by complete training curves, downstream evaluations, and reproducible experiments, not by single-step loss alone.

    The pragmatic conclusion is therefore “hybrid usage + small-scale validation + large-scale gradual rollout,” rather than a full replacement.

    5. The Memory Bill for Million-token Long Contexts

    Memory pressure in long-context training comes mainly from three sources: activations that grow with sequence length, attention computation costs that rise rapidly with length, and communication volume from parallel sharding. Common mitigation approaches include:

    • Sequence parallelism and context parallelism, which split long sequences across more devices.
    • Chunking and recomputation of attention computation, trading compute for memory.
    • Activation recomputation, mixed precision, and memory fragmentation management.
    • More memory-efficient optimizer states, freeing up room for batch size and sequence length.

    Saving optimizer memory and supporting long contexts are not two independent matters: the memory freed by the former is precisely the budget available to the latter.

    6. Deployment Checklist

    1. Build a memory budget first: estimate weights, gradients, optimizer states, activations, and temporary buffers item by item, leaving a safety margin.
    2. Run small-scale controlled experiments: compare convergence speed, stability, and throughput under the same data and steps, and record confidence intervals.
    3. Configure a hybrid optimizer: use the matrix-level method for 2D hidden-layer weights and retain adaptive methods for other parameters.
    4. Set up monitoring and alerts: establish metrics and automatic alerts for loss spikes, gradient norms, and update scales.
    5. Elastic resources: use container platforms and object storage for checkpoint persistence, and use monitoring alerts and logging services to locate abnormal nodes.
    6. Review costs: use training cost per token and end-to-end duration as the final evaluation criteria.

    7. Conclusion

    The evolution of optimizers is essentially about “how to more intelligently decide which direction to take at each step within limited memory and limited time.” Element-wise adaptive methods win on universality and robustness, while matrix-level orthogonalized methods win on low state overhead and balanced update directions. For large-scale and long-context training, the truly reusable methodology is to account for memory as a first-class budget, use a hybrid strategy to balance robustness and efficiency, and rely on rigorous experiments as the sole judge. If you need an elastic compute and storage foundation to support such experiments, you can explore the general containers, object storage, and monitoring and alerting capabilities offered by Baidu AI Cloud.