Skip to content

AdamW Epsilon Underflow in FP16

The default epsilon value for Adam/AdamW is 1e-8. In float16, the smallest representable positive normal number is ~5.96e-8. Thus, 1e-8 underflows to 0.0. During the optimizer update, this leads to a division by zero if the gradient variance estimate is also close to zero, producing NaNs.

Quick answer

The default epsilon value for Adam/AdamW is 1e-8.

Root cause
The default epsilon value for Adam/AdamW is 1e-8. In float16, the smallest representable positive normal number is ~5.96e-8.
Recommended fix
Increase AdamW epsilon to an FP16-safe value optimizer = torch.optim.AdamW(model.parameters(), lr=1e-3, eps=1e-5) A larger epsilon like 1e-5 or 1e-4 is representable in float16, preventing division by zero during the parameter update calculation.
How Denpex helps
Denpex matches AdamW Epsilon Underflow in FP16 across every rank in a distributed run and reports which rank failed first, so you act on the initiating node instead of the loudest one.
Optimizer#Numerical Underflow

What this failure is

AdamW Epsilon Underflow in FP16 is a Optimizer failure seen during ML training runs. The default epsilon value for Adam/AdamW is 1e-8. In float16, the smallest representable positive normal number is ~5.96e-8. Thus, 1e-8 underflows to 0.0. During the optimizer update, this leads to a division by zero if the gradient variance estimate is also close to zero, producing NaNs. Common tags: Numerical Underflow.

Live diagnosis, no signup

Is this what broke your run? Paste your log.

You're reading about AdamW Epsilon Underflow in FP16. Paste your own crash log or traceback below and get the real root cause for YOUR run, not this generic entry. No account, no card. Logs are masked at ingress and never saved to account history.

training_logs.txt
No log to hand? Try one:

3 free diagnoses/day

Want 14 days on the Scale plan?

Request an evaluation code. A verified workplace organization activates up to 50 diagnoses a day, alerts, history, and follow-up questions. No credit card or automatic subscription.

Evaluate one incident

Why it happens (the mechanism)

Engineers usually suspect exploding gradients and try to apply gradient clipping, which completely fails to fix an underflow-induced division by zero.

What you'll observe

  • Loss becomes NaN without gradient explosion
  • Optimizer state contains NaNs

Common symptoms and what they mean

SymptomWhy it happens
Gradient norm remains small and stable, but loss suddenly turns NaN.The default epsilon value for Adam/AdamW is 1e-8. In float16, the smallest representable positive normal number is ~5.96e-8. Thus, 1e-8 underflows to 0.0. During the optimizer update, this leads to a division by zero if the gradient variance estimate is also close to zero, producing NaNs.
Model crashes during the optimizer step rather than the forward/backward pass.The default epsilon value for Adam/AdamW is 1e-8. In float16, the smallest representable positive normal number is ~5.96e-8. Thus, 1e-8 underflows to 0.0. During the optimizer update, this leads to a division by zero if the gradient variance estimate is also close to zero, producing NaNs.

Which systems are affected

  • PyTorch
  • Hugging Face Transformers

How to confirm this is the problem

Use this checklist to test the hypothesis against a small reproduction. No single line proves the root cause, so preserve the preceding events and compare one variable at a time.

  • Disable AMP to see if the problem disappears.
  • Inspect optimizer parameters (`optimizer.param_groups[0]['eps']`).

The fix and the prevention pattern

The root cause is on this page and stays free. A free account adds the exact remediation steps, saved history, and the fix on every entry in the encyclopedia.

Sign up free. Unlock the full analysis

No credit card. Daily allowance follows verified trust tier. Instant access.

Diagnose this failure in VS Code

Select the traceback or open the failed terminal, then run Denpex locally to see the initiating rank, collateral failures, exact fix, and verification command without uploading the log.

Install the free VS Code extension

Root cause

  • The default epsilon value for Adam/AdamW is 1e-8. In float16, the smallest representable positive normal number is ~5.96e-8. Thus, 1e-8 underflows to 0.0. During the optimizer update, this leads to a division by zero if the gradient variance estimate is also close to zero, producing NaNs.

The fix and how to prevent it

Evaluate Denpex on your own logs

Request a Scale evaluation code. A verified workplace organization activates 14 days with up to 50 diagnoses a day. Every account keeps its current diagnosis allowance and gets a verification path. No card or automatic subscription.

We send a single-use code tied to that address. Static provider and TLD rules do not reject valid addresses. Account trust determines the benefit after signup.

Don't just read the fix, diagnose your run

The encyclopedia tells you what went wrong. Denpex tells you what went wrong in YOUR training run. With your logs, your config, and your stack.