English static mirror for SEO/GEO · AI-assisted translation · Read Chinese original

MegaTrain: Training 100B+ Parameter Models on a Single GPU

Forum topic · ✨步子哥 · 2026-05-02

Summary

MegaTrain is a memory-centric training system that enables full-precision training of 100B+ parameter large language models on a single GPU by fundamentally restructuring data placement across the memory hierarchy. Instead of keeping parameters, gradients, and optimizer states in GPU memory, MegaTrain stores all persistent states in host RAM, treating the GPU as a temporary compute engine. It streams layer-by-layer parameters to the GPU, uses double-buffered pipelining to overlap PCIe transfers with computation, executes optimizer updates on CPU, and applies aggressive activation recomputation to trade compute for memory. It also replaces PyTorch's autograd graph with stateless layer templates, keeping GPU memory bounded to a single layer. Reported results: on an H200 with 1.5TB host memory, MegaTrain reliably trained a 120B model where DeepSpeed ZeRO-3 fails around 30B; it achieved 1.84x the throughput of ZeRO-3 with CPU offload on a 14B model and sustained over 250 TFLOPS at 32B on a GH200; and it trained a 7B model with 512K-token context on one GPU, a task otherwise requiring 64 GPUs with FSDP+CP.

MegaTrain: Training 100B+ Parameter Models on a Single GPU

Key points

  • Problem: GPU memory is the main bottleneck for training large models. Mixed-precision training of a 7B model requires ~84GB just for parameters, gradients, and Adam optimizer states (~12x parameter count), exceeding even an H200's 141GB HBM for larger models.
  • Core idea: Break the constraint of GPU memory by leveraging the memory hierarchy. MegaTrain stores all persistent states (parameters, gradients, optimizer states) in host RAM and treats the GPU as a temporary compute engine.
  • Design highlights

    1. Parameters and optimizer states in host memory: Parameters are streamed layer-by-layer to the GPU, gradients streamed back, and optimizer steps (e.g., Adam) run entirely on CPU. GPU memory demand drops from ~12x parameter size to roughly a single layer's worth. 2. Streaming, pipelined execution: Layer-by-layer parameter prefetch and gradient offload, with double buffering (ping-pong) so the next layer's parameters arrive while the current layer computes, overlapping PCIe I/O with GPU computation across multiple CUDA streams. 3. Aggressive activation recomputation: Activations are recomputed every few layers instead of being stored, trading extra compute for memory; segmented checkpointing (every K layers) balances the trade-off. 4. Stateless layer templates: Instead of PyTorch's global autograd graph, each layer uses a lightweight template with dynamically bound parameters, so GPU memory never exceeds one layer and gradients can stream back to the host easily.

    Reported performance

  • Scale: Reliably trained a 120B-parameter model on a single H200 with 1.5TB host memory; existing offloading systems typically fail around 30B due to exploding host memory needs. Host memory grows linearly with parameter count thanks to flat tensor layouts and an authoritative host storage design.
  • Throughput: 1.84x DeepSpeed ZeRO-3 (CPU offload) on a 14B model; sustained over 250 TFLOPS on a single GH200 at 32B, where ZeRO-3 cannot run due to OOM.
  • Long context: Trained a 7B model with 512K-token context on a single GH200 — a setup that would require 64 GPUs with FSDP+CP.
  • Positioning vs. existing frameworks

  • DeepSpeed ZeRO-Offload/Infinity: GPU-centric with selective offloading; parameters still mostly reside on GPUs, causing scaling walls for very large models. MegaTrain moves parameters to host fundamentally.
  • Megatron-LM: Multi-GPU tensor/pipeline parallelism requiring large clusters; pursues maximum MFU. MegaTrain targets single-GPU scenarios via storage restructuring rather than parallel scaling.
  • PyTorch FSDP2: Shards state across multiple GPUs but cannot handle single-GPU huge models; MegaTrain is like FSDP extended to offload-to-host on a single card, with a custom streaming engine.
  • Colossal-AI: Ease-of-use distributed framework that still requires multi-GPU environments; MegaTrain optimizes a single GPU to the extreme.

Takeaway

MegaTrain demonstrates that when hardware is scarce, system-level redesign of the memory hierarchy can substitute for hardware stacking. It complements rather than replaces cluster-scale frameworks: single-machine training/fine-tuning with MegaTrain, cluster scaling with tools like Megatron-LM. For memory-constrained practitioners, it makes single-card training of frontier-scale models feasible — albeit with trade-offs in communication-bound workloads and extra recomputation overhead.

Tags

#megatrain#large-language-models#gpu-training#cpu-offloading#memory-hierarchy#deepspeed#activation-checkpointing#single-gpu

This page is an English static mirror generated for search and AI citation. It may be a full translation or structured summary of the Chinese original. Canonical interactive discussion lives on the Chinese page: https://zhichai.net/topic/177619068