Skip to content
프로젝트

LambdaLabsML/distributed-training-guide

GitHub에서 보기

소개

분산 PyTorch 학습 코드를 작성하는 방법에 대한 모범 사례와 가이드입니다.

학습 및 교육

이 수치를 측정하는 방법

측정된 스타 증가

in 24h
0
in 7 days
+1
in 15 days
+3
in 1 month
기록 수집 중

서로 겹치는 기간의 순증가량이며 일별 합계가 아닙니다. 측정값이 없으면 비워 둡니다. 스타는 관심도를 나타내며 품질을 보장하지 않습니다.

README.md

Original

Distributed Training Guide

🔥 News 🔥

Ever wondered how to train a large neural network across a giant cluster? Look no further!

This is a comprehensive guide on best practices for distributed training, diagnosing errors, and fully utilizing all resources available. It is organized into sequential chapters, each with a README.md and a train_llm.py script in them. The readme will discuss both the high level concepts of distributed training, and the code changes introduced in that chapter.

The guide is written entirely in very minimal standard pytorch, using transformers and datasets for models and data, respectively. No other library is used for distributed code - the distributed stuff is entirely in pytorch.

  1. Chapter 1 - A standard Causal LLM training script that runs on a single GPU.
  2. Chapter 2 - Upgrades the training script to support multiple GPUs and to use DDP.
  3. Chapter 3 - Covers how to launch training jobs across clusters with multiple nodes.
  4. Chapter 4 - Upgrades the training script to use FSDP instead of DDP for more optimal memory usage.
  5. Chapter 5 - Upgrades the training script to train Llama-405b.
  6. Chapter 6 - Upgrades our single GPU training script to support tensor parallelism.
  7. Chapter 7 - Upgrades our TP training script to use 2d parallelism (FSDP + TP).
  8. Alternative Frameworks - Covers different frameworks that all work with pytorch under the hood.
  9. Diagnosing Errors - Best practices and how tos for quickly diagnosing errors in your cluster.
  10. Related Topics - Topics that you should be aware of when distributed training.

Questions this guide answers:

  • How do I update a single gpu training/fine tuning script to run on multiple GPUs or multiple nodes?
  • How do I diagnose hanging/errors that happen during training?
  • My model/optimizer is too big for a single gpu - how do I train/fine tune it on my cluster?
  • How do I schedule/launch training on a cluster?
  • How do I scale my hyperparameters when increasing the number of workers?

Best practices for logging stdout/stderr and wandb are also included, as logging is vitally important in diagnosing/debugging training runs on a cluster.

Each of the training scripts is aimed at training a causal language model (i.e. gpt/llama).

Set up

Clone this repo

git clone https://github.com/LambdaLabsML/distributed-training-guide.git

Virtual Environment

cd distributed-training-guide
python3 -m venv venv
source venv/bin/activate
python -m pip install -U pip
pip install -U setuptools wheel
pip install -r requirements.txt
pip install flash-attn --no-build-isolation

wandb

This tutorial uses wandb as an experiment tracker.

wandb login

🦄 Other exciting ML projects at Lambda: ML Times, Text2Video, GPU Benchmark.

관련 프로젝트 살펴보기

불러오는 중…