Repository navigation
Data Pipeline
The built-in list contains 16 educational example sentences. --corpus-file accepts UTF-8 text with one training example per non-blank line. Samples are repeated using --repeat (default 4). Data is kept in memory as a Python list.
flowchart TB
Text["Text lines x repeat"] --> DS["IndexedTextDataset: (record_id, text)"]
DS --> Split{"World size > 1?"}
Split -->|yes| Sampler["DistributedSampler, shuffle seed 2026; set_epoch"]
Split -->|no| Shuffle["Single-process DataLoader shuffle"]
Sampler --> R0["Rank 0 record indices"]
Sampler --> R1["Rank 1 record indices"]
R0 --> Loader0["DataLoader, batch_size per rank"]
R1 --> Loader1["DataLoader, batch_size per rank"]
Shuffle --> LoaderSingle["Single DataLoader"]
Loader0 --> Collator["Tiny byte collator or Qwen tokenizer collator"]
Loader1 --> Collator
LoaderSingle --> Collator
Collator --> Device["Tensor batches on CPU or local CUDA GPU"]
- Encode sample text as UTF-8 bytes; retain at most
seq_len - 1bytes. - Map byte values
0..255to token IDs2..257and append EOS token1. - Pad with ID
0toseq_len. - Clone
input_idstolabels, replacing PAD targets with-100(ignored in cross-entropy).
The pretrained tokenizer performs truncation and right padding to seq_len, and supplies an attention_mask. Labels are copied from token IDs with padded positions masked to -100.
Limitations: No validation split, document deduplication, dataset streaming, dynamic sequence bucketing, assistant-only loss mask, or real task-quality evaluation is implemented. Using a realistic training dataset requires separate design work.
Distributed LLM Training · PyTorch DDP (educational) — Home · System-Architecture · Low-Level-Design · Publishing-the-Wiki
This project is licensed under the Apache License, Version 2.0.© 2026 Sudhanshu Shukla · Licensed under the Apache License, Version 2.0.