MegaScale-Data: Scaling Dataloader for Multisource Large Foundation Model Training

Juntao Zhao, Qi Lu, Wei Jia, Borui Wan, Lei Zuo, Junda Feng, Jianyu Jiang, Yangrui Chen, Shuaishuai Cao, Jialing He, Kaihua Jiang, Yuanzhe Hu, Shibiao Nong, Yanghua Peng, Haibin Lin, Chuan Wu · DOI

TL;DR

MegaScale-Data is a distributed data loading architecture designed to handle the massive memory overhead and computational imbalances that occur when training Large Foundation Models (LFMs) on data from hundreds of diverse sources. By disaggregating data preprocessing into specialized actors and introducing a centralized, declarative data plane, it eliminates redundant data access and achieves up to a 4.5× improvement in training throughput alongside a 13.5× reduction in CPU memory usage.

What Problem Does This Paper Address?

Modern foundation models are trained on massive, heterogeneous datasets blending text, images, and video from hundreds of distinct sources. Standard training frameworks use colocated dataloaders that process data independently across parallel ranks. This approach hits two major walls in multi-source, hybrid-parallel training:

  1. Workload Imbalance: Because the attention mechanism has quadratic computational complexity, variations in sequence lengths or image resolutions create massive computational disparities between microbatches. This leads to severe stragglers and pipeline bubbles across data-parallel ranks.
  2. Memory Bloat: Each dataloader process independently maintains file access states (metadata, sockets, I/O buffers) for every data source. As the number of sources and parallel ranks grows, memory consumption scales linearly, leading to massive redundancy and CPU memory exhaustion.
VLM Pretraining Pipeline and Dataloader Types

Methods

MegaScale-Data introduces three core architectural innovations to decouple data loading from model execution:

  • Disaggregated Preprocessing Architecture: It splits the traditional dataloader into two role-specific actors. Source Loaders handle sample-level transformations (like JPEG decoding or tokenization) for specific datasets. Data Constructors act as sinks for GPU ranks, aggregating samples to perform batch-level and parallelism transformations (like padding or splitting).
  • Centralized and Declarative Data Plane: It introduces DGraph (a stateful dataflow graph tracking sample lifecycles and dependencies) and ClientPlaceTree (a hierarchical representation of the logical device mesh). Together, they allow developers to express complex data mixing strategies (e.g., curriculum learning) using simple primitives (mix, distribute, balance) that automatically adapt to hybrid parallelism configurations.
  • Adaptive Multi-Level Scaling: An offline auto-partitioner clusters data sources by preprocessing costs to allocate worker resources efficiently. At runtime, an online AutoScaler dynamically adjusts and reshards Source Loaders as data mixing ratios shift over time.
Optimizing Loader Parallelism Redundancy

Datasets

The authors evaluated MegaScale-Data using two primary dataset groups:

  • coyo700m: An open-source image-text pair dataset consisting of 5 distinct data sources.
  • navit_data: A massive, production-grade dataset consisting of 306 distinct data sources, characterized by highly skewed token and sequence length distributions.

Key Insights and Ideas

  • Data-Side Load Balancing Beats Model-Side Fixes: Instead of using expensive all-to-all communication protocols at the model layer to balance input batches after ingestion, MegaScale-Data proactively balances heterogeneous data across modules before it hits the GPUs.
  • Decoupling Sample vs. Batch Operations: Separating sample-level transformations from batch-level collation allows multiple GPU ranks to share identical preprocessed data, completely eliminating redundant file access and data fetching across context-parallel (CP) or pipeline-parallel (PP) groups.
  • Exploiting Idle CPU Capacity: By deploying Source Loaders and Data Constructors as sidecars within accelerator pods, the system taps into otherwise wasted local CPU and memory resources, scaling out to remote pods only when necessary.

Key Results

  • Throughput Gains: MegaScale-Data achieved up to a 4.5× end-to-end training throughput improvement (averaging 1.77×) compared to non-scheduling baselines, particularly shining in long-context scenarios where workload imbalances are most severe.
  • Memory Reduction: The disaggregated architecture delivered up to a 13.5× reduction in CPU memory usage by eliminating redundant loader instances across parallel ranks.
  • Mitigating Imbalance: In a real-world VLM pre-training case study, the framework reduced iteration latency from 37.24 seconds to 15.91 seconds (a 2.34× speedup) by smoothing out the computational spikes caused by variable image resolutions.

Limitations and Future Work

  • Online Planning Overhead: While negligible for long training iterations, the centralized planner introduces minor overhead. The authors propose a future "Replay Mode" to pre-compute predictable schedules offline.
  • Reactive Load Balancing: Currently, load balancing happens reactively after data is fetched. Future work will explore Ahead-of-Fetch load balancing by leveraging early metadata acquisition to pre-compute sample costs before loading.
  • Graph Optimization: The authors plan to develop a strategy optimizer that uses graph rewriting techniques to automatically fuse orchestration primitives into highly efficient, low-latency C kernels.

Summary updated

BibTeX
@inproceedings{zhao2026megascale,
  author = {Juntao Zhao and Qi Lu and Wei Jia and Borui Wan and Lei Zuo and Junda Feng and Jianyu Jiang and Yangrui Chen and Shuaishuai Cao and Jialing He and Kaihua Jiang and Yuanzhe Hu and Shibiao Nong and Yanghua Peng and Haibin Lin and Chuan Wu},
  title = {{MegaScale-Data: Scaling Dataloader for Multisource Large Foundation Model Training}},
  booktitle = {EuroSys},
  year = {2026},
  doi = {10.1145/3767295.3803568},
}
Figure