Note: This repository is currently under heavy development.
torchtrain is a native PyTorch library with PyTorch native parallelisms and various training techniques to train large models.
While torchtrain utilizes the PyTorch ecosystem for things like data loading (i.e. HuggingFace datasets), the core functionality is written in PyTorch.
- Designed to be easy to understand, use and extend for different training purposes.
- Minimal changes to the model code, when applying 1D/2D or 3D Parallelisms.
- Modular components instead of monolithic codebase
Install PyTorch from source or install the latest pytorch nightly, then install requirements by
pip install -r requirements.txt
Install additional dev requirements if you want to contribute to the repo:
pip install -r dev-requirements.txt
run the llama debug model locally to verify the setup is correct:
./run_llama_train.sh
To visualize TensorBoard metrics of models trained on a remote server via a local web browser:
-
Make sure
metrics.enable_tensorboard
option is set to true in model training (either from a .toml file or from CLI). -
Set up SSH tunneling, by running the following from local CLI
ssh -L 6006:127.0.0.1:6006 [username]@[hostname]
- Inside the SSH tunnel that logged into the remote server, go to the torchtrain repo, and start the TensorBoard backend
tensorboard --logdir=./torchtrain/outputs/tb
- In the local web browser, go to the URL it provides OR to http://localhost:6006/.
For training on ParallelCluster/Slurm type configurations, you can use the multinode_trainer.slurm file to submit your sbatch job.
Note that you will need to adjust the number of nodes and gpu count to your cluster configs.
To adjust total nodes:
#SBATCH --ntasks=2
#SBATCH --nodes=2
should both be set to your total node count. Then update the srun launch parameters to match:
srun torchrun --nnodes 2
where nnodes is your total node count, matching the sbatch node count above.
To adjust gpu count per node:
If your gpu count per node is not 8, adjust:
--nproc_per_node
in the torchrun command and
#SBATCH --gpus-per-task
in the SBATCH command section.