Observed since 20 Oct, 19:02 UTC
No superseded metadata states collected. Unchanged observations do not create new revisions.
Adams optimizer: next-generation optimizer blending element-wise methods with matrix-aware regularization
Adams is a next-generation optimizer that blends the simplicity of element-wise methods with the stability benefits of matrix-aware regularization. It updates neural network parameters in both 1D (per-element) and 2D (per-matrix) ways, staying fast and easy to parallelize like Adam/AdamW while improving stability and generalization.
epsilon hyperparameter; truly scale-invariant per-parameter update.
Small second-moment estimates are a major source of instability and loss spikes in Adam-like methods. Adams replaces the usual preconditioned step with a bounded update using atan2:
$$ \Delta \theta \propto \text{atan2}\big(\hat m_t,\sqrt{\hat n_t}\big), $$
which:
epsilon hyperparameter,For matrix parameters $W \in \mathbb{R}^{M \times N}$, spectral norm better reflects the scale relevant to activations than the Frobenius norm. Adams therefore applies decoupled spectral weight decay (akin to AdamW’s decoupling), replacing the usual $\tfrac{1}{2}|W|_F^2$ with the spectral norm $\tfrac{1}{2}\sigma_1^2$:
spectral_norm) to approximate the top singular triplet $(u_1, \sigma_1, v_1)$.Efficiency: the spectral step adds only two GEMV operations per matrix per update, comparable to a handful of extra element-wise ops. In typical FSDP/ZeRO setups the full weight matrix is available during forward/backward, so this integrates cleanly at scale.
Recent reports suggest that fully matrix-based optimizers (e.g., Muon) can be hard to implement/parallelize broadly and often show modest end-to-end benefits on large models (~1.1x or less), despite strong stability. Meanwhile, the dominant optimizer Adam is simple and fast but prone to instability and loss spikes.
Adams asks: Can we keep Adam’s speed and simplicity while gaining matrix-level stability?
pip install adams-torch
You don’t need to manually broadcast parameters or all-reduce gradients—multi-GPU usage matches single-GPU usage. Fully compatible with torch.compile.
FSDP is not supported yet. Contributions welcome.
import os
import torch
import torch.distributed as dist
from adams import Adams_ZeRO # main optimizer
def init():
# Initialize distributed training if launched via torchrun/torch.distributed
if "LOCAL_RANK" in os.environ:
dist.init_process_group(backend="nccl")
torch.cuda.set_device(int(os.environ["LOCAL_RANK"]))
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
model = Model().to(device)
# Spectral decay applies to matrix-shaped params.
# scalar_vector_weight_decay applies standard decoupled L2 to 0D/1D params.
optimizer = Adams_ZeRO(
model.parameters(),
lr=3e-4,
weight_decay=0.1, # spectral decay for matrices
scalar_vector_weight_decay=0.1, # L2 for scalars/vectors
betas=(0.9, 0.95)
)
# Sync any internal buffers across ranks if required by your setup.
optimizer.broadcast_buffers(model.buffers())
return model, optimizer
@torch.compile # Optional: works with torch.compile
def train_step(model, optimizer, batch):
loss = model(batch) # forward; compute your loss
loss.backward() # backward
optimizer.step() # no gradient clipping needed
optimizer.zero_grad(set_to_none=True)
return loss
Care should be taken as matrix-based optimizers (e.g. Muon).
param.use_spectral_decay = False. Adams uses a separate decoupled L2 term, controlled by scalar_vector_weight_decay (default 0.1).(B, M, N). Adams treats all dimensions except the last two as batch dimensions. (P.S. In our experiments, we treat each Attention head q,k,v as separate projection matrices. E.g. there are 24 (8 head * 3) matrices in QKV proj for 8 MHA heads)epsilon. Adams can handle much larger weight decay to improve generalization, e.g. 1.0.Apache-2.0
Download counts and popularity will appear here as the collector receives them.
| Version | Published | Direct dependencies | Open version |
|---|---|---|---|
| 0.0.1 | 13 Sept 2025 | 1 |
This describes our collected data; it is not a security assessment.
Observed since 20 Oct, 19:02 UTC
No superseded metadata states collected. Unchanged observations do not create new revisions.
package:1fa09448ace59b028f5f32ceadff8f21d1a9f64f7b90979af851bc2c09187cde