Spectra 推出即插即用优化器 SpectraAdamW,LLM 训练显存占用降低 50%
Show HN: Spectra – A drop-in optimizer that cuts LLM training VRAM by 50%
Spectra Labs 发布 SpectraAdamW,一款可将 LLM 微调优化器状态显存降低 50% 的即插即用优化器,通过因子化方差近似与频域动量压缩实现。
Authors: Spectra Labs Research
Status: Closed Beta (Python POC Available)
Abstract
The primary memory bottleneck when fine-tuning Large Language Models (LLMs) on consumer hardware is not the model weights, but the optimizer states. Standard AdamW requires storing two massive state tensors (momentum and variance), costing 2x the model parameters in VRAM. Unstructured sparsity (magnitude pruning) and aggressive 8-bit quantization often lead to severe degradation in convergence stability.
We introduce SpectraAdamW, a hybrid optimizer utilizing factorized variance approximations and frequency-domain momentum compression to reduce the optimizer state overhead by exactly 50% (~1x parameters) while maintaining full-precision convergence behavior.
Methodology
1. Factorized Variance Approximation (FVA)
Standard AdamW tracks the second moment (uncentered variance) of the gradients at full precision. SpectraAdamW decomposes this second moment into row and column means for 2D weight matrices (e.g., Linear layers). By storing only $O(N \times 1)$ and $O(1 \times M)$ tensors instead of the full $O(N \times M)$ matrix, we effectively eliminate the memory footprint of the variance state.
To prevent the Gibbs ringing artifacts commonly associated with aggressive variance compression, the factorized variance is strictly reconstructed via scalar multiplication before the gradient update, ensuring the denominator remains strictly positive and bounded.
2. Frequency-Domain Momentum Compression (Native Backend)
While the variance is factorized, the first moment (momentum) retains heavy directional information. In our proprietary C++ backend, momentum is compressed by transforming gradients into the frequency domain via a Fast Fourier Transform (FFT). This isolates the high-energy signal from the noise, allowing us to dynamically mask low-impact frequencies and compress the state without losing structural gradient integrity.
Empirical VRAM Benchmarks
In simulated 8192-dimension Transformer layer updates (Batch Size 128):
- AdamW State VRAM: 256.00 MB
- SpectraAdamW State VRAM: 128.16 MB
- Reduction: 50.0%
Loss curves demonstrate perfect alignment with AdamW convergence by step 40, avoiding the delayed convergence penalty seen in aggressive quantization methods.
Usage (Python POC)
We are currently distributing the PyTorch Minimum Viable Product (MVP) to verify the factorized variance math and VRAM reduction. The optimizer acts as a 1-line drop-in replacement for torch.optim.AdamW:
from spectra_optim import SpectraAdamW # Example: Fine-tuning an 8B model model = AutoModelForCausalLM.from_pretrained("meta-llama/Llama-3-8B") # Standard AdamW State VRAM: ~32GB # SpectraAdamW State VRAM: ~16GB optimizer = SpectraAdamW(model.parameters(), lr=1e-4, weight_decay=0.01) loss.backward() optimizer.step()
Beta Access
The fully optimized C++ CUDA backend is currently in closed development. If you are conducting research on constrained hardware and wish to verify the Python POC in our private Google Colab environment, please reach out to the Spectra Labs team on Reddit at r/SpectraLabs.
来源:Hacker News · github.com