Training Optimization Practices for Open-Source Large-Scale Models

    This article examines the engineering trade-offs behind training open-source ultra-large-scale models, focusing on how optimizer state becomes the primary memory bottleneck at the trillion-parameter scale. It explains matrix-level optimization as a way to reduce state overhead, outlines the open questions around scale extrapolation and numerical stability, and shows how the saved memory can be redirected to longer context and larger batches. A practical engineering checklist is included for reproducing, continuing, or domain-adapting such models.

    1. Background: Why an Open-Source Release Matters to Engineers

    The arrival of a new generation of open-source ultra-large-scale models has brought two long-discussed research topics back to the engineering front line. The first is where to store optimizer state at the trillion-parameter scale. The second is how to actually use million-token context without exhausting GPU memory. Official technical materials usually emphasize long-context capability and overall training efficiency. For developers, however, what determines whether a model can be reproduced, further trained, or adapted to a domain through continued pre-training is whether the memory budget adds up.

    One basic fact needs to be clear first: parameter count is only the tip of the iceberg in terms of memory usage. In mixed-precision training, for example, the weights themselves, gradients, optimizer state, activations, temporary buffers, and communication buckets each occupy their own space. When the parameter scale jumps from tens of billions to trillions, these “invisible costs” shift from supporting roles to the main constraint, directly determining how much room is left for batch size and context length.

    2. The Memory Budget: Why Optimizer State Becomes the Bottleneck

    Adaptive optimizers have long been the default choice. Their core advantage is element-wise adaptivity: they maintain two statistics per parameter, the first moment and the second moment, and automatically scale the step size based on the first- and second-order information in the gradient history. This is friendly to sparse gradients and to parameters with different scales.

    The cost is equally clear: each parameter requires two additional state tensors. A rough estimate makes the problem obvious. At the trillion-parameter scale, these two states alone can occupy somewhere in the tens of terabytes under mixed precision, not counting weight copies, gradients, and activations. The result is the three most common compromises in training scripts: pushing batch size down to a very small value, cutting context length short, and making parallel partitioning extremely complex in exchange for sharded state storage.

    A schematic view of the memory composition (the numbers only illustrate the order of magnitude and are not measured):

    1. Total memory ≈ weights + gradients + optimizer state + activations + communication buffers + fragmentation headroom
    2. Optimizer state ≈ parameter count × bytes per parameter × number of states

    When the “number of states” drops from 2 to 0 or close to 0, the space saved can be converted directly into longer context or larger batches. That is the most tangible engineering benefit.

    3. Matrix-Level Optimization: From Element-Wise to Whole-Matrix Geometric Updates

    Traditional adaptive optimization treats a weight matrix as a pile of mutually independent scalars and computes a step size for each element. Matrix-level optimization instead treats the entire weight matrix as a single, indivisible high-dimensional geometric object. It orthogonalizes the matrix formed by fusing the gradient and momentum, then adds the result to the weights in one shot.

    This matters on three levels:

    1. Lower state overhead. Orthogonalization does not require keeping two statistics per parameter over the long term, so state storage is significantly reduced.
    2. More regular update directions. Orthogonalization suppresses scale differences across directions, reducing cases where “some directions take huge steps while others barely move.”
    3. Better alignment with matrix-multiply hardware. Matrix-level operations are more likely to hit high-throughput compute paths, and overlapping communication with computation becomes easier to arrange.

    An intuitive analogy: element-wise optimization is like letting each soldier decide their own stride, which is flexible but hard to keep in formation. Matrix-level optimization is like forming ranks first and then advancing at a unified pace, with lower coordination overhead. Formations are not a universal solution, of course, and that is exactly the core objection addressed in the next section.

    4. Objections and Boundaries: Small-Scale Validation Is Not Industrial Readiness

    This class of optimization was initially validated only on very small models, so three objections are common:

    • Whether scale extrapolation holds: faster convergence on small models does not guarantee stability at hundreds of billions or trillions of parameters over far more training steps.
    • Whether all parameters are suitable: a common engineering compromise is to apply matrix-level updates only to the two-dimensional weight matrices in hidden layers, while input and output embeddings, normalization parameters, and biases remain with mature element-wise adaptive methods.
    • Numerical and precision issues: orthogonalization involves matrix decomposition or iterative approximation, so low-precision stability, additional operator overhead, and compatibility with mixed precision and distributed partitioning all need dedicated handling.

    The key to industrialization, therefore, is not “swapping one optimizer.” It is putting the optimizer back into the complete training system and re-validating it there: state sharding strategy, checkpoint format, learning rate and warmup schedule, gradient clipping, and recovery mechanisms for loss spikes. Missing any one of these can bring the benefit back to zero.

    5. Long Context: Spending the Saved Memory Where It Counts

    The difficulty of million-token context lies not only in storage but also in attention complexity, which grows rapidly with sequence length. Common techniques can be combined:

    • Chunking and sparse attention to reduce the cost of global pairwise interaction;
    • Extrapolation and interpolation strategies for positional encoding to keep training stable after length extension;
    • Activation recomputation, trading compute for memory;
    • Sequence parallelism and context parallelism to split long sequences across devices;
    • Caching and streaming, with paged cache management for long conversation state on the serving side.

    The memory saved by the optimizer can be fed back precisely into the two parameters that most affect training throughput and quality, context length and batch size, forming a positive loop.

    6. A Practical Engineering改造 Checklist

    1. Build a memory budget table first: list the measured usage of the five items, weights, gradients, states, activations, and buffers, then decide on the optimizer approach.
    2. Prefer a hybrid strategy: enable matrix-level updates only for two-dimensional hidden-layer weights and keep mature methods for the remaining parameters.
    3. Validate extrapolation at small scale: align training curves at a controllable scale and observe the frequency of loss spikes and recovery time.
    4. Audit precision and operators: confirm the behavior of decomposition and iterative steps under low precision, and keep higher precision on critical paths if necessary.
    5. Checkpoint compatibility: changes to state structure affect resuming from checkpoints, so versioned formats and conversion scripts need to be designed in advance.
    6. Serving-side support: efficiency gains on the training side must carry over to the inference side. General cloud capabilities such as container platforms, object storage, message queues, logging services, and monitoring and alerting should be used to support elastic scaling and observability.

    7. Conclusion: The Real Advantage Is System-Level Efficiency

    Returning to the original question: the distinctive value of this class of open-source models is not a single number. It is that they rebalance the variables of parameter scale, optimizer state, context length, and training cost. The lesson for developers is clear: do not fixate on parameter count. Work out the memory budget first, then choose matching optimization and parallelism strategies, and finally run small-scale extrapolation validation on your own data. To build a training and inference pipeline quickly in the cloud, you can use general-purpose container, storage, and monitoring capabilities from Baidu AI Cloud to establish a reproducible, observable, and scalable engineering baseline.