āļ„āļđāđˆāļĄāļ·āļ­āļ—āļēāļ‡āđ€āļ—āļ„āļ™āļīāļ„

Z-Loss āđāļĨāļ°āļ„āļ§āļēāļĄāđ€āļŠāļ–āļĩāļĒāļĢāđƒāļ™āļāļēāļĢāļāļķāļāļāļ™

Z-loss is an auxiliary penalty on the log of a softmax normalization constant.

āļŸāļąāļ‡āļ„āļģāđāļ™āļ°āļ™āļģāļ™āļĩāđ‰āļšāļĢāļĢāļĒāļēāļĒāđ‚āļ”āļĒ AI · ~3 min

āļšāļ™āļŦāļ™āđ‰āļēāļ™āļĩāđ‰āļ­āđˆāļēāļ™ 3 āļ™āļēāļ—āļĩ
  1. āļ āļēāļžāļĢāļ§āļĄ
  2. āđ€āļˆāļēāļ°āļĨāļķāļ
  3. āļāļēāļĢāđƒāļŠāđ‰āļ‡āļēāļ™āļˆāļĢāļīāļ‡āđƒāļ™āđ‚āļĨāļāđāļŦāđˆāļ‡āļ„āļ§āļēāļĄāđ€āļ›āđ‡āļ™āļˆāļĢāļīāļ‡
  4. The Future of Z-Loss and Training Stability
  5. āļāļēāļĢāļ™āļģāđ„āļ›āļ›āļāļīāļšāļąāļ•āļī
  6. āļŠāļģāļĢāļ§āļˆāļ•āđˆāļ­āđ„āļ›
  7. āļ„āļģāļ–āļēāļĄāļ—āļĩāđˆāļžāļšāļšāđˆāļ­āļĒ

āļ āļēāļžāļĢāļ§āļĄ

It can discourage poorly controlled logit offsets and has been used with language-model outputs and mixture-of-experts routers. It complements the main objective; it is not a guarantee against divergence or a hard bound on every individual logit.

āđ€āļˆāļēāļ°āļĨāļķāļ

Softmax converts logits into probabilities by exponentiating them and dividing by their sum. Call that sum Z. A common z-loss term is the square of ln Z, multiplied by a coefficient and averaged over the relevant positions. Google’s T5X implementation adds such a term to cross-entropy. The name describes the normalization quantity being controlled, not a new replacement for the prediction task. The motivation becomes clearer from softmax’s shift property. Adding the same constant to every logit leaves its probabilities unchanged in exact arithmetic. Cross-entropy therefore does not identify a unique common offset for the logits. Z-loss responds to that offset because it changes ln Z. Encouraging ln Z toward zero can help control this otherwise unconstrained direction, while numerical implementation and precision still matter. For a constructed two-class example, logits [0, 0] produce equal probabilities and Z = 2. The unweighted penalty is (ln 2)Âē, about 0.48045. Subtract ln 2 from both logits and each exponential becomes 0.5. Now Z = 1, the penalty is zero, and the probabilities remain equal. Zero auxiliary loss has not made the prediction correct; it has changed the logit normalization. ST-MoE adapts this idea to router logits and reports improved stability in its tested sparse-model configurations. Its router z-loss is distinct from the load-balancing auxiliary loss that addresses expert usage. Do not treat either result as a universal guarantee. Select the coefficient and target logits deliberately, track task loss and auxiliary loss separately, and inspect held-out quality. A run can become unstable for other reasons, including optimization settings, data problems, or numerical errors elsewhere in the computation.

āļāļēāļĢāđƒāļŠāđ‰āļ‡āļēāļ™āļˆāļĢāļīāļ‡āđƒāļ™āđ‚āļĨāļāđāļŦāđˆāļ‡āļ„āļ§āļēāļĄāđ€āļ›āđ‡āļ™āļˆāļĢāļīāļ‡

For two logits [0, 0], the softmax probabilities are [0.5, 0.5], but the unweighted z-loss is (ln 2)Âē, about 0.48045.

Shifting both logits to [−ln 2, −ln 2] leaves the probabilities at [0.5, 0.5] while making the normalization constant one and the z-loss zero.

A researcher logs cross-entropy and the weighted auxiliary penalty separately so a changing total loss is not mistaken for an identical change in prediction quality.

An MoE experiment compares router z-loss coefficients while tracking training stability, task quality, and expert utilization instead of assuming one coefficient solves every routing problem.

The Future of Z-Loss and Training Stability

Auxiliary objectives will remain one option for studying numerical behavior as models and routing systems evolve. Their effects should be measured with the actual precision, optimizer, architecture, and data configuration. Keep comparisons controlled and retain separate records of stability, main-task quality, and auxiliary penalties. A lower z-loss alone is not a success metric for the application. Future implementation changes may alter the best coefficient or where the term is useful, so reproduce the relevant ablation instead of carrying over a setting without evaluation.

āļāļēāļĢāļ™āļģāđ„āļ›āļ›āļāļīāļšāļąāļ•āļī

āļ—āļģāđ„āļĄāļĄāļąāļ™āļ–āļķāļ‡āļŠāļģāļ„āļąāļ

  • āļ•āđ‰āļ™āļ—āļļāļ™āđāļĨāļ°āļ‡āļšāļ›āļĢāļ°āļĄāļēāļ“. āļāļēāļĢāļ•āļąāļ”āļŠāļīāļ™āđƒāļˆāļ”āđ‰āļēāļ™āļŠāļ–āļēāļ›āļąāļ•āļĒāļāļĢāļĢāļĄāļ‚āļąāļšāđ€āļ„āļĨāļ·āđˆāļ­āļ™āļ›āļĢāļ°āļŠāļīāļ—āļ˜āļīāļ āļēāļžāđāļĨāļ°āļ•āđ‰āļ™āļ—āļļāļ™āļāļēāļĢāļ”āļģāđ€āļ™āļīāļ™āļ‡āļēāļ™āđ€āļ›āđ‡āļ™āđ€āļ§āļĨāļēāļŦāļĨāļēāļĒāļ›āļĩ
  • āļāļēāļĢāļ•āļąāļ”āļŠāļīāļ™āđƒāļˆāļ—āļĩāđˆāļŠāļąāļ”āđ€āļˆāļ™āļĒāļīāđˆāļ‡āļ‚āļķāđ‰āļ™. āļāļēāļĢāļĻāļķāļāļĐāļēāļ”āđ‰āļēāļ™āđ€āļ—āļ„āļ™āļīāļ„āļŠāđˆāļ§āļĒāđƒāļŦāđ‰āļ—āļĩāļĄāđ€āļĨāļ·āļ­āļāļāļĨāļļāđˆāļĄāļ—āļĩāđˆāđ€āļŦāļĄāļēāļ°āļŠāļĄ āđ„āļĄāđˆāđƒāļŠāđˆāđāļ„āđˆāļāļĨāļļāđˆāļĄāđƒāļŦāļĄāđˆāļĨāđˆāļēāļŠāļļāļ”
  • āļāļēāļĢāļ„āļ§āļšāļ„āļļāļĄāļ„āļļāļ“āļ āļēāļž. āļ•āļąāļ§āđ€āļĨāļ·āļ­āļāļ—āļēāļ‡āļ§āļīāļĻāļ§āļāļĢāļĢāļĄāļ—āļĩāđˆāļ”āļĩāļāļ§āđˆāļēāļˆāļ°āļŠāđˆāļ§āļĒāļĨāļ”āđ€āļŦāļ•āļļāļāļēāļĢāļ“āđŒāļ”āđ‰āļēāļ™āļ„āļ§āļēāļĄāļ™āđˆāļēāđ€āļŠāļ·āđˆāļ­āļ–āļ·āļ­āđƒāļ™āļāļēāļĢāļœāļĨāļīāļ•

āļĢāļ°āļ§āļąāļ‡

  • āļāļēāļĢāđ€āļžāļīāđˆāļĄāļ›āļĢāļ°āļŠāļīāļ—āļ˜āļīāļ āļēāļžāđ€āļāļ“āļ‘āđŒāļĄāļēāļ•āļĢāļāļēāļ™āļŦāļ™āļķāđˆāļ‡āļĢāļēāļĒāļāļēāļĢāļŠāļēāļĄāļēāļĢāļ–āļ‹āđˆāļ­āļ™āļˆāļļāļ”āļ­āđˆāļ­āļ™āļ‚āļ­āļ‡āļĢāļ°āļšāļšāđƒāļ™āļ§āļ‡āļāļ§āđ‰āļēāļ‡āđ„āļ”āđ‰
  • āļ•āđ‰āļ™āļ—āļļāļ™āđ‚āļ„āļĢāļ‡āļŠāļĢāđ‰āļēāļ‡āļžāļ·āđ‰āļ™āļāļēāļ™āđāļĨāļ°āļāļēāļĢāļšāļģāļĢāļļāļ‡āļĢāļąāļāļĐāļēāļĄāļąāļāļ–āļđāļāļ›āļĢāļ°āđ€āļĄāļīāļ™āļ•āđˆāļģāđ„āļ›
  • āļŠāđˆāļ­āļ‡āļ§āđˆāļēāļ‡āļ”āđ‰āļēāļ™āļ„āļ§āļēāļĄāļ›āļĨāļ­āļ”āļ āļąāļĒāđāļĨāļ°āļ„āļ§āļēāļĄāļŠāļēāļĄāļēāļĢāļ–āđƒāļ™āļāļēāļĢāļŠāļąāļ‡āđ€āļāļ•āļŠāļēāļĄāļēāļĢāļ–āđ€āļžāļīāđˆāļĄāļ‚āļķāđ‰āļ™āđ„āļ”āđ‰āđ€āļĄāļ·āđˆāļ­āļĢāļ°āļšāļšāļĄāļĩāļ„āļ§āļēāļĄāļ‹āļąāļšāļ‹āđ‰āļ­āļ™āļĄāļēāļāļ‚āļķāđ‰āļ™

āļ‚āļąāđ‰āļ™āļ•āļ­āļ™āļ•āđˆāļ­āđ„āļ›

  1. āļāļģāļŦāļ™āļ”āđ€āļ›āđ‰āļēāļŦāļĄāļēāļĒāđ€āļ§āļĨāļēāđāļāļ‡ āļ„āļļāļ“āļ āļēāļž āđāļĨāļ°āļ•āđ‰āļ™āļ—āļļāļ™āļāđˆāļ­āļ™āļ™āļģāđ„āļ›āđƒāļŠāđ‰āļ‡āļēāļ™
  2. āđ€āļāļ“āļ‘āđŒāļĄāļēāļ•āļĢāļāļēāļ™āļ āļēāļĒāđƒāļ•āđ‰āļŠāļ āļēāļ§āļ°āđ‚āļŦāļĨāļ”āđāļĨāļ°āļ‚āđ‰āļ­āļĄāļđāļĨāļˆāļĢāļīāļ‡
  3. āļāļēāļĢāļ•āļĢāļ§āļˆāļŠāļ­āļšāđ€āļ„āļĢāļ·āđˆāļ­āļ‡āļĄāļ·āļ­āđ€āļžāļ·āđˆāļ­āļŦāļēāļ‚āđ‰āļ­āļœāļīāļ”āļžāļĨāļēāļ” āļāļēāļĢāđ€āļšāļĩāđˆāļĒāļ‡āđ€āļšāļ™ āđāļĨāļ°āļœāļĨāļāļĢāļ°āļ—āļšāļ•āđˆāļ­āļœāļđāđ‰āđƒāļŠāđ‰
  4. āđ€āļ•āļĢāļĩāļĒāļĄāđ€āļŠāđ‰āļ™āļ—āļēāļ‡āļāļēāļĢāļĒāđ‰āļ­āļ™āļāļĨāļąāļšāđāļĨāļ°āļāļēāļĢāļ•āļ­āļšāļŠāļ™āļ­āļ‡āļ•āđˆāļ­āđ€āļŦāļ•āļļāļāļēāļĢāļ“āđŒāļāđˆāļ­āļ™āļ›āļĢāļąāļšāļ‚āļ™āļēāļ”

āļŠāļģāļĢāļ§āļˆāļ•āđˆāļ­āđ„āļ›

āļˆāļ”āļŦāļĄāļēāļĒāļ‚āđˆāļēāļ§āļŸāļĢāļĩ

āļĢāļąāļšāļŠāļĢāļļāļ› AI āļĢāļēāļĒāļ§āļąāļ™

āđ€āļĢāļ·āđˆāļ­āļ‡āļĢāļēāļ§ AI āļ—āļĩāđˆāļ•āļĢāļ§āļˆāļŠāļ­āļšāđāļĨāđ‰āļ§ 3 āđ€āļĢāļ·āđˆāļ­āļ‡āļ—āļļāļāļ§āļąāļ™āļ—āļģāļ‡āļēāļ™ āđ€āļŠāđ‰āļē, āđ€āļ‚āļĩāļĒāļ™āđ€āļ›āđ‡āļ™āļ āļēāļĐāļēāļ­āļąāļ‡āļāļĪāļĐāļ˜āļĢāļĢāļĄāļ”āļē āļŸāļĢāļĩāļ•āļĨāļ­āļ”āđ„āļ› āđ„āļĄāđˆāļĄāļĩāđ‚āļ†āļĐāļ“āļē

āļ­āļĩāđ€āļĄāļĨāļŦāļ™āļķāđˆāļ‡āļ‰āļšāļąāļšāļ—āļļāļāļ§āļąāļ™āļ—āļģāļ‡āļēāļ™ āļĒāļāđ€āļĨāļīāļāļāļēāļĢāļŠāļĄāļąāļ„āļĢāđƒāļ™āļ„āļĨāļīāļāđ€āļ”āļĩāļĒāļ§ āđ€āļĢāļēāđ„āļĄāđˆāđ€āļ„āļĒāļ‚āļēāļĒāļŦāļĢāļ·āļ­āđāļŠāļĢāđŒāļ—āļĩāđˆāļ­āļĒāļđāđˆāļ­āļĩāđ€āļĄāļĨāļ‚āļ­āļ‡āļ„āļļāļ“

āļ—āļ”āļŠāļ­āļšāļ•āļąāļ§āđ€āļ­āļ‡

Take the Z-Loss and Training Stability quiz

āļ‚āđ‰āļ­āđ€āļŠāļ™āļ­āđāļ™āļ°āļ—āļąāļ™āļ—āļĩāļŠāļģāļŦāļĢāļąāļšāļ—āļļāļāļ„āļģāļ•āļ­āļš āđāļĨāļ°āđƒāļšāļĢāļąāļšāļĢāļ­āļ‡āļ—āļĩāđˆāļŠāļēāļĄāļēāļĢāļ–āđāļŠāļĢāđŒāđ„āļ”āđ‰āļžāļĢāđ‰āļ­āļĄ ID āļ—āļĩāđˆāļ•āļĢāļ§āļˆāļŠāļ­āļšāđ„āļ”āđ‰āđ€āļĄāļ·āđˆāļ­āļ„āļļāļ“āļœāđˆāļēāļ™āļŦāļĨāļąāļāļŠāļđāļ•āļĢ

āđ€āļĢāļīāđˆāļĄāđāļšāļšāļ—āļ”āļŠāļ­āļš

āļŠāļ™āļąāļšāļŠāļ™āļļāļ™āļāļēāļĢāļĻāļķāļāļĐāļē AI āļŸāļĢāļĩ AI Understanding āđ€āļ›āđ‡āļ™āļ­āļ‡āļ„āđŒāļāļĢāđ„āļĄāđˆāđāļŠāļ§āļ‡āļŦāļēāļœāļĨāļāļģāđ„āļĢ 501(c)(3) — āđ„āļĄāđˆāļĄāļĩāđ‚āļ†āļĐāļ“āļē āđ„āļĄāđˆāļĄāļĩāļāļģāđāļžāļ‡āđ€āļ‡āļīāļ™, āļ•āļĨāļ­āļ”āđ„āļ› āļšāļĢāļīāļˆāļēāļ„

āļ„āļģāļ–āļēāļĄāļ—āļĩāđˆāļžāļšāļšāđˆāļ­āļĒ

What is Z-Loss and Training Stability?

Z-loss is an auxiliary penalty on the log of a softmax normalization constant. It can discourage poorly controlled logit offsets and has been used with language-model outputs and mixture-of-experts routers. It complements the main objective; it is not a guarantee against divergence or a hard bound on every individual logit.

Which quantity does the common z-loss term penalize?

The guide defines the auxiliary term as Îŧ(log Z)Âē, where Z is the sum of exponentiated logits.

What happens to softmax probabilities when the same constant is added to every logit in exact arithmetic?

The common exponential factor cancels between the numerator and denominator.

For logits [0, 0], what is the unweighted z-loss?

The exponentials sum to 2, so squaring the natural logarithm gives about 0.48045.

Which equal-logit pair gives Z = 1 and zero z-loss?

Each exponential is 0.5, and 0.5 + 0.5 = 1. The probabilities are still equal.

Does zero z-loss show that a classifier predicts the right answer?

The equal-probability example reaches zero z-loss without establishing the correct class.

āđ€āļĢāļĩāļĒāļ™āļĢāļđāđ‰āļ•āđˆāļ­āđ„āļ›

āļ„āļģāđāļ™āļ°āļ™āļģāļ—āļĩāđˆāđ€āļāļĩāđˆāļĒāļ§āļ‚āđ‰āļ­āļ‡

āļ„āļģāđāļ™āļ°āļ™āļģāđ€āļžāļīāđˆāļĄāđ€āļ•āļīāļĄāļ—āļĩāđˆāđ€āļĨāļ·āļ­āļāļŠāļģāļŦāļĢāļąāļšāļŦāļąāļ§āļ‚āđ‰āļ­āļ™āļĩāđ‰

āļ•āđˆāļ­āđ„āļ›āļ„āļģāđāļ™āļ°āļ™āļģāļ•āđˆāļ­āđ„āļ›

āļāļēāļĢāđ€āļ•āļīāļĄāļ„āļļāļ“āļĨāļąāļāļĐāļ“āļ°āđāļĨāļ°āļ‚āđ‰āļ­āļĄāļđāļĨāļāļēāļĢāļāļķāļ

āđ€āļ—āļ„āļ™āļīāļ„

āļĢāļąāļšāđƒāļšāļĢāļąāļšāļĢāļ­āļ‡ AI āļŸāļĢāļĩāļŦāļĨāļąāļāļŠāļđāļ•āļĢāđāļĨāļ°āļāļēāļĢāļŠāļ­āļšāļŠāļąāđ‰āļ™ āđ† āļŸāļĢāļĩ āđ„āļĄāđˆāļĄāļĩāļ„āđˆāļēāđƒāļŠāđ‰āļˆāđˆāļēāļĒ āđ„āļĄāđˆāļĄāļĩāļšāļąāļ•āļĢāđ€āļ„āļĢāļ”āļīāļ• āļ›āļĢāļ°āļĄāļēāļ“ 2.5 āļŠāļąāđˆāļ§āđ‚āļĄāļ‡āđ€āļĢāļīāđˆāļĄāļ•āđ‰āļ™āļŸāļĢāļĩ →