← Portfolio

Open-source experiment · PyTorch

Dataloader Optimization

Experiments on the path from stored images to GPU-ready batches.

I explored data-loading bottlenecks in PyTorch with CIFAR-10 and CelebA, then published the code and a technical write-up. The project looks at why a GPU may wait for data and what can be done at different points in the loading pipeline.

Period
2021
My role
Author · Implementation and technical write-up
Scope
Data loading, transfer, chunk caching, and batch reuse

Prepare another batch while the GPU trains

A GPU can finish its current batch before the next one is ready. I explored multiprocess loading and prefetching so CPU workers could prepare upcoming batches while training continued.

Different batches can occupy the pipeline at the same time
CPU workers

Prepare

Batch CBatch DBatch E
Ready queue

Hold next batch

Batch BBatch CBatch D
GPU

Train

Batch ABatch BBatch C
Preparation can overlap with training.
Schematic batches. The animation shows progression, not measured timings or a speedup.

Match the intervention to the bottleneck

Other experiments addressed different costs: keeping images in a compact data type before conversion, using HDF5 chunks and caching, and reusing a batch through batch echoing.

Batch echoing performs more updates on a batch that has already been transferred. My write-up discusses the tradeoff with randomness. High utilization alone does not show that training quality is preserved.

Each intervention targets a different part of loading
Disk

HDF5 chunks + cache

CPU preparation

Multiprocess loading

Data transfer

Compact image representation

GPU updates

Batch echoing

Conceptual locations of the methods in the historical project, not a profiler trace or one combined benchmark setup.

Publish the code and the reasoning

The repository contains separate CIFAR-10 and CelebA scripts, chunking and batch-echoing variants, and a write-up explaining the choices. The original article is also available on this site.

Code and a write-up others can inspect

My contribution
Experimental implementations and a public explanation of the data-loading pipeline.
Published material
Source code and historical CIFAR-10/CelebA experiment notes.

The historical utilization observations depend on the experiment setup. These experiments were not rerun for this portfolio, and no general speedup across hardware is claimed.