Documentation Index
Fetch the complete documentation index at: https://mintlify.com/AymanMahfuz27/modern_llm/llms.txt
Use this file to discover all available pages before exploring further.
HardwareConfig
Hardware-specific training configuration. Supports local (RTX 3060) and high-end GPU (A100/H100) environments with auto-detection and preset configurations.Parameters
Device specifier: “auto”, “cuda”, “cuda:0”, or “cpu”. When set to “auto”, automatically selects CUDA if available, otherwise CPU.
Number of GPUs for distributed training. Must be >= 1.
GPU memory in GB, used for auto-tuning batch sizes. Must be >= 1.
Mixed precision dtype for automatic mixed precision (AMP).
Trade compute for memory savings by recomputing activations during backward pass.
Whether running multi-GPU training via torchrun. Automatically set by
from_env().Total number of processes in distributed training. Set by environment variable.
Local process rank, set by torchrun via LOCAL_RANK environment variable.
Methods
from_env
Create config from environment variables set by torchrun or SLURM.LOCAL_RANKandWORLD_SIZEfrom environment- Number of available GPUs
- GPU memory size
- Whether running distributed training
get_torch_device
Returntorch.device for model/tensor placement.
Example
Validation rules
num_gpusmust be >= 1gpu_memory_gbmust be >= 1mixed_precisionmust be “bf16”, “fp16”, or “fp32”
DataConfig
Data loading and corpus configuration for training.Parameters
List of dataset names or paths to mix during training.
Target number of tokens for pretraining (50M default). Must be >= 1000.
Maximum number of epochs to iterate over the data. Must be >= 1.
Number of examples to buffer for shuffling during data loading.
Number of DataLoader worker processes for parallel data loading.
Number of batches to prefetch per worker for better GPU utilization.
Example
Validation rules
datasetslist cannot be emptytokens_targetmust be >= 1000max_epochsmust be >= 1
Hardware presets
LOCAL_RTX3060
Preset for local RTX 3060 (12GB VRAM).- device: “cuda”
- num_gpus: 1
- gpu_memory_gb: 12
- mixed_precision: “bf16”
- gradient_checkpointing: True
GPU_A100
Preset for A100 (80GB VRAM).- device: “cuda”
- num_gpus: 1
- gpu_memory_gb: 80
- mixed_precision: “bf16”
- gradient_checkpointing: True
GPU_H100
Preset for H100 (80GB VRAM).- device: “cuda”
- num_gpus: 1
- gpu_memory_gb: 80
- mixed_precision: “bf16”
- gradient_checkpointing: False (H100 has enough memory)
get_hardware_preset
Get a hardware preset by name.name: One of “local”, “rtx3060”, “a100”, “h100”, or “auto”
Data presets
get_data_preset
Get a data scale preset by name.name: One of “small”, “medium”, “large”, or “xl”
Small preset
- datasets: [“wikitext-2-raw-v1”]
- tokens_target: 10M
- max_epochs: 3
Medium preset
- datasets: [“wikitext-2-raw-v1”, “roneneldan/TinyStories”]
- tokens_target: 100M
- max_epochs: 5
Large preset
- datasets: [“wikitext-2-raw-v1”, “roneneldan/TinyStories”, “openwebtext”]
- tokens_target: 1B
- max_epochs: 1
XL preset
- datasets: [“wikitext-2-raw-v1”, “roneneldan/TinyStories”, “openwebtext”, “bookcorpus”]
- tokens_target: 5B
- max_epochs: 1