Memory Optimization in Large-Scale Training: How Matrix-Level Orthogonalization Evolves Optimizers

    This article examines why optimizer states become a primary memory bottleneck in trillion-parameter training and how matrix-level orthogonalization offers a different optimization paradigm. It compares element-wise adaptive methods with matrix-level approaches, outlines key engineering requirements for scaling to production—including hybrid optimizer orchestration, parallel sharding consistency, precision strategy, memory and recomputation trade-offs, and stability guardrails—and explains how to evaluate real-world gains in memory, throughput, and time to target loss.

    1. The Starting Point: Optimizer States Are Consuming the Training Budget

    In large-scale model training, GPU memory is often the first resource to hit its limit. Take mainstream adaptive optimization methods as an example: to maintain a first moment and a second moment for every parameter, they must store two additional state tensors on the same order of magnitude as the parameters themselves. When the parameter count reaches the trillion scale, even with mixed precision, the state variables alone can occupy memory in the tens of terabytes. This directly compresses the available batch size and context length, reduces throughput, increases the share of communication, and significantly inflates training costs.

    The root of the problem is that adaptive optimizers trade stability in convergence for a “one ledger per element” approach, and the storage and update cost of that ledger grows linearly with the number of parameters. As a result, the industry has begun pursuing two cost-reduction paths: compressing the states themselves (low-rank, sparse, or low-precision storage), and changing the granularity of optimization from element-wise updates to matrix-level updates.

    2. Differences Between the Two Optimization Paradigms

    Element-wise adaptive methods treat a weight matrix as a large collection of unrelated scalars. Each one maintains its own momentum and second-order statistics, and the gradients are scaled point by point. The advantage is strong anisotropic adaptation, which is friendly to sparse gradients or gradients with large scale differences. The drawbacks are heavy state overhead, fragmented update operators, and memory-access-intensive operations.

    Matrix-level orthogonalization methods treat the entire weight matrix as a single, indivisible high-dimensional geometric object. They first orthogonalize the “matrix formed by fusing the gradient and momentum,” then add it to the weights in one shot. An intuitive analogy: the former is like scattered skirmishers fighting independently, each needing an individual step-size command; the latter is like a formation marching in ranks, first arranging the formation and then advancing together, with lower command overhead. Orthogonalization suppresses the over-amplification of certain directions in the update, making the effective step size more balanced. In small- and medium-scale racing experiments, this often shows a noticeable reduction in the number of steps required to reach a target loss.

    The boundary needs to be emphasized: matrix-level methods mainly act on the two-dimensional weights of hidden layers. The embedding layer, output head, normalization parameters, biases, and others are usually still handled by adaptive methods, forming a hybrid optimization strategy. At the same time, the extra matrix operations introduced by orthogonalization bring computational overhead, which must be weighed against the memory and step savings.

    3. Key Engineering Points for Moving from Small and Medium Scale to Industrial Scale

    1. Hybrid optimizer orchestration. Dispatch optimizers by parameter dimensionality, and avoid orthogonalizing one-dimensional parameters; tag parameters at the registration stage to reduce runtime checks.
    2. Parallel sharding consistency. Tensor parallelism splits matrices into blocks, while orthogonalization is a global operation. It requires correct collective communication along the sharded dimension, or completion on the replica dimension before sharding; otherwise the semantics will deviate.
    3. Precision strategy. Orthogonalization iterations are sensitive to numerical range. It is recommended to perform this step in higher precision and then fall back to low-precision accumulation, to prevent updates from being swallowed by quantization noise.
    4. Memory and recomputation balance. The saved state memory can be reinvested into larger batches and longer contexts, but the activation memory and the computational cost of recomputation must be evaluated at the same time.
    5. Stability guardrails. Retain gradient clipping, update-norm monitoring, and loss-spike rollback mechanisms, especially when switching optimizers or adjusting the learning rate schedule.

    Illustrative pseudocode:

    1. for step, batch in enumerate(loader):
    2. grads = backward(loss(model(batch)))
    3. for name, p in model.named_parameters():
    4. if p.ndim == 2 and is_hidden(name):
    5. m = momentum(p, grads[name]) # Only one momentum state
    6. u = orthogonalize(m) # Matrix-level orthogonalization
    7. p.add_(u, alpha=-lr * scale(p.shape)) # Unified step-size addition
    8. else:
    9. adam_step(p, grads[name]) # One-dimensional and special layers

    4. Real-World Gains and Evaluation Methods

    The gains mainly appear in three places: state memory drops from two copies to roughly one, freeing up batch size and context length; there are fewer update operators and more regular memory access, improving single-step efficiency; and the number of steps required to reach the target loss decreases, shortening total runtime. For evaluation, fix the data and random seed, and separately record peak memory, single-step time, the number of steps to reach the target loss, and total machine hours, and extrapolate across multiple scales to avoid drawing conclusions only from small models.

    In cloud practice, training tasks can be orchestrated with a container platform, checkpoints and datasets can be hosted on object storage, and monitoring alerts and log services can be used to observe memory, throughput, and loss curves, enabling fast failure localization and controllable costs. Overall, matrix-level orthogonalization optimization is an effective way to turn “optimizer states” from a memory bottleneck into a schedulable resource, but success depends on the systematic design of parallel semantics, precision, and stability guardrails.