Purpose
Picotron is a minimalist and highly modifiable distributed training framework designed specifically for educational purposes. Inspired by NanoGPT, it aims to help users quickly understand and practice various techniques in distributed training, especially for pretraining Llama-like models.
Main Capabilities
Picotron supports 4D parallelism, namely Data Parallel, Tensor Parallel, Pipeline Parallel, and Context Parallel. Its codebase is very concise and readable; the core files train.py, model.py, as well as data_parallel.py, tensor_parallel.py, pipeline_parallel.py, and context_parallel.py are all under 300 lines of code.
In terms of performance, the project is still under active development and is not optimal. According to official information, 38% MFU (Model FLOPs Utilization) was observed when training the LLaMA-2-7B model on 64 H100 GPUs, and close to 50% MFU when training the SmolLM-1.7B model on 8 H100 GPUs. More benchmarks will be released soon.
Compared with Nanotron, Picotron is mainly aimed at educational purposes, helping people quickly become familiar with all techniques in distributed training.
Usage
Users need to first obtain a token (HF_TOKEN) from Hugging Face to download models.
GPU Environment
- Use create_config.py to generate a configuration file in JSON format, which by default is output to the tmp directory. For example:
python create_config.py --out_dir tmp --exp_name llama-1B --dp 8 --model_name HuggingFaceTB/SmolLM-1.7B --num_hidden_layers 15 --grad_acc_steps 32 --mbs 4 --seq_len 1024 --hf_token < HF_TOKEN >
- Run locally:
torchrun --nproc_per_node 8 train.py --config tmp/llama-1B/config.json
- 3D parallelism example:
python create_config.py --out_dir tmp --dp 4 --tp 2 --pp 2 --pp_engine 1f1b --exp_name llama-7B --model_name meta-llama/Llama-2-7b-hf --grad_acc_steps 32 --mbs 4 --seq_len 1024 --hf_token < HF_TOKEN >
- Slurm submission:
python submit_slurm_jobs.py --inp_dir tmp/llama-7B --qos high --hf_token < HF_TOKEN >
CPU Environment (expected to be slower)
3D parallelism example:
python create_config.py --out_dir tmp --exp_name llama-1B-cpu --dp 2 --tp 2 --pp 2 --pp_engine 1f1b --model_name HuggingFaceTB/SmolLM-1.7B --num_hidden_layers 5 --grad_acc_steps 2 --mbs 4 --seq_len 128 --hf_token < HF_TOKEN > --use_cpu
Run locally:
torchrun --nproc_per_node 8 train.py --config tmp/llama-1B-cpu/config.json
Applicable Scenarios
Picotron is suitable for the following scenarios: learning and teaching distributed training, quickly experimenting with different parallelism strategies, and researching or validating 4D parallelism techniques. It is not suitable for production environments pursuing the highest training performance.
Limitations
- Performance is not optimal and is still under active development.
- It is mainly aimed at educational purposes, and production use requires careful evaluation.
- Specific installation steps, a complete dependency list, and detailed benchmarks are not yet provided.
Citation
If you use Picotron, please cite the project. The tutorial video and code repository can be obtained through the official links provided.