pip install torch numpy transformers datasets==3.6.0 tiktoken wandb tqdm matplotlib seaborn
git clone https://github.com/microsoft/Tutel.git third_party/tutelDependencies:
- pytorch <3
- numpy <3
transformersfor huggingface transformers <3 (to load GPT-2 checkpoints)datasetsfor huggingface datasets <3 (if you want to download + preprocess OpenWebText)tiktokenfor OpenAI's fast BPE code <3wandbfor optional logging <3tqdmfor progress bars <3tutelfor expert parallelism (the repo falls back tothird_party/tutelif a system install is unavailable)
We first tokenize the dataset, in this case the OpenWebText, an open reproduction of OpenAI's (private) WebText used to train GPT-2:
python data/openwebtext/prepare.pyThis downloads and tokenizes the OpenWebText dataset. It will create a train.bin and val.bin which holds the GPT2 BPE token ids in one sequence, stored as raw uint16 bytes.
Thank you to Andrej Karpathy to providing an awesome starting point for the nanoMoE implementation!
Thank you to the author of this blog upon our code is based.