03 · train_gpt.py line 1420
distributed_data_generator
DDP-aware infinite data loader with BOS alignment
A Python generator that reads FineWeb .bin shards from disk, splits the data across 8 GPUs so each sees unique tokens, optionally aligns sequences to document starts (BOS token = 50256), and yields 4 CUDA tensors per training step.
The 4 tensors yielded per step
_inputs(int32) — input token IDs for this rank's slice_targets(int64) — shifted-by-1 labels for next-token loss
_cum_lengths(int32) — cumulative doc boundaries (for varlen flash attention)_bigram_inputs(int32) — hashed bigram indices fromget_bigram_hash