AdamBridge
Asynchronous Layer-Wise Host Optimizer
Keep active parameters on the GPU and move everything else off it. AdamBridge holds the master weights and both Adam moments in host RAM and updates them with multi-threaded fused SIMD CPU kernels, pipelined into the backward pass.
Core Technical Summary
AdamBridge implements the OptiCompute-Bridge architectural design for PyTorch. Active model parameters remain resident on the GPU, while the master weights and both Adam moments are offloaded to NUMA-local host RAM and updated via multi-threaded fused SIMD CPU kernels (AVX2+FMA, AVX-512F or NEON, chosen at runtime). The arithmetic is exactly torch.optim.AdamW's.
By registering autograd backward hooks via opt.attach_hooks(model), parameter updates are pipelined asynchronously. Each layer transfers its gradient to host RAM and executes its CPU SIMD update concurrently while earlier layers continue their backward pass on the GPU.
Version 0.2.0 adds an FP24 master, a chunked causal_lm_loss and a shared pinned transfer ring, which together fine-tune Qwen2.5-7B on a 24 GB laptop GPU, plus delayed updates, the Lion optimizer and tested torch.compile support. In a head-to-head arena it trained 2.1–2.2× as many tokens per second as DeepSpeed at reference quality.
Benchmarks
Data sourced verbatim from the reproducible benchmark suite shipped with the package. Hardware: RTX 5090 Laptop GPU (24 GiB), Intel Core Ultra 9 290HX Plus (AVX2), 64 GiB RAM, Windows 11, PyTorch 2.14.1 + CUDA 13.2. Compared against bitsandbytes 0.50.2 and torchao 0.18.0.
| Optimizer Configuration | Final Val Loss | Step Latency | Peak GPU VRAM | VRAM Saving |
|---|---|---|---|---|
| PyTorch AdamW, FP32 weights + autocast (reference) | 2.6402 | 292 ms | 19.6 GiB | Reference |
| AdamBridge, FP8 moments | 2.6409 | 305 ms | 13.2 GiB | -32.7% |
| AdamBridge, BF16 moments | 2.6405 | 317 ms | 13.2 GiB | -32.7% |
| torchao CPUOffloadOptimizer, FP32 weights | 2.6401 | 525 ms | 15.9 GiB | -18.9% |
| bitsandbytes AdamW8bit, FP32 weights | 2.6433 | 312 ms | 16.8 GiB | -14.3% |
| PyTorch AdamW, BF16 weights only | 2.6526 | 266 ms | 15.1 GiB | -23.0% |
The BF16-only optimizer is fast but loses quality: at this learning rate most AdamW updates round away in BF16, so only 18% of its weights changed against 84% for the reference.
| Model | AdamBridge | DeepSpeed | torchao | bitsandbytes | PyTorch | vs DeepSpeed |
|---|---|---|---|---|---|---|
| Qwen2.5-0.5B | 11,784 tok/s | 5,541 | 6,770 | 10,640 | 11,623 | +113% |
| Qwen2.5-1.5B | 4,829 tok/s | 2,192 | 2,680 | 4,341 | – | +120% |
| Qwen2.5-3B | 2,782 tok/s | – | – | – | – | only AdamBridge trains it |
| Qwen2.5-7B | 1,122 tok/s | – | – | – | – | no reference fits |
Each cell is the library's fastest configuration that reached the reference's validation loss; a dash means no configuration fitted or reached it. Activation checkpointing and a chunked loss were on for every library. DeepSpeed 0.19.9 ran in its documented single-GPU configurations (ZeRO-2 and ZeRO-3 with offload, ZenFlow, SuperOffload).
| Library / Configuration | Largest Model | Stopped By |
|---|---|---|
| AdamBridge, FP8 moments, FP24 master | 8.02B | host memory |
| AdamBridge, FP8 moments | 6.79B | host memory |
| AdamBridge, FP32 moments | 3.39B | host memory |
| bitsandbytes AdamW8bit (FP32 weights) | 2.08B | GPU memory |
| torchao CPUOffloadOptimizer (FP32 weights) | 2.08B | host memory |
| DeepSpeed ZeRO-2 + CPU offload (ZeRO-Offload) | 2.08B | host memory |
| DeepSpeed ZeRO-3 + offload (ZeRO-Infinity) | 1.54B | host memory |
| PyTorch AdamW, all on the GPU (FP32 weights) | 1.31B | GPU memory |
Random-initialised Qwen2.5-3B-shaped models with more layers, 3 steps at micro-batch 1, bisected to ±8%.
Capabilities
Fine-Tune a 7B Model on a 24 GB GPU (New in 0.2)
Two things stop a 7.6B-parameter model from training on a 24 GB laptop GPU with 44 GB of host memory, and 0.2 removes both:
- •
adambridge.causal_lm_losscomputes the cross-entropy a slice of positions at a time, so the 2.3 GiB full-logits tensor never exists, with the same value and gradients as the standard loss. - •
master_precision="fp24"keeps the top 24 bits of each FP32 master with stochastic rounding: about 5.06 host bytes per parameter with FP8 moments, 9–15% less host memory at the same quality. - • Result: Qwen2.5-7B at 1,122 tokens/s with 18.2 GiB of GPU memory and 38.0 GiB of host memory.
Elimination of BF16 Update Truncation
At standard fine-tuning learning rates (e.g. 2e-5), AdamW updates are frequently smaller than half the spacing between representable BF16 values. Without a high-precision master copy, they are rounded away to zero:
- • A pure BF16 optimizer changed only 18% of weights during Qwen2.5-0.5B fine-tuning, against 84% for the FP32 reference, and finished with a worse validation loss (2.6526 vs 2.6402).
- • AdamBridge keeps BF16 weights on the GPU for compute but the master weights on the host, and reached reference quality in every precision mode.
Verified 32% to 40% VRAM Reductions
Validated across LLM fine-tuning benchmarks on NVIDIA RTX 5090 Laptop hardware:
- • Qwen2.5-0.5B on WikiText-2 (200 steps of 8×512): peak VRAM from 19.6 GiB to 13.2 GiB (-32.7%) at matching validation loss (2.6405 vs 2.6402).
- • SmolLM2-135M: 40% less GPU memory than the reference at the same quality.
- • 2.7 GiB less VRAM than torchao CPU offload at the same quality, with 40% less time per step (305 ms vs 525 ms).
Moment & Master Precision Modes
Granular trade-offs between host memory footprint and precision (host bytes per parameter, FP32 master included):
- • fp32: 12 bytes; 395 ms step in the 0.5B benchmark.
- • bf16: 8 bytes with stochastic rounding; 317 ms step.
- • fp8: about 6.06 bytes (block-scaled E4M3 / E5M2 of √v); 305 ms step.
- • master_precision="fp24": one byte less per parameter in any mode.
Delayed Updates & LionBridge (New in 0.2)
- •
delay_updates=Trueapplies each update one step late, so the CPU update overlaps the whole next forward and backward pass andstep_sync()returns at once, at the cost of one step of staleness. Measure it on your task. - •
adambridge.LionBridgeruns the Lion optimizer on the same pipeline with one moment instead of two: 8 host bytes per parameter with FP32 state instead of 12, and faster updates. - •
gpu_state_budget="auto"keeps the optimizer state of the last-to-finish parameters on the GPU, removing the end-of-backward wait when VRAM allows.
PyTorch Ecosystem Compatibility
Works as a drop-in optimizer within existing PyTorch training scripts:
- • Standard PyTorch learning rate schedulers work in both synchronous and asynchronous modes.
- •
torch.compileworks in every mode, including CUDA graphs and compiled autograd. Compile per block to keep the layer-wise overlap. - • Global gradient clipping via
torch.nn.utils.clip_grad_norm_is supported with synchronousstep(). - •
accumulation_stepssupports loops you don't control, such as the Hugging Face Trainer, andAutoTuneConfigtunes thread counts and moment precision.
Usage
pip install adambridge. It is a pure-Python wheel carrying its C source; the native kernel compiles on first use (pip install "adambridge[compiler]" adds a C compiler for machines without one), and python -m adambridge info shows the SIMD level, NUMA nodes and L2 size.Asynchronous Training Loop
import torch
from adambridge import AdamBridge
model = MyTransformer().cuda()
# Wrap optimizer; parameters stay on the GPU, moments & master weights on host RAM
opt = AdamBridge(model.parameters(), lr=1e-4, weight_decay=0.01)
opt.attach_hooks(model) # pipelines layer updates into the backward pass
for x, y in loader:
loss = loss_fn(model(x), y)
loss.backward() # offloaded & updated per layer
opt.step_sync() # sync boundary for forward passQwen2.5-7B on a 24 GB GPU
import torch, adambridge
# Fine-tuning a 7B model on a 24 GB GPU with 43 GB host RAM
loss_fn = adambridge.causal_lm_loss(chunk_size=1024) # chunks logits: no 2.3 GB tensor
opt = adambridge.AdamBridge(
model.parameters(), lr=2e-5,
moment_precision="fp8", # 6 host bytes per parameter
master_precision="fp24", # 1 byte less per parameter; matches FP32 loss
host_transfer_ring=4, # 4 pinned buffers reused across layers
)
opt.attach_hooks(model)
for batch in loader:
loss = loss_fn(model, batch["input_ids"], batch["labels"])
loss.backward(); opt.step_sync(); opt.zero_grad()Delayed Updates & LionBridge
# Delay updates by 1 step to overlap CPU update with the whole next forward/backward
opt = adambridge.AdamBridge(model.parameters(), lr=1e-4, delay_updates=True)
opt.attach_hooks(model)
# Or use the Lion optimizer with 1 moment instead of 2 (8 bytes/param with FP32 state)
lion = adambridge.LionBridge(model.parameters(), lr=1e-4, weight_decay=0.1)
lion.attach_hooks(model)AdamBridge: FAQ
What is AdamBridge?
AdamBridge is an open-source PyTorch optimizer from InnvoSols. It keeps active BF16 parameters on the GPU and moves the master weights and both Adam moments to host RAM, where multi-threaded fused SIMD CPU kernels update them layer by layer during the backward pass.
How much GPU memory does AdamBridge save?
Fine-tuning Qwen2.5-0.5B on WikiText-2 on an NVIDIA RTX 5090 Laptop GPU, AdamBridge reduced peak VRAM from 19.6 GiB to 13.2 GiB (32.7% lower) with matching validation loss (2.6405 vs 2.6402). It also used 2.7 GiB less VRAM than torchao CPU offload with lower step latency (305 ms vs 525 ms).
How does AdamBridge compare with DeepSpeed?
In the AdamBridge 0.2 arena benchmark (100 steps of 8x512 tokens on WikiText-2, RTX 5090 Laptop GPU), AdamBridge trained 11,784 tokens/s on Qwen2.5-0.5B against DeepSpeed's 5,541 (+113%) and 4,829 tokens/s on Qwen2.5-1.5B against 2,192 (+120%), at reference quality. Only AdamBridge trained Qwen2.5-3B and 7B on that machine; the largest model it trained was 8.02B parameters, against 2.08B for DeepSpeed ZeRO-Offload.
Can AdamBridge fine-tune a 7B model on a 24 GB GPU?
Yes. With FP8 moments, an FP24 master (master_precision="fp24", about 5.06 host bytes per parameter) and adambridge.causal_lm_loss, which avoids building the full logits tensor, it fine-tuned Qwen2.5-7B at 1,122 tokens/s using 18.2 GiB of GPU memory and 38.0 GiB of host memory. Where references exist, the FP24 master matches the FP32 master's quality with 9-15% less host memory.
Why not just train with a pure BF16 optimizer?
At typical fine-tuning learning rates (for example 2e-5), many AdamW updates are smaller than half the spacing between representable BF16 values, so they round away to zero. In benchmarks a pure BF16 optimizer changed only 18% of weights. AdamBridge keeps a high-precision master copy on the host so those small updates are preserved.
How do I use AdamBridge?
Install it with pip install adambridge, create adambridge.AdamBridge(model.parameters(), lr=...), call opt.attach_hooks(model) to enable layer-wise asynchronous updates during backward, and call opt.step_sync() after loss.backward(). Without attach_hooks it works as a drop-in optimizer with backward(), step() and zero_grad().
Is AdamBridge compatible with existing PyTorch training code?
Yes. LR schedulers work in both modes, and torch.compile works in every mode, including CUDA graphs and compiled autograd. Global gradient clipping with clip_grad_norm_ needs the synchronous step() mode. An autotuner (adambridge.autotune.AutoTuneConfig) picks the thread count and can step moment precision down when the CPU update is the bottleneck, and accumulation_steps supports the Hugging Face Trainer.
What precision modes does AdamBridge offer?
Adam moments can be stored on the host in fp32, bf16 or fp8 (12, 8 or about 6.06 host bytes per parameter including an FP32 master), and master_precision="fp24" saves one more byte per parameter. In the Qwen2.5-0.5B benchmark all three moment precisions reached reference quality, with step times of 395 ms (fp32), 317 ms (bf16) and 305 ms (fp8).
What else is new in AdamBridge 0.2?
Version 0.2 adds delayed updates (delay_updates=True), which overlap the host update with the whole next forward and backward pass at the cost of one step of staleness; LionBridge, the Lion optimizer on the same pipeline with one moment instead of two; gpu_state_budget, which keeps some parameters' optimizer state on the GPU; a shared pinned transfer ring that saves about 30 GB of host RAM on 7B models; FP24 master weights; causal_lm_loss; tested torch.compile support; and accumulation_steps for training loops such as the Hugging Face Trainer.
Custom Optimization for Your Workloads
If your organization is training large architectures and encountering VRAM constraints, PCIe bottlenecks, or latency targets, our systems engineering team is available for consulting engagements and custom kernel authoring.