Causal shift experiments codebase
uv sync
# --no-cache-dir
uv pip install --no-build-isolation flash-attnpip install .
pip install flash-attnsrc/
├── data/ # Data pre-processing (generate memmap)
├── scripts/ # Example scripts for training
├── config.py # Configuration file
├── eval.py # Evaluate NTP accuracy
├── model.py # Model definition
└── train.py # Training script
# Note: train_gated.py and model_gated.py are for gated models.
Generate memmap files (train.bin and val.bin) for training on 10B tokens from fineweb-edu dataset:
src/data/fineweb-edu/download.sh /path/to/local/dir # download data (parquet)
python src/data/fineweb-edu/prepare.py --path /path/to/local/dir --cache_dir /path/to/cache/dir # generate np memmapThe training scripts will train a GPT2-like model on the fineweb-edu dataset.
See src/scripts/main.sh for an example training script. Make sure you have the data prepared before running the training script.
The script runs a model training on all available GPUs using torchrun.
Also see src/scripts/gated.sh for training a gated model and src/scripts/skip.sh for training a model by pseudo-skipping residual connections.
Note: training should take less than 16 A100 GPU hours.
This repository is built upon the nanoGPT repository.