Introduction
In modern deep learning, the efficiency of the data pipeline is critical as model sizes and dataset scales increase. While local NVMe storage provides negligible latency, petascale datasets are increasingly hosted on cloud-based object storage like Amazon S3. Standard PyTorch DataLoaders are optimized for local access, utilizing multiple worker processes to parallelize batch preparation. However, a significant bottleneck exists: within each worker, individual data items are fetched sequentially. In high-latency environments, this "sequential fetch" leads to severe GPU starvation, as the system waits for network round-trips for every single item in a batch.
The Data Loading Bottleneck
The standard training loop involves several nested activities. As illustrated in Figure 1, a "Train step" encompasses getting a batch, transferring it to the device, and running the training operation. The "Get batch" activity is further composed of multiple "Get item" calls.
In high-latency scenarios like S3, the cumulative latency of sequential "Get item" calls dominates the batch loading time. While increasing the number of worker processes can help, it often leads to excessive memory consumption and hits limits on concurrent connections or system resources without solving the underlying sequential nature of the fetcher.
Methodology: The ConcurrentDataloader
To address this, we developed the ConcurrentDataloader, which introduces a fetcher parallelization layer. By modifying the _MapDatasetFetcher, we enable concurrent fetching of individual data items within a single batch. Two primary implementations were explored:
- Threaded Implementation: Utilizes a
ThreadPoolExecutorto launch simultaneous requests for all items in a batch. - Asyncio Implementation: Leverages Python’s
asynciofor non-blocking I/O, allowing a single thread to manage multiple concurrent network requests efficiently.
Additionally, we implemented lazy initialization to prevent the multi-second delays typically seen when starting a DataLoader with many workers. We also investigated the use of Varnish, an HTTP accelerator, to provide OS-level caching for remote data.
Experimental Setup
Performance was evaluated using the ImageNet ILSVRC 2012 dataset. Benchmarks were conducted across various storage backends, including high-speed local NVMe SSDs (Scratch) and high-latency remote object storage (AWS S3).
Results and Discussion
The impact of storage latency on standard PyTorch performance is stark. As shown in Figure 2, the median duration for the "batch" operation on S3 is approximately 30.5 seconds, compared to only 1.68 seconds on local scratch storage. This massive disparity highlights the "S3 penalty" that starves the GPU.
With the ConcurrentDataloader, we observed a transformative improvement:
- Batch Loading Speedup: Up to a 12× reduction in batch loading time for S3.
- Training Throughput: Overall throughput improved by 11.44× to 15.5× for S3-based training.
- GPU Utilization: Utilization moved from near-idle levels to levels comparable to local SSD training.
- Performance Parity: The optimized loader achieved roughly 67% of the performance of a local SSD while fetching directly from S3, significantly reducing the need for expensive local data staging.
Limitations and Future Work
While the Python-based concurrent fetching provides massive gains, it eventually encounters the Global Interpreter Lock (GIL). Preliminary tests suggest that moving the data loading logic to a lower-level language like C++ could unlock even higher performance. Furthermore, while this approach is a drop-in replacement for standard datasets, combining it with data sharding (e.g., WebDataset) would likely provide the most robust performance profile for massive-scale training.
Summary updated