Repository navigation
Advanced Optimizers v2.5
Note
WIP, for upcoming update
These are optimizers equipped with the newest, advanced techniques and methods from academic research papers.
- Suffixed with
_advin the UI.
Every feature should work independently, but using multiple features simultaneously is experimental, as they may interact in beneficial or detrimental ways.
-
SinkSGD_adv: Added a powerful new optimizer to the lineup, using Sinkhorn iterative normalization for well-conditioned updates (arxiv: 2502.06742). - Spectral Scaling: Now available across all optimizers, achieving width/rank invariant updates for highly stable training. Same LR for all LoRA ranks (requires alpha=rank)
-
Granular State Precision: Drastically reduce memory overhead with new optimizer state modes:
factored(Rank-2 factored mode),fp32(Full FP32 precision),bf16_sr&int8_sr(BF16/Int8 with Stochastic Rounding). -
Factored Second Moment: Available for all Adam variants. Works seamlessly alongside any
state_precisionsetting to further slash memory usage. -
Universal Nesterov Momentum: Nesterov momentum (
nesterov) and a dedicated coefficient (nesterov_coef) are now available across all optimizers. Replacing Simplified AdEMAMix. -
New OrthoGrad modes: Standard OrthoGrad
flattenedand a new matrix-wise modeiterative. -
Centered Weight Decay: Pulls weights toward their pre-train state (anchor). To save memory, anchor precision (
centered_wd_mode) can be set to full, float8, int8, or int4.
| Optimizer | Description | Best For |
|---|---|---|
AdamW_adv |
Advanced AdamW with a rich set of optional features | General purpose |
Adopt_adv |
ADOPT with previous-step normalization (decorrelation) | Fast convergence in noisy/small batch training |
Prodigy_adv |
Prodigy with self-adaptive d-estimation | No manual LR tuning |
Lion_adv |
Lion with sign-based updates | Memory-efficient sign-based training |
SignSGD_adv |
SignSGD with several advanced variants | Memory-efficient, robust to gradient outliers |
SinkSGD_adv |
Sinkhorn-normalized updates for well-conditioned optimization | Dense updates, fast convergence |
These features work with all optimizers and are generally safe to enable.
| Feature | Description | Recommended Usage | Performance Impact | Theoretical Basis | Compatibility |
|---|---|---|---|---|---|
| Fused Back Pass | Fuses backward pass; gradients are used immediately and memory is freed on-the-fly. | Memory-constrained environments | Reduces peak memory | memory optimization | All optimizers |
| Stochastic Rounding | Accumulates parameter updates and weight decay in float32, rounding once at the end. Reduces quantization noise in BF16. | BF16 training | Minimal overhead (<5%) | Revisiting BFloat16 Training | All optimizers |
| OrthoGrad | Removes gradient component parallel to weights to reduce overfitting. | Full fine-tuning without weight decay | +33% time overhead for effective BS=4. Larger EBS = less overhead. | Grokking at Edge | All optimizers |
| State Precision | Controls the dtype used to store optimizer state. | Large models / memory-limited hardware | Memory-constrained environments | Reduces peak memory | All optimizers |
| Cautious Weight Decay | Modifications to weight decay that only applies it when the update direction aligns with the parameter sign. | General purpose (requires Weight Decay > 0) |
No overhead | Cautious Weight Decay | All optimizers |
| Spectral Normalization | Applies explicit spectral normalization via power iteration for width/rank invariant updates. | Stable training across architectures | Minimal overhead | spectral normalization | All optimizers |
| Nesterov Momentum | Looks ahead before applying the update, often improving convergence. | General purpose with momentum | No overhead | Nesterov's Method | All optimizers |
| Feature | Description | Recommended Usage | Performance Impact | Theoretical Basis | Compatibility |
|---|---|---|---|---|---|
| Atan2 | Robust epsilon replacement with built-in update clipping (scale-invariant). | Use for stable bounded updates (or for Adopt as it needs that) | No overhead | Adam-atan2 | AdamW/Prodigy/Adopt/AdaMuon |
| Kourkoutas-β | Layer-wise adaptive β₂ based on gradient "sunspike" ratio | Noisy/small-BS/high-LR training | Minimal overhead | Kourkoutas-β | AdamW/Prodigy/Adopt/Muon/AdaMuon |
| Centered Weight Decay | Pulls weights toward their pre-train anchor instead of zero. | Fine-tuning / PEFT | Minimal overhead (anchor storage) | Centered Weight Decay | All optimizers |
| Fisher Weight Decay | Maps decay through the empirical Fisher information matrix and clips its RMS. | Geometry-aware regularization | No overhead | FAdam | AdamW/Prodigy/Adopt |
| Geometric Weight Decay | Weight decay variant operating on geometric properties of the update direction. | Sign-based / Sinkhorn optimizers | No overhead | Gradient Multi-Normalization | SignSGD/SinkSGD |
| Factored Second Moment | Compresses only the second moment into rank-2 form while keeping first moment dense. | Memory savings on Adam variants | Compression overhead | SMMF | AdamW/Prodigy/Adopt |
| Variance-Normalized Momentum (NtM) | Applies adaptive normalization before computing momentum. | Sign-based / Sinkhorn updates | No overhead | NtM | SignSGD/SinkSGD |
| Stochastic Sign | Replaces deterministic sign with a stochastic variant preconditioned by |
Escape sharp minima | Minimal overhead | Adaptive Stochastic Sign | SignSGD/Lion |
| Sinkhorn Iterations | Number of Sinkhorn iterations for well-conditioned updates. | Default setting | +iteration overhead | Gradient Multi-Normalization | SinkSGD |
| Orthogonal Sinkhorn | Orthogonal Sinkhorn variant reaching rank-2 orthogonal projection. | Maximum conditioning | +iteration overhead | Iterative OrthoGrad | SinkSGD |
Controls the dtype used to store optimizer states (first moment, second moment, momentum, etc.). Lower precision saves VRAM at the cost of some numerical accuracy.
| Value | Description |
|---|---|
'auto' |
Uses the parameter's native dtype. |
'fp32' |
Full float32 precision. Highest memory usage. |
'bf16_sr' |
BF16 with stochastic rounding. Good balance of speed and accuracy. |
'int8_sr' |
8-bit integer with stochastic rounding and per-block scales. Experimental |
'factored' |
Rank-2 factored mode (SMMF). Stores states as two low-rank matrices. Lowest memory, solid accuracy. |
Fully compile the optimizer step function with torch.compile for fused, optimized execution.
| Parameter | Default | Description |
|---|---|---|
Compiled Optimizer |
False |
Compiles the core optimizer step with torch.compile. |
- This can heavily fuse and optimize the optimizer step path, reducing Python overhead and improving throughput.
- Recommended for heavy optimizer settings or full finetuning.
Nesterov momentum looks ahead before applying the update, often improving convergence.
| Parameter | Default | Description |
|---|---|---|
Nesterov |
False |
Enables Nesterov momentum. Must be used with non-zero momentum. |
Nesterov coef |
None / empty |
Optional coefficient for the Nesterov look-ahead. Defaults to the momentum value when None/empty. |
-
Starting values:
-
Large enough batch size:
Momentum = 0.95|Nesterov = True|Nesterov coef = [empty] -
Small batch size:
Momentum = 0.98 – 0.999|Nesterov = True|Nesterov coef = 0.2- Ensure the momentum duration covers a significant portion of your dataset (e.g., half an epoch).
- For the Nesterov coefficient, start with
0.2as a safe baseline for long-term momentum. However, momentum values of0.98or0.99can tolerate higher coefficients. - Note that some reports suggest higher coefficients require a lower learning rate, so tune accordingly.
-
Large enough batch size:
-
Usage: Start with these baseline values and tune as needed.
-
Theoretical paper expanding on this: "Nesterov acceleration despite very noisy gradients"
OrthoGrad orthogonalizes the gradient before applying the update, improving training stability and generalization by removing redundant directional components.
| Value | Description |
|---|---|
'disabled' |
Off. |
'flattened' |
Standard vectorized OrthoGrad. Projects flattened parameter vector onto the orthogonal complement of the gradient. |
'iterative' |
Matrix-wise rank-2 OrthoGrad. Operates on the 2D parameter matrix directly. |
- Available on all optimizers.
- Reference Paper: Grokking at the Edge of Numerical Stability
- Iterative mode is more accurate and theoretically suited but slower (x3)
Applies explicit spectral normalization using power iteration to the update matrix. This achieves width/rank invariant updates, making learning rates more transferable across architectures.
| Parameter | Default | Description |
|---|---|---|
Spectral Normalization |
False |
Enables spectral normalization via power iteration. |
- Available on all optimizers.
- For LoRA set
alpha=rank, for LoKr setalpha=dim - This ensures scale-invariant effective LR O(1) across all parameters, ranks, widths.
- Set
LR scalerin training tab tobothto handle batch size changes
- These were tested on Muon, SinkSGD, SignSGD with spectral normalization:
- Adam requires roughly x10 lower LR but it's still have scale-invariant effective LR.
| Model | LR-range |
|---|---|
| Krea2 | 1e-3 |
| Anima | 1e-4 |
| SDXL | 1e-3 |
- In general: 1e-3 to 1e-4 LR.
Instead of decaying weights toward zero, centered weight decay pulls them toward their initial values (anchors). This preserves the relative structure of pretrained weights while still regularizing.
| Parameter | Default | Description |
|---|---|---|
centered_wd |
0.0 | Centered weight decay coefficient. |
centered_wd_mode |
'full' |
Quantization format for storing anchors to save VRAM. |
Anchor precision options:
| Value | Description | Memory |
|---|---|---|
'full' |
Stores anchors in the original parameter dtype. | Highest |
'float8' |
Uses torch.float8_e4m3fn. |
Low |
'int8' |
8-bit block-wise quantization (block size 128). | Low |
'int4' |
4-bit block-wise quantization (block size 32). | Lowest |
- Available on all optimizers.
- Intended for full finetuning or training a pre-trained LoRA.
- int4 is sufficient here, as we only need a rough reference rather than full-precision weights.
A simple yet effective method for Adam-based optimizers that improves upon the eps hyperparameter, completely replacing it and making the optimizer scale-invariant.
This can be achieved by one of the two settings (choose one):
- Atan2 scaling option: Bounds the update step within the range
[-2, 2], effectively acting as built-in update clipping to prevent large, destabilizing jumps during optimization. -
eps=None/empty: Derives a scale invariant eps value that acts as a noise floor.
✅ Highly Recommended for Unstable Optimizers:
This is especially beneficial for optimizers likeAdopt_adv, which typically require highepsvalues and update clipping to remain stable during training.
| Parameter | Default | Description |
|---|---|---|
Atan2 Scaling |
False |
Enables the atan2 update rule. |
- Available on:
AdamW_adv,Prodigy_adv,Adopt_adv
This is a new technique that refines how Weight Decay is applied.
In standard optimization (like AdamW or Lion), Weight Decay always pulls parameters toward zero, regardless of what the loss function wants. This often creates a conflict where the optimizer wants to increase a value, but weight decay fights it by trying to decrease it.
CWD solves this by applying a simple logic mask:
- If the optimizer update and the parameter sign align (agree): Apply weight decay to help shrink the value.
- If they disagree (conflict): Turn off weight decay for that specific parameter and let the optimizer do its job.
- Simply enable it and set your
Weight Decayto a value> 0. -
No tuning required: It uses the exact same
Weight Decayvalue you would normally use. - Performance: The paper demonstrates consistently lower final loss and better generalization on both Vision and LLM tasks.
Keeps the first moment in state_precision precision while compressing only the second moment into a rank-2 factored form.
| Parameter | Default | Description |
|---|---|---|
factored_2nd |
False |
Compresses the second moment with SMMF. Available on all Adam variants. |
- This combination gives you both precision control on the first moment and memory savings on the second moment.
- Available only on Adam variants
| Parameter | Default | Description |
|---|---|---|
Sinkhorn iterations |
5 | Number of Sinkhorn iterations. |
Orthogonal Sinkhorn |
False |
Uses orthogonal Sinkhorn variant for rank-2 orthogonal projection. |
- Paper: Gradient Multi-Normalization for Stateless and Scalable LLM Training
- Orthogonal Sinkhorn is the same as intertive orthograd for other optimizers but it's integrated as a part of sinkhorn iterations, leading to a state where the update is both conditioned and orthogonalized to the weight.
- It's fine to reduce Sinkhorn iterations to 3 for performance gain.
Kourkoutas-β replaces the fixed β₂ with a dynamic schedule that lowers β₂ during periods of high gradient variance ("sunspikes"), then recovers it. This improves both stability and convergence speed.
Instead of using a fixed β₂ (e.g., 0.999 or 0.95), it dynamically modulates β₂ per param based on a bounded sunspike ratio.
-
During gradient bursts → β₂ ↓ toward
beta2_min→ faster reaction -
During calm phases → β₂ ↑ toward
betas[1]→ stronger smoothing
This is especially effective for noisy training, small batch sizes, and high learning rates, where gradient norms shift abruptly due to noise or aggressive LR schedules.
Maps the decay direction through the empirical Fisher information matrix and clips its RMS, as described in the FAdam paper. Provides geometry-aware regularization.
| Parameter | Default | Description |
|---|---|---|
Fisher Weight Decay |
False |
Enables Fisher weight decay. |
- Available on:
AdamW_adv,Prodigy_adv,Adopt_adv. - Compatible with
cautious_wdandcentered_wd.
A weight decay variant designed for sign-based and Sinkhorn-normalized optimizers. It operates on the geometric properties of the update direction:
- Signed-L1 penalty for
SignSGD_adv - Row and column distribution penalty for
SinkSGD_adv
| Parameter | Default | Description |
|---|---|---|
geometric_wd |
False |
Enables geometric weight decay. |
Available on: SignSGD_adv, SinkSGD_adv.
- Compatible with
centered_wdandcautious_wd. - Inspired from Fisher Weight Decay
Normalization-then-Momentum applies the adaptive normalization before computing momentum. This can improve stability, especially with sign-based or sinkhorn-normalized updates.
| Parameter | Default | Description |
|---|---|---|
Normalization-then-Momentum (NtM) |
False |
Enables NtM. |
- Available on
SignSGD_adv, andSinkSGD_adv. - ADOPT is already bundled with it by design.
Replaces the deterministic sign operator with a stochastic variant preconditioned by the
| Parameter | Default | Description |
|---|---|---|
Stochastic Sign |
False |
Enables the stochastic sign operator. |
- Available on:
SignSGD_adv,Lion_adv. - This adds controlled randomness that can help escape sharp minima
- In expectation, this leads to well-conditioned optimization (similar to SinkSGD but in different geometry).
- If you need assistance, the best place is the Discord
- If you have found a bug, problem or have a feature request, search for existing issues first before creating an issue