SuperAPIAI Directory

picotron

github.com · AI developer platforms

Picotron is a minimalist 4D parallel distributed training framework released by Hugging Face, intended for educational purposes. Inspired by NanoGPT, it is designed specifically for pretraining Llama-like models and supports data parallelism, tensor parallelism, pipeline parallelism, and context parallelism. The code is concise and readable; train.py, model.py, and each parallelism module are all under 300 lines, making it suitable for learning and experimenting with distributed training techniques. Performance is still under active development; in measured tests, training LLaMA-2-7B on 64 H100s reaches 38% MFU, and training SmolLM-1.7B on 8 H100s approaches 50% MFU. The framework is mainly aimed at educational scenarios, helping users quickly become familiar with various distributed training techniques. It provides a tutorial video and code repository for building Picotron from scratch. Users need to obtain a token from Hugging Face to download models. It supports GPU and CPU environments, can generate configuration files via create_config.py, run locally with torchrun, or submit Slurm jobs via submit_slurm_jobs.py. Specific installation steps, complete dependencies, and detailed benchmarks are not yet provided.

Open website Alternatives
PricingOpen source开源项目(可免费自部署)

About this tool

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

  1. 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 >
  1. Run locally:
torchrun --nproc_per_node 8 train.py --config tmp/llama-1B/config.json
  1. 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 >
  1. 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.

Up/Down to navigate · Enter to open · ESC to closeBrowse all tools