After so many related blog posts, many readers are likely already familiar with the Muon optimizer—even if the theoretical details remain hazy, it has probably left the impression of being an "optimizer tailored specifically for matrix parameters." However, this statement is not entirely accurate: for instance, for the embedding layer on the input side and the LM head on the output side, although their parameters are also matrices, they are not well-suited for Muon (see "A Guide to the Muon Optimizer: Quick Start and Key Details").
Why do they receive such "special treatment"? In this post, we will adopt the three stability metrics proposed in the opening article to explore the initialization rules for different types of layers and their corresponding steepest descent directions, thereby answering this question.
Recap #
In the first article, Beyond MuP, Part 1: Three Characteristics of a Good Model, we proposed three stability metrics:
All three metrics share a unified format: compute the RMS of the output, and then take the
Because the domain of
Steepest descent is not a new concept; it answers the question of "what optimizer should be used given a stability metric," whereas the core contribution of the "Beyond MuP" series is answering the question of "what stability metric should be used," providing calculation formulas for stability metrics that apply to arbitrary layers.
The Embedding Layer #
Now let us consider the embedding layer, which is arguably the simplest layer: the input is an index
Notice that "dependency stability" is absent here, because the inputs to an embedding layer are discrete token IDs, and two IDs cannot be subtracted. Of course, one could force the calculation by converting them into one-hot vectors, but that brings no new information; moreover, from the perspective of backpropagation, we do not need to backpropagate into token IDs any further, so there is no need to consider their stability.
The remaining two stability results are the maximum row norm of
To find the steepest descent for an embedding layer, we need to solve the optimization problem
This problem is actually straightforward to solve; we only need to apply the Cauchy-Schwarz inequality:
Equality holds at
The Output Head #
Next, let us look at the LM head. On the surface, this is also a linear layer, whose input is
Responsible for the Loss #
The answer is that the LM head needs to be "responsible" for the loss.
Note that steepest descent serves training. From an inference perspective, the model takes several tokens as input to predict the next token; but from a training perspective, the true "model" is: taking several tokens and the next token as input to compute the loss. That is, both data and labels are actually inputs, and the true output is in fact the loss. For preceding layers, we can disregard labels and the loss, but the LM head, as the final layer "bordering" the loss, cannot avoid taking into account the effects of labels and the loss.
Therefore, the input to the LM head becomes
where
Forward Stability #
First is the relatively simple forward stability; by straightforward relaxation, we have
Therefore,
If we omit the constant
An Important Inequality #
As for the remaining two metrics, because they involve taking differences, computing them is somewhat more complex. We first prove an inequality that will be used:
The proof is not difficult, but requires a bit of technique: denote the right-hand side by
This proves that
By symmetry, swapping
Dependency Stability #
Using inequality
Therefore,
The result is cut from the same cloth as forward stability. The calculation here is similar to that for the embedding layer: because the label
Update Stability #
Finally, regarding update stability, we again apply inequality
Therefore,
It is not hard to see that the three stability metrics of the LM Head are essentially identical to those of the Embedding layer: both are the maximum row/column norm of the parameter matrix or its increment. This means that the steepest descent for the LM Head is also Normalized SGD, with the difference being that the LM Head applies column-wise RMS Norm. In addition, all three metrics for the LM Head are multiplied by
Other modules #
Besides linear layers, the Embedding layer, and the LM Head, common Transformer models usually include several other parameters or layers that need to be analyzed separately. Let us review them one by one here.
Hadamard product #
As we know, after RMS Norm, there is usually a multiplication by a
We could systematically compute the three stability metrics for
According to the previous article,
As for the optimizer, let the gradient of
Linear Bias Term #
Traditional linear layers usually also have a bias vector
After adding the bias vector, the three stability metrics are
Among them, dependency stability is identical to the case without bias, so we only need to look at forward stability and update stability. For simplicity, we use the inequality
Similarly,
Attention Scaling #
Using the forward stability metric, we can also re-derive the scaling factor of the Attention mechanism. Let
Here,
Which one is actually correct? In fact, both are.
In fact, constrained by Flash Attention, the design space for Head Dim is quite limited: it is typically 128 and generally at most 256. Therefore, in practice there is almost no issue of transferring parameters across Head Dim, so this result is mostly purely theoretical.
Summary #
Finally, the main results of these two posts are summarized as follows:
Among them, the steepest descent directions for the Embedding and LM Head are row-wise and column-wise Normalized SGD, respectively, which is consistent with works such as Scion; as for the transfer rules for variance and learning rates, they agree with the conclusions of MuP. In these two posts, however, all of them are derived based on the "three stability metrics" we proposed, indicating that we have indeed found a unified form of stability measurement for arbitrary layers.