flashoptim
Memory-Efficient PyTorch optimizers
What it is and what it does
FlashOptim is a library of PyTorch optimizer implementations that reduce peak training memory by compressing optimizer states, master weights, and gradients through quantization and fused Triton kernels. It provides drop-in replacements for standard optimizers—FlashSGD, FlashSGDW, FlashAdam, FlashAdamW, and FlashLion—that follow the standard PyTorch optimizer API, so you can swap them in with minimal code changes.
The library works by splitting weight representation and quantizing optimizer moments to 8-bit while maintaining master weights at configurable precision (24-bit or 32-bit by default). All compression operations are fused into the update kernel to avoid overhead. It supports optional gradient release for further memory reduction and can produce checkpoints with quantized optimizer states. Training in reduced precision (bf16/fp16) does not degrade convergence according to the documentation.
Use it for:
- Fine-tuning large language models (8B+) on memory-constrained GPUs to fit larger batch sizes or longer sequences.
- Reducing peak memory during training to enable training on smaller GPUs or with larger models.
- Storing compressed checkpoints that are substantially smaller than standard optimizer state files.
- Training workflows where gradient release timing is critical to minimize intermediate memory peaks.
- Migrating existing PyTorch training code to use memory-efficient optimizers without rewriting training loops.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
FlashOptim provides drop-in replacements for PyTorch optimizers (SGD, Adam, Lion variants) that reduce training memory by quantizing optimizer states, master weights, and gradients while maintaining model convergence.
Yes, with conditions. Install if you train on NVIDIA CUDA GPUs and need to reduce training memory for large models. The low install friction, active maintenance, permissive license, and zero known vulnerabilities support adoption. However, it is early-stage (Alpha), Linux/CUDA-only, and the first optimizer step incurs Triton JIT overhead. Verify convergence and performance on your specific models and hardware before production use.
Install
flashoptim on PyPI
pip
pip install flashoptimuv
uv add flashoptimpoetry
poetry add flashoptimInstalling flashoptim
Before you install
Low install friction with a pure Python wheel. Active maintenance (last commit 2026-07-09) and early-stage status (Alpha, first release 2026-02-28) suggest ongoing development. Requires torch and triton as runtime dependencies.
License in practice
Apache License 2.0 is permissive, allowing commercial and private use with minimal restrictions—you may use, modify, and distribute FlashOptim freely provided you include license notices and disclaim warranties.
Quickstart
pip install flashoptim
import torch
from flashoptim import FlashAdamW, cast_model
model = torch.nn.Linear(128, 10).cuda()
cast_model(model, dtype=torch.bfloat16)
optimizer = FlashAdamW(model.parameters(), lr=1e-3)
x = torch.randn(32, 128, device="cuda", dtype=torch.bfloat16)
loss = model(x).sum()
loss.backward()
optimizer.step()
Requires NVIDIA CUDA GPU on Linux; torch and triton must be installed; first optimizer step is slower due to Triton kernel JIT compilation.
Verify before relying
- Actual memory savings percentages (35% peak, 57% checkpoint reduction) on representative models and hardware configurations beyond the 8B finetuning example.
- Convergence equivalence claims across different model architectures, scales, and training regimes.
- Performance overhead of quantization and fused kernels on different GPU generations and batch sizes.
- Compatibility with distributed training frameworks (DDP, FSDP) and mixed-precision training workflows.
Package facts
| License | Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the terms and conditions for… (full text in the JSON record) (permissive) |
| Python support | supports the current Python release (>=3.9) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 2 — torch, triton |
| Maintenance | actively maintained — 119 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 82,187/month — #14,177 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: flashoptim-0.1.4-py3-none-any.whl
Keywords: pytorch, optimizer, memory-efficient, deep-learning, training
Tags
More Artificial Intelligence packages
LiteLLM provides a unified Python interface to…
permissive · top 100 on PyPI
huggingface-hubClient library and CLI tool for downloading,…
permissive · top 100 on PyPI
langchainLangChain provides a framework for building…
permissive · top 1,000 on PyPI
hf-xethf-xet provides chunk-based deduplication and…
permissive · top 1,000 on PyPI
tokenizersTokenizers converts raw text into token…
permissive · top 1,000 on PyPI
transformersTransformers provides a unified framework for…
permissive · top 1,000 on PyPI
lion-pytorchLion is a PyTorch optimizer that implements an…
permissive · top 15,000 on PyPI
schedulefreeProvides schedule-free optimizers for PyTorch…
permissive · top 15,000 on PyPI
prodigyoptProdigy is a PyTorch optimizer that adapts the…
permissive · top 15,000 on PyPI
adam-atan2-pytorchProvides an Adam optimizer variant using atan2…
permissive · top 15,000 on PyPI
torch-optimizerProvides a collection of alternative…
permissive · top 15,000 on PyPI
pytorch-rangerRanger is a PyTorch optimizer that combines…
permissive · top 15,000 on PyPI
pytorch_optimizerProvides a collection of modern optimizers,…
permissive · top 15,000 on PyPI
optimum-quantoA PyTorch quantization backend that reduces…
permissive · top 15,000 on PyPI
comfy-aimdoA PyTorch VRAM allocator that dynamically…
unclear · top 5,000 on PyPI
codeflashCodeflash is a CLI tool that uses LLMs to…
unclear · top 15,000 on PyPI