Open SourceResearch 🇷🇺 08.08.2026 16:02

Beating OOM in PyTorch: Training Giant Graphs on an Ordinary GPU

Disk Sparse AdamDisk Sparse Adam
A developer has created Disk Sparse Adam (DSA), an out-of-core optimizer for PyTorch that moves optimizer moment states to disk via mmap, drastically reducing memory usage for training large sparse models. This allows training on consumer GPUs and even free Google Colab, with benchmark showing zero VRAM overhead on a million entities.
The article presents Disk Sparse Adam (DSA), a new out-of-core optimizer for PyTorch designed to train massive sparse models, such as knowledge graph embeddings with millions of nodes, on consumer-grade GPUs. The standard torch.optim.SparseAdam stores first and second moment states in memory, which for a model with 10 million entities and 128-dimensional vectors consumes about 10.24 GB extra, often leading to CUDA out-of-memory errors. DSA instead stores these moment matrices on disk as binary files and maps them into memory using the OS mmap mechanism, reading and writing only the active batch's states on each optimization step. The optimizer is designed as a drop-in replacement for standard PyTorch pipelines, and it supports both Euclidean and hyperbolic (Poincaré ball) spaces. The author reports that memory usage for optimizer states drops from gigabytes to megabytes, and a benchmark on Kaggle with 1 million entities showed 0.00 MB VRAM overhead and a throughput of 134,212 samples per second. DSA is available on GitHub under the MIT license, with limitations including the need for an NVMe SSD for best performance and compatibility only with sparse gradients, such as those from torch.nn.Embedding or EmbeddingBag.
Abbreviations
OOM = Out Of Memory — Нехватка памяти
GPU = Graphics Processing Unit — Графический процессор
VRAM = Video Random Access Memory — Видеопамять
RAM = Random Access Memory — Оперативная память
IOPS = Input/Output Operations Per Second — Операций ввода-вывода в секунду
NVMe = Non-Volatile Memory Express — Энергонезависимая память Express
SSD = Solid-State Drive — Твердотельный накопитель
GNN = Graph Neural Network — Графовая нейронная сеть
DSA = Disk Sparse Adam — Дисковый разреженный оптимизатор Adam
mmap = memory map — отображение в память
Source: Habr — хаб ИИ — original
Our earlier posts on this topic ↓
Fresh news