ByteDance's MegaScale-Data Boosts Vision Model Training 4.5x on 4,096 GPUs
ByteDance's MegaScale-Data rethinks how foundation model training pipelines stream data from hundreds of sources, cutting memory 13.5x and boosting throughput 4.5x.
ProTakeaways
- ByteDance's MegaScale-Data reworks foundation-model dataloading into a Ray-based actor system with Source Loaders, Data Constructors, and a Planner.
- Reports 4.5x higher training throughput and 13.5x lower CPU memory versus PyTorch DataLoader, tf.data, Cachew, Ray Data, and Pecan.
- Load-time balancing addresses up to 6.9x FLOPs imbalance from variable sequence lengths without adding all-to-all communication.
- DGraph and ClientPlaceTree abstractions let engineers express VLM mixing strategies in about a dozen lines of code.
- Autoscaler dynamically repartitions and reshards Source Loaders as mixing ratios shift for curriculum learning workloads.
- Validated up to 4,096 GPUs on Llama, Mixtral, and ViT combinations; no open-source release announced.
Training a modern vision-language model does not fail because attention kernels are slow. It fails because the humble dataloader, sitting between object storage and thousands of GPUs, was never designed to juggle hundreds of heterogeneous sources at once. A team from ByteDance Seed and the University of Hong Kong has published MegaScale-Data, an industrial dataloader that reworks the pipeline into a distributed actor system and reports up to 4.5x higher end-to-end training throughput and a 13.5x reduction in CPU memory usage on clusters as large as 4,096 GPUs.
Why the old dataloader falls apart
Frameworks like PyTorch DataLoader, tf.data, and Ray Data hand each data-parallel rank an identical, self-contained loader that pulls a disjoint slice of the training set. That design was fine for ImageNet. It breaks in two ways for foundation models.
The first problem is workload imbalance. Because the attention operator has quadratic complexity in sequence length, a sequence made of 30-token and 70-token subsequences takes 16% more compute than two 50-token subsequences. When samples of very different lengths get randomly sprinkled across ranks, some GPUs finish their microbatch far ahead of others and sit idle. In an 8-GPU VLM benchmark, the maximum microbatch FLOPs were 3.2x higher than the minimum for images and 6.9x higher for full sequences.

The second problem is memory bloat. In production LFM training, replicated file access states for data sources consume more than 70% of total data-preprocessing memory when per-DP batch sizes are moderate. Every worker on every rank keeps its own sockets, Parquet metadata, schemas, and I/O buffers for every source. Multiply that by hundreds of sources and hybrid parallelism (pipeline, context, tensor) and the footprint explodes. Worse, audio processing needs about 4x more compute per output token than image decoding and 300x more than text tokenization, so worker counts get sized for the slowest source and everything else is over-provisioned.
Splitting the pipeline into specialized actors
MegaScale-Data disaggregates what used to be one monolithic loader into three roles built on Ray:
- Source Loaders are per-source actors that own file access and sample-level transforms (JPEG decode, tokenization). Each source is loaded once, not once per rank.
- Data Constructors sit next to the trainer, aggregating outputs from Source Loaders and handling batch-level work such as packing, padding, and the parallelism transforms needed for CP, PP, and TP groups.
- Planner centrally orchestrates mixing schedules, generates loading plans from lightweight metadata, and drives autoscaling.

This split kills two kinds of redundancy at once. Ranks inside the same context-parallel group now share a single preprocessed batch instead of each loading it. And file handles for a given source live in one actor instead of being cloned across the cluster.
A declarative data plane
The team also introduces two abstractions that let engineers describe complicated mixing strategies without hand-writing scheduler code. DGraph is a dataflow graph that tracks each sample's lifecycle and dependencies, and ClientPlaceTree is a tree representation of the GPU topology that automates parallelism transforms. On top of these, a handful of primitives (mix, distribute, cost, balance, broadcast_at, plan) express strategies like curriculum learning or long-short context balancing in a few lines. A full VLM inter-module balancing strategy is implemented with about five additional lines of code on top of a seven-line unimodal balancer.
The balance primitive supports greedy bin-packing or Karmarkar-Karp differencing to redistribute samples by predicted FLOPs cost. Crucially, this happens at load time, before data hits the model, so there is no expensive all-to-all inside the training graph to shuffle work around.
Autoscaling for heterogeneous sources
Because different sources have wildly different preprocessing costs, MegaScale-Data runs a two-phase scaler. Offline, it clusters sources by transformation cost and picks per-source worker and actor counts within memory bounds. Online, the Planner watches the moving-average sampling weight of each source and spins up new Source Loader actors or reclaims idle ones when the mixture shifts, for example during curriculum learning.
Fault tolerance is baked in. Shadow Loaders act as hot standbys for instant failover, and differential checkpointing lets Source Loaders snapshot less frequently than the Planner by relying on deterministic replay of Planner state.
What the numbers show
The evaluation uses ViT encoders (1B and 2B) paired with Llama-12B, Mixtral 8x7B, and a production 25B tMoE model on the coyo700m and internal navit_data corpora, benchmarked against PyTorch DataLoader, tf.data, Cachew, Ray Data, and Pecan.
- Up to 3.63x speedup in training iteration time versus state-of-the-art loaders and up to 13.5x reduction in loader memory usage on 288 and 576 GPU runs.
- End-to-end orchestration gives up to 4.54x throughput improvement over a non-scheduling baseline, averaging 1.77x.
- Gains scale with context length: 4k contexts average 1.71x, 8k contexts 2.63x, and 16k contexts 3.09x, because longer sequences produce more heterogeneity for the balancer to exploit.
- At 4,096 GPUs a naive direct-transfer baseline collapses under connection overhead, while MegaScale-Data sustains throughput via the Data Constructor layer.
The balancer changes how tokens are grouped, which could nudge convergence. The paper reports that without context parallelism the balanced loss tracks the baseline tightly; with CP enabled there is slightly more fluctuation from repartitioning effects on distributed GEMMs, but training still converges.
Availability and where it fits
MegaScale-Data is implemented on top of Ray in roughly 8,763 lines of Python, but the paper does not announce an open-source release. The design is most useful for teams training multimodal or multi-source foundation models at hundreds to thousands of GPUs, particularly where hybrid 4D parallelism (DP + CP + PP + TP), dynamic data mixing, or curriculum learning are in play. For single-source, pure data-parallel jobs, a colocated PyTorch DataLoader is still simpler and the memory wins mostly disappear. The bigger message is that as models grow, the input pipeline deserves the same first-class distributed-systems treatment that the training framework already gets.