Nanotron is an open-source library for pretraining Transformer models, developed by Hugging Face. It provides a simple and flexible API, supports pretraining models on custom datasets, and is designed to be easy to use, fast, and scalable.
In terms of main capabilities, Nanotron has the following features: 3D parallelism (data parallelism DP, tensor parallelism TP, pipeline parallelism PP); expert parallelism for MoE; AFAB and 1F1B schedules for PP; explicit TP and PP APIs for easier debugging; ZeRO-1 optimizer; FP32 gradient accumulation; parameter tying/sharding; custom module checkpointing for large models; spectral µTransfer parameterization for scaling neural networks; precise GPU performance measurement based on CUDA event timing. Its roadmap includes the ZeRO-3 optimizer (i.e., FSDP), torch.compile support, and interleaved 1f1b scheduling.
In terms of usage, the project provides installation and quick start guidance. To run the code, you first need to create a Python virtual environment (for example, using uv), install PyTorch and core dependencies, install the remaining dependencies for running the example scripts, log in to Hugging Face and Weights & Biases accounts, and confirm that the system has Git LFS installed so that models/datasets can be loaded and pushed to the Hugging Face Hub; if it is not installed, it needs to be installed. In the training example, a single command can train a tiny Llama model in about 10 minutes on a single node with 8 H100s, and the model will be saved in the checkpoints directory specified in the configuration file; you can use examples/config_tiny_llama.py to generate your own training configuration. In the generation stage, you can accelerate generation with multiple GPUs by increasing the --tp (tensor parallelism) value, and use a larger --pp (pipeline parallelism) value for very large models. For VSCode debugging, you can add a configuration to launch.json. More examples are provided in the /examples directory.
In terms of applicable scenarios, Nanotron is aimed at researchers and engineers who need to pretrain Transformer models on custom datasets, and is especially suitable for scenarios that require large-scale multi-node, multi-GPU training and value performance and scalability. The project provides a multi-node training (Slurm) guide and a guide for training your first model.
Limitations orInformation not yet provided: specific pricing and charging models are not provided; the ZeRO-3 optimizer, torch.compile support, and interleaved 1f1b scheduling in the roadmap are not yet supported; more detailed benchmark data, configurations, and logs can be found in its ultrascale-playbook-data repository.