Revolutionize MoE training with a memory-efficient optimizer.
Project details
SkewAdam offers a novel approach to optimize state allocation in Mixture-of-Experts training, achieving a remarkable 97.4% reduction in optimizer memory usage. Designed to fit large models on limited resources, it surpasses traditional optimizers like AdamW, Muon, and Lion, proving effective in reducing both memory overhead and validation perplexity.
SkewAdam is an innovative tiered optimizer specifically designed for memory-efficient Mixture-of-Experts (MoE) training. This optimizer significantly reduces memory usage, slashing the typical optimizer state required for large models by 97.4%, which facilitates training a 6.78B-parameter model on a single 40GB GPU.
The principle behind SkewAdam is rooted in the non-homogeneous nature of MoE architectures. By strategically allocating optimizer state to different tiers of parameters, it optimizes both memory usage and model performance:
| Tier | Share of Parameters | Momentum | Second Moment | State Cost |
|---|---|---|---|---|
| Backbone (embeddings, attention, dense FFN) | 5.0% | fp32 | factored | 1.27 GB |
| Experts (128 SwiGLU experts) | 95.0% | none | factored | 12.6 MB |
| Router (top-2 gate) | 0.008% | none | full fp32 | 2.1 MB |
Momentum is retained for the backbone, which processes all tokens, while expert parameters, which are less frequently accessed, utilize a factored second moment, leading to substantial memory savings. The router, although small, maintains critical second moments to effectively manage traffic.
The optimizer's efficiency is highlighted in the following comparative metrics, derived from training a 6.78B-parameter MoE model:
| Optimizer | State (GB) | Peak VRAM (GB) | Tokens/s | Val. PPL ↓ | Balance Loss |
|---|---|---|---|---|---|
| SkewAdam | 1.29 | 31.3 | 5,000 | 108.4 | 0.0505 |
| AdamW | 50.55 | 81.4 | 4,692 | 126.8 | 0.0502 |
| Muon | 25.27 | 57.6 | 3,409 | 120.2 | 0.0608 |
| Lion | 25.27 | 56.6 | 5,075 | 393.7 | 0.0537 |
SkewAdam not only achieves superior validation perplexity but also balances routing effectively during training, ensuring optimal resource utilization.
To utilize SkewAdam within a training loop, it can be easily integrated following the example below:
from skewadam import SkewAdam
optimizer = SkewAdam([
{"params": dense_params, "use_momentum": True, "use_factored": True, "weight_decay": 0.05},
{"params": expert_params, "use_momentum": False, "use_factored": True, "weight_decay": 0.05},
{"params": router_params, "use_momentum": False, "use_factored": False, "weight_decay": 0.0},
], lr=3e-4)
SkewAdam presents a pioneering approach to optimizer state management, optimizing both memory efficiency and training performance in Mixture-of-Experts architectures. This project significantly extends the capability of large model training on constrained hardware, making it an essential tool for researchers and practitioners in the field of machine learning.
Comments
0Start the conversation
Share the first comment.