Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

End-to-End LLM Model Development with Torchtitan and Torchtune #341

Open
wants to merge 856 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
856 commits
Select commit Hold shift + click to select a range
0e7a427
Update README.md
KeitaW Mar 16, 2024
d6e56b2
Update README
KeitaW Mar 17, 2024
5c9ecae
update scripts
KeitaW Mar 17, 2024
b30d471
update log file name
KeitaW Mar 17, 2024
5d160c6
Remove 14k log lines
Mar 18, 2024
736a029
Merge pull request #216 from aws-samples/reduce-build-log-efa-exporter
KeitaW Mar 18, 2024
ae6b020
Merge pull request #215 from aws-samples/pytorch-cpu-ddp-conda-enroot
KeitaW Mar 18, 2024
61ddfa5
Merge pull request #214 from aws-samples/smph-fix-dcgm-exporter-gpu-util
mhuguesaws Mar 18, 2024
098c222
Change nccl version to 2.20.3
mhuguesaws Mar 21, 2024
0e77ca5
Merge pull request #217 from aws-samples/nccl_tests_version_changes
verdimrc Mar 22, 2024
1a88359
smp v2 llama2 training example using fp8
arunkumarl87 Mar 22, 2024
318f9d9
Update 3.container-train.sbatch
KeitaW Mar 25, 2024
3dc358c
Merge pull request #221 from aws-samples/KeitaW-patch-1
verdimrc Mar 25, 2024
bea1b68
Added second subnet for other AWS services which require multi-AZ
shimomut Mar 26, 2024
da7a51d
Removed FSXSecurityGroup as it is unused
shimomut Mar 26, 2024
1de3e5a
Renamed resources to Primary/Backup Subnet
shimomut Mar 26, 2024
018f4e9
Revert "Removed FSXSecurityGroup as it is unused"
shimomut Mar 26, 2024
a474f65
Merge branch 'hyperpod_backup_subnet_20240326'
shimomut Mar 26, 2024
447d45c
Rename 0.crate-conda-env.sh to 0.create-conda-env.sh
sean-smith Mar 27, 2024
c6a146b
Merge pull request #225 from aws-samples/sean-smith-patch-2
KeitaW Mar 27, 2024
67d6af7
Deleted unused security group FSXSecurityGroup
shimomut Mar 26, 2024
8d59eef
Merge pull request #222 from shimomut/main
shimomut Mar 28, 2024
ac8f5bd
Added comments to conda setup scripts
arunkumarl87 Mar 28, 2024
44701fd
Merge pull request #218 from aruncs2005/main
aruncs2005 Mar 28, 2024
73b2ccb
Update 1.conda-train.sbatch
KeitaW Mar 31, 2024
4aa19c5
Update 3.container-train.sbatch
KeitaW Mar 31, 2024
437783a
Merge pull request #229 from aws-samples/KeitaW-patch-1
KeitaW Mar 31, 2024
c608899
updated pytorch version to 2.2
johnbensnyder Mar 31, 2024
3adaa5c
Validate Json in preflight check
sean-smith Apr 1, 2024
7d25c4a
Merge pull request #233 from aws-samples/validate-json
KeitaW Apr 1, 2024
7e76b5d
Adding for ActiveDirectory/LDAPS integration for HyperPod (#224)
shimomut Apr 1, 2024
6fc2e9d
DCGM exporter Updates - added responses to comments. create systemd s…
nghtm Mar 28, 2024
5debc4f
updated comments with references
johnbensnyder Apr 2, 2024
3cf0ea2
Merge pull request #230 from johnbensnyder/fsdp_version_update
verdimrc Apr 2, 2024
13a8b32
smhp: shorter wget log (less 3k lines)
Apr 2, 2024
a069026
smhp: increase apt lock timeout
Apr 2, 2024
0bb48b3
Merge pull request #236 from aws-samples/smhp-shorter-log
KeitaW Apr 2, 2024
a477f22
Merge pull request #227 from nghtm/exporter-updates
mhuguesaws Apr 2, 2024
d46de06
Update setup_conda_env.sh
aruncs2005 Apr 2, 2024
5b748ab
Merge pull request #237 from aruncs2005/main
perifaws Apr 2, 2024
d4c68bb
Merge pull request #235 from aws-samples/smhp-apt-lock-timeout
perifaws Apr 2, 2024
d08ba66
Deprecate chrony timesync
Apr 3, 2024
d53342d
Driver for apply hotfix
Apr 3, 2024
605d9e6
smhp: add hotfix to hold lustre client
Apr 3, 2024
4967a8a
smhp: hotfix to mock gpu .deb package
Apr 3, 2024
b156771
Revert "DCGM exporter Updates - added responses to comments. create s…
mhuguesaws Apr 3, 2024
1e04b44
Enabled Prometheus agent mode.
giuseppeporcelli Apr 3, 2024
43b0f84
Merge pull request #238 from giuseppeporcelli/main
verdimrc Apr 3, 2024
621ac21
Merge pull request #226 from aws-samples/upstream-ppc-v2403.02
verdimrc Apr 3, 2024
69734b2
updated pytorch version to 2.2
johnbensnyder Mar 31, 2024
8cc9fb3
updated comments with references
johnbensnyder Apr 2, 2024
8d5daac
smhp: shorter wget log (less 3k lines)
Apr 2, 2024
bdf9d10
DCGM exporter Updates - added responses to comments. create systemd s…
nghtm Mar 28, 2024
96818b5
Update setup_conda_env.sh
aruncs2005 Apr 2, 2024
521b1b9
smhp: increase apt lock timeout
Apr 2, 2024
046270b
Revert "DCGM exporter Updates - added responses to comments. create s…
mhuguesaws Apr 3, 2024
7b6ce70
Revert "DCGM exporter Updates - added responses to comments. create s…
mhuguesaws Apr 3, 2024
29eb8be
Enabled Prometheus agent mode.
giuseppeporcelli Apr 3, 2024
afa41f3
Enabled Prometheus agent mode.
giuseppeporcelli Apr 3, 2024
d256f8f
Deprecate chrony timesync
Apr 3, 2024
306c8b4
Deprecate chrony timesync
Apr 3, 2024
15c8108
Driver for apply hotfix
Apr 3, 2024
5590534
Driver for apply hotfix
Apr 3, 2024
2621a2c
smhp: add hotfix to hold lustre client
Apr 3, 2024
c537bbc
smhp: add hotfix to hold lustre client
Apr 3, 2024
d0fe50d
smhp: hotfix to mock gpu .deb package
Apr 3, 2024
df1b0e3
smhp: hotfix to mock gpu .deb package
Apr 3, 2024
08fd1b6
Bump pillow from 10.2.0 to 10.3.0 in /3.test_cases/4.DDP
dependabot[bot] Apr 3, 2024
13a441d
use docker restart always for DCGM and EFA NODE containers, to sustai…
nghtm Apr 3, 2024
0625a02
use docker restart always for DCGM and EFA NODE containers, to sustai…
nghtm Apr 3, 2024
ba7a748
Merge branch 'aws-samples:main' into exporter-updates
nghtm Apr 3, 2024
577aace
Merge branch 'aws-samples:main' into exporter-updates
nghtm Apr 3, 2024
84999f2
Merge pull request #240 from nghtm/exporter-updates
mhuguesaws Apr 3, 2024
a73df1b
Merge pull request #240 from nghtm/exporter-updates
mhuguesaws Apr 3, 2024
23f6963
Adding comment why we uninstall ec2-instance-connect (#241)
shimomut Apr 3, 2024
2cd2b1e
Adding comment why we uninstall ec2-instance-connect (#241)
shimomut Apr 3, 2024
8f874e0
Merge pull request #239 from aws-samples/dependabot/pip/3.test_cases/…
perifaws Apr 3, 2024
cb2c9d6
Merge pull request #239 from aws-samples/dependabot/pip/3.test_cases/…
perifaws Apr 3, 2024
06f78ee
pcluster: add a small util script to fetch config from a running cluster
Apr 4, 2024
6343a90
pcluster: add a small util script to fetch config from a running cluster
Apr 4, 2024
6cb9781
smhp: fix issue #243
Apr 5, 2024
6e90775
smhp: fix issue #243
Apr 5, 2024
a73ac66
Merge pull request #244 from aws-samples/smhp-dpkg-retry
verdimrc Apr 5, 2024
fdd246c
Merge pull request #244 from aws-samples/smhp-dpkg-retry
verdimrc Apr 5, 2024
57415ae
start adding deepspeed example
KeitaW Apr 5, 2024
32fe215
start adding deepspeed example
KeitaW Apr 5, 2024
f130f6b
Activate conda environment
sean-smith Apr 5, 2024
3cdb653
Activate conda environment
sean-smith Apr 5, 2024
bdf2487
Merge pull request #245 from aws-samples/sean-smith-patch-2
KeitaW Apr 5, 2024
8c4dae9
Merge pull request #245 from aws-samples/sean-smith-patch-2
KeitaW Apr 5, 2024
a8b8aad
adopt code from megotron-deepspeed repository
KeitaW Apr 7, 2024
29da5fb
adopt code from megotron-deepspeed repository
KeitaW Apr 7, 2024
2da855d
Fix typo in 15.gpt-neox README
KeitaW Apr 7, 2024
58bb612
Fix typo in 15.gpt-neox README
KeitaW Apr 7, 2024
eb891e4
Update README.md
KeitaW Apr 7, 2024
3c88a6f
Update README.md
KeitaW Apr 7, 2024
34ba897
cleanup
KeitaW Apr 7, 2024
e682407
cleanup
KeitaW Apr 7, 2024
74b8479
update readme
KeitaW Apr 7, 2024
d09696c
update readme
KeitaW Apr 7, 2024
ea15006
update
KeitaW Apr 7, 2024
ab93f3c
update
KeitaW Apr 7, 2024
0b214b1
update
KeitaW Apr 7, 2024
525159e
update
KeitaW Apr 7, 2024
e0aa9d0
cleanup
KeitaW Apr 7, 2024
1a39144
cleanup
KeitaW Apr 7, 2024
7d0dfab
Update 2.train-mpt-manual-distributed.sbatch
KeitaW Apr 8, 2024
c05056d
Update 2.train-mpt-manual-distributed.sbatch
KeitaW Apr 8, 2024
18fd145
Merge pull request #248 from aws-samples/KeitaW-patch-2
verdimrc Apr 8, 2024
55d9397
Merge pull request #248 from aws-samples/KeitaW-patch-2
verdimrc Apr 8, 2024
7fffe50
Merge pull request #242 from aws-samples/pcluster-util-fetch-config
verdimrc Apr 8, 2024
b38410a
Merge pull request #242 from aws-samples/pcluster-util-fetch-config
verdimrc Apr 8, 2024
a6f9581
update
KeitaW Apr 8, 2024
538d64f
update
KeitaW Apr 8, 2024
00c07ac
update
KeitaW Apr 8, 2024
fa68fc3
update
KeitaW Apr 8, 2024
6c99cba
update
KeitaW Apr 9, 2024
580e825
update
KeitaW Apr 9, 2024
c0b2a85
update
KeitaW Apr 9, 2024
82a69ea
update
KeitaW Apr 9, 2024
a5ce2b2
removed
KeitaW Apr 9, 2024
8f35ef6
removed
KeitaW Apr 9, 2024
6b28131
Skip incomplete checkpoints in FSDP sample app (#251)
shimomut Apr 10, 2024
d16967a
Skip incomplete checkpoints in FSDP sample app (#251)
shimomut Apr 10, 2024
41052b7
Enable Auto-resume
sean-smith Apr 1, 2024
429fe94
Enable Auto-resume
sean-smith Apr 1, 2024
35af783
Validate provisioning_parameters.json
sean-smith Apr 10, 2024
ef4b597
Validate provisioning_parameters.json
sean-smith Apr 10, 2024
53ba90e
Merge pull request #253 from aws-samples/validate-config
KeitaW Apr 10, 2024
db79703
Merge pull request #253 from aws-samples/validate-config
KeitaW Apr 10, 2024
bffd4e6
Merge pull request #247 from aws-samples/deepspeed
KeitaW Apr 10, 2024
aae94b1
Merge pull request #247 from aws-samples/deepspeed
KeitaW Apr 10, 2024
ea0a581
Bump transformers in /3.test_cases/12.SM-dataparallel-FSDP/scripts
dependabot[bot] Apr 10, 2024
7d2fc9c
Bump transformers in /3.test_cases/12.SM-dataparallel-FSDP/scripts
dependabot[bot] Apr 10, 2024
dac63aa
Bump transformers in /3.test_cases/13.SM-dataparallel-deepspeed/code
dependabot[bot] Apr 10, 2024
a361538
Bump transformers in /3.test_cases/13.SM-dataparallel-deepspeed/code
dependabot[bot] Apr 10, 2024
e7824e8
Merge pull request #255 from aws-samples/dependabot/pip/3.test_cases/…
KeitaW Apr 11, 2024
313712d
Merge pull request #255 from aws-samples/dependabot/pip/3.test_cases/…
KeitaW Apr 11, 2024
dc4c301
Merge pull request #254 from aws-samples/dependabot/pip/3.test_cases/…
KeitaW Apr 11, 2024
b680627
Merge pull request #254 from aws-samples/dependabot/pip/3.test_cases/…
KeitaW Apr 11, 2024
b7f6ff8
Merge pull request #246 from aws-samples/KeitaW-patch-1
verdimrc Apr 11, 2024
284ea5a
Merge pull request #246 from aws-samples/KeitaW-patch-1
verdimrc Apr 11, 2024
efbbe53
nemo-launcher: support nemo-launcher with patch version; increase ver…
Apr 12, 2024
1bca0ff
nemo-launcher: support nemo-launcher with patch version; increase ver…
Apr 12, 2024
654ba82
Merge pull request #258 from aws-samples/nemo-launcher-bcm
KeitaW Apr 12, 2024
b6461fb
Merge pull request #258 from aws-samples/nemo-launcher-bcm
KeitaW Apr 12, 2024
2eca998
torchtune usecase
pbelevich Apr 12, 2024
db51efe
torchtune usecase
pbelevich Apr 12, 2024
6002abb
torchtune usecase
pbelevich Apr 12, 2024
6416560
add initial draft
KeitaW May 19, 2024
a8e5bba
add initial draft
KeitaW May 19, 2024
0105a19
add initial draft
KeitaW May 19, 2024
d5f3555
add docs
KeitaW May 19, 2024
345b729
add docs
KeitaW May 19, 2024
001a09d
add docs
KeitaW May 19, 2024
0b4e8e5
update
KeitaW May 19, 2024
309ef58
update
KeitaW May 19, 2024
2003183
update
KeitaW May 19, 2024
ab5d3d5
reorganize
KeitaW May 19, 2024
2726b58
reorganize
KeitaW May 19, 2024
1e8d3e8
reorganize
KeitaW May 19, 2024
f98accf
update
KeitaW May 20, 2024
4c0c69d
update
KeitaW May 20, 2024
c907933
update
KeitaW May 20, 2024
678f985
current state
KeitaW May 24, 2024
8b65168
current state
KeitaW May 24, 2024
ac4c45f
current state
KeitaW May 24, 2024
27d6967
update
KeitaW May 24, 2024
94a0dbc
update
KeitaW May 24, 2024
e9ac7d2
update
KeitaW May 24, 2024
5b91caf
Make *.sh files executable
pbelevich May 24, 2024
e63f623
Make *.sh files executable
pbelevich May 24, 2024
244db77
Make *.sh files executable
pbelevich May 24, 2024
04adb95
Update 3.test_cases/torchtitan-torchtune/slurm/README.md
KeitaW May 25, 2024
9a3160a
Update 3.test_cases/torchtitan-torchtune/slurm/README.md
KeitaW May 25, 2024
28d43c2
Update 3.test_cases/torchtitan-torchtune/slurm/README.md
KeitaW May 25, 2024
762f21e
Update 3.test_cases/torchtitan-torchtune/slurm/README.md
KeitaW May 25, 2024
7ca1fc9
Update 3.test_cases/torchtitan-torchtune/slurm/README.md
KeitaW May 25, 2024
5f7eb84
Update 3.test_cases/torchtitan-torchtune/slurm/README.md
KeitaW May 25, 2024
f1da782
local change
KeitaW May 25, 2024
690df84
local change
KeitaW May 25, 2024
83a7e2d
local change
KeitaW May 25, 2024
5d8b9b7
update README.md
KeitaW May 25, 2024
e341ec3
update README.md
KeitaW May 25, 2024
fbdb034
update README.md
KeitaW May 25, 2024
c9f8ac7
update README
KeitaW May 25, 2024
45ac55d
update README
KeitaW May 25, 2024
e5ac23f
update README
KeitaW May 25, 2024
fa15546
separate libraries
KeitaW May 26, 2024
f826581
separate libraries
KeitaW May 26, 2024
0d15a9d
separate libraries
KeitaW May 26, 2024
dd13ba0
update README
KeitaW May 26, 2024
daa65b6
update README
KeitaW May 26, 2024
bfb35c6
update README
KeitaW May 26, 2024
ff02c72
move container image
KeitaW May 26, 2024
f55f60d
move container image
KeitaW May 26, 2024
06e6df0
move container image
KeitaW May 26, 2024
0adc47f
update
KeitaW May 26, 2024
948418a
update
KeitaW May 26, 2024
9af9bb9
update
KeitaW May 26, 2024
a55c333
update to make it compatible with SMHP
KeitaW May 26, 2024
13a5aff
update to make it compatible with SMHP
KeitaW May 26, 2024
e24b21a
update to make it compatible with SMHP
KeitaW May 26, 2024
08342fc
update readme
KeitaW May 26, 2024
9db7487
update readme
KeitaW May 26, 2024
c7a8cf0
update readme
KeitaW May 26, 2024
6cb0dc3
update
KeitaW May 26, 2024
5276eda
update
KeitaW May 26, 2024
fbd278e
update
KeitaW May 26, 2024
523de6e
update
KeitaW May 26, 2024
b322db3
update
KeitaW May 26, 2024
3eba59c
update
KeitaW May 26, 2024
19e4cba
update README
KeitaW May 26, 2024
a604cf0
update README
KeitaW May 26, 2024
392d28e
update README
KeitaW May 26, 2024
6a940fb
update script
KeitaW May 26, 2024
fe62d87
update script
KeitaW May 26, 2024
1be9da2
update script
KeitaW May 26, 2024
6d4da01
remove torchtitan
KeitaW May 26, 2024
19dd02c
remove torchtitan
KeitaW May 26, 2024
1e5aedd
remove torchtitan
KeitaW May 26, 2024
7b292ab
update tutorials
KeitaW May 26, 2024
c8ceac8
update tutorials
KeitaW May 26, 2024
e6c47cf
update tutorials
KeitaW May 26, 2024
89b4927
update LoRA part WIP
KeitaW May 27, 2024
b024895
update LoRA part WIP
KeitaW May 27, 2024
b195f0b
update LoRA part WIP
KeitaW May 27, 2024
fbabf38
update
KeitaW May 30, 2024
1026a36
update
KeitaW May 30, 2024
eacd729
update
KeitaW May 30, 2024
33e99e2
update
KeitaW May 30, 2024
ebf995c
update
KeitaW May 30, 2024
e9abb4e
update
KeitaW May 30, 2024
3083036
clean up
KeitaW May 31, 2024
c0397a4
clean up
KeitaW May 31, 2024
7eb0f66
clean up
KeitaW May 31, 2024
3b0d9e6
update
KeitaW May 31, 2024
332285e
update
KeitaW May 31, 2024
d4029d2
update
KeitaW May 31, 2024
ae98bf9
update
KeitaW Jun 2, 2024
64e0724
update
KeitaW Jun 2, 2024
00dfbf5
update
KeitaW Jun 2, 2024
b929043
Merge branch 'torchtitan-torchtune' of github.com:aws-samples/awsome-…
KeitaW Jun 4, 2024
4ac5496
Merge branch 'torchtitan-torchtune' of github.com:aws-samples/awsome-…
KeitaW Jun 4, 2024
952eba3
update
KeitaW Jun 4, 2024
563e807
update
KeitaW Jun 5, 2024
71c33f6
Merge branch 'main' into torchtitan-torchtune
KeitaW Jun 5, 2024
77d4908
Update 3.test_cases/torchtune/slurm/README.md
KeitaW Jun 11, 2024
0133094
Update 3.test_cases/torchtune/slurm/tutorials/e2e-llama3-70b-developm…
KeitaW Jun 11, 2024
f8833b7
Update 3.test_cases/torchtune/slurm/README.md
KeitaW Jun 11, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions 3.test_cases/torchtitan/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@

**Torchtitan** is a pioneering library for large-scale LLM training utilizing native PyTorch. It highlights PyTorch's latest distributed training features through a clean, minimalistic codebase.

Characteristics of Torchtitan include:

* User-friendly design, making it easy to understand, use, and extend for various training purposes.
* Minimal modifications required to the model code for applying 1D, 2D, or upcoming 3D parallelism.
* A modular approach over a monolithic codebase, facilitating quick start-ups.
85 changes: 85 additions & 0 deletions 3.test_cases/torchtitan/pretrain.sbatch
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
#!/bin/bash

# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
# SPDX-License-Identifier: MIT-0

#SBATCH --job-name=pretrain
#SBATCH --nodes=2
#SBATCH --ntasks=2
#SBATCH --gpus-per-node=8 # Number of GPU per node
#SBATCH --output=logs/%x_%j.out # logfile for stdout
#SBATCH --error=logs/%x_%j.err # logfile for stderr, remove it to merge both outputs
#SBATCH --wait-all-nodes=1
#SBATCH --exclusive
set -euxo pipefail

##################################################################
############# Load environment variables #########################
##################################################################
# Load environment variables
if [ ! -f .env ]
then
echo "Please create a .env file with the required environment variables"
exit 1
else
source .env
fi

##################################################################
######### Define EFA/NCCL/Slurm environment variables ############
##################################################################
## EFA settings
export FI_LOG_LEVEL=1
export FI_PROVIDER=efa # change to eth if you want to use ENA for comparisons
export FI_EFA_USE_HUGE_PAGE=0
# https://discuss.pytorch.org/t/nccl-network-is-unreachable-connection-refused-when-initializing-ddp/137352
# https://github.com/pytorch/pytorch/issues/68893
export NCCL_SOCKET_IFNAME=en
export TORCH_NCCL_ASYNC_ERROR_HANDLING=1
export NCCL_DEBUG=INFO
export HOSTNAMES=`scontrol show hostnames "$SLURM_JOB_NODELIST"`
export MASTER_ADDR=$(scontrol show hostnames "$SLURM_JOB_NODELIST" | head -n 1)
export COUNT_NODE=`scontrol show hostnames "$SLURM_JOB_NODELIST" | wc -l`
export NODES=( $( scontrol show hostnames $SLURM_JOB_NODELIST ) )
export NODES_ARRAY=($NODES)
export HEAD_NODE=${NODES_ARRAY[0]}
export MASTER_ADDR=$(hostname --ip-address)
export MASTER_PORT=$RANDOM
export NNODES=$SLURM_JOB_NUM_NODES
export NPROC=$SLURM_GPUS_PER_NODE
export WORLD_SIZE=$(( $NNODES * $NPROC ))

##################################################################
############### Create train config ##############################
##################################################################

if [ ! -d ${FSX_PATH}/tmp ]; then
mkdir -p ${FSX_PATH}/tmp
fi
cat ${PWD}/train_configs/pretrain_llama3_70b.toml | envsubst > ${FSX_PATH}/tmp/pretrain_llama3_70b.toml

##################################################################
################# Set arguments ##################################
##################################################################

: "${CONTAINER_MOUNT:=$FSX_PATH:$FSX_PATH}"
declare -a SRUN_ARGS=(
--container-image $ENROOT_IMAGE
--container-mounts $CONTAINER_MOUNT
)
declare -a TORCHRUN_ARGS=(
# change this to match the number of gpus per node:
--master_addr $MASTER_ADDR
--master_port $RANDOM
--nproc_per_node=8
--nnodes $NNODES
--nnodes=$SLURM_JOB_NUM_NODES
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

--nnodes twice

--rdzv_backend=c10d
--rdzv_endpoint=$(hostname)
)
declare -a TRAIN_ARGS=(
--job.config_file ${FSX_PATH}/tmp/pretrain_llama3_70b.toml
)

srun -l "${SRUN_ARGS[@]}" \
torchrun "${TORCHRUN_ARGS[@]}" ${PWD}/../torchtitan/train.py "${TRAIN_ARGS[@]}"
234 changes: 234 additions & 0 deletions 3.test_cases/torchtitan/slurm/torchtitan.dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,234 @@
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
# SPDX-License-Identifier: MIT-0

####################################################################################################
# This is a sample Dockerfile, with optional stanzas. Please read through this Dockerfile,
# understand what it does, then create your own Dockerfile.
#
# Sample build instructions:
#
# docker build --progress=plain -t nvidia-pt-od:latest -f 0.nvcr-pytorch-aws.dockerfile .
# rm /fsx/nvidia-pt-od__latest.sqsh ; enroot import -o /fsx/nvidia-pt-od__latest.sqsh dockerd://nvidia-pt-od:latest
#
# Compute nodes (aka build nodes) are transient, so we need to keep the docker image on shared fs,
# which head node can load into its local registry.
#
# # Build node: save image to file
# docker save nvidia-pt-od:latest > /fsx/nvidia-pt-od__latest.tar
#
# # Load image to local docker registry -> on head node, or new compute/build node.
# docker load < /fsx/nvidia-pt-od__latest.tar
####################################################################################################
FROM nvcr.io/nvidia/pytorch:24.04-py3
ENV DEBIAN_FRONTEND=noninteractive

# The three must-be-built packages.
# Efa-installer>=1.29.0 required for nccl>=2.19.0 to avoid libfabric NCCL error.
ARG EFA_INSTALLER_VERSION=1.31.0
ARG AWS_OFI_NCCL_VERSION=v1.8.1-aws
ARG NCCL_TESTS_VERSION=2.13.9
ARG NCCL_VERSION=2.20.3-1

RUN apt-get update -y
RUN apt-get remove -y --allow-change-held-packages \
libmlx5-1 ibverbs-utils libibverbs-dev libibverbs1

# We noticed that since 23.09, we can't just delete the whole /opt/hpcx/, otherwise `import torch`
# complains about missing libuc?.so.
RUN rm -rf /opt/hpcx/ompi \
&& rm -rf /usr/local/mpi \
&& rm -rf /opt/hpcx/nccl_rdma_sharp_plugin \
&& ldconfig
ENV OPAL_PREFIX=
RUN DEBIAN_FRONTEND=noninteractive apt-get install -y --allow-unauthenticated \
git \
gcc \
vim \
kmod \
openssh-client \
openssh-server \
build-essential \
curl \
autoconf \
libtool \
gdb \
automake \
cmake \
apt-utils \
libhwloc-dev \
aptitude && \
DEBIAN_FRONTEND=noninteractive apt autoremove -y

# EFA
RUN apt-get update && \
cd /tmp && \
curl -O https://efa-installer.amazonaws.com/aws-efa-installer-${EFA_INSTALLER_VERSION}.tar.gz && \
tar -xf aws-efa-installer-${EFA_INSTALLER_VERSION}.tar.gz && \
cd aws-efa-installer && \
# ONLY add `--skip-kmod`, `--no-verify` and `--skip-limit-conf` flags to container image.
# Those three flags must NOT be used on the host.
#
# Explanations:
# - to build EFA in the Dockerfile, we added --skip-kmod and --no-verify. Without these flags,
# the Dockerfile will fail to build. If installing EFA on the host and not in a container,
# please remove these flags.
# - The --skip-limit-conf can be retained in Dockerfile, but it's redundant as the host already
# has these limits set by efa_installer.
./efa_installer.sh -y -g -d --skip-kmod --no-verify --skip-limit-conf && \
ldconfig && \
rm -rf /tmp/aws-efa-installer /var/lib/apt/lists/*
ENV LD_LIBRARY_PATH=/opt/amazon/efa/lib:$LD_LIBRARY_PATH
ENV PATH=/opt/amazon/efa/bin:/opt/amazon/openmpi/bin:$PATH


####################################################################################################
# [CUSTOM_NCCL_OPTION_1] Uncomment below stanza to install another NCCL version using the official
# binaries.
#
# NCCL EFA plugin (aws-ofi-nccl) depends on mpi, hence we must rebuild openmpi before building the
# aws-ofi-ccnl.
####################################################################################################
# RUN cd /opt && \
# wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2004/x86_64/cuda-keyring_1.0-1_all.deb && \
# dpkg -i cuda-keyring_1.0-1_all.deb && \
# apt update && \
# apt install -y libnccl2==${NCCL_VERSION} libnccl-dev==${NCCL_VERSION} && \
# echo NCCL_SOCKET_IFNAME=^docker0,lo >> /etc/nccl.conf


####################################################################################################
# [CUSTOM_NCCL_OPTION_2] Install NCCL from source to the same location as the built-in ones. The
# benefits of installing to the same location as the built-in version are:
#
# 1. There's only ever a single libnccl version offered by this image, preventing application from
# mistakenly chooses a wrong version.
# 2. No longer needing extra settings for LD_LIBRARY_PATH or LD_PRELOAD.
#
# NCCL EFA plugin (aws-ofi-nccl) depends on mpi, hence we must rebuild openmpi before building the
# aws-ofi-ccnl.
####################################################################################################
RUN cd /tmp \
&& git clone https://github.com/NVIDIA/nccl.git -b v${NCCL_VERSION} \
&& cd nccl \
&& make -j src.build BUILDDIR=/usr \
# Build for p4 & p5.
NVCC_GENCODE="-gencode=arch=compute_90,code=sm_90, -gencode=arch=compute_80,code=sm_80" \
&& rm -rf /tmp/nccl \
&& echo NCCL_SOCKET_IFNAME=^docker0,lo >> /etc/nccl.conf


####################################################################################################
# Rebuild OpenMPI with custom PMIX version. E.g., to match what host's Slurm is built with (see
# /opt/pmix/ on host, or run pmix_info on host).
#
# May be needed on rare occassions when `srun --mpi=pmix --container-image=... <mpi_application>`
# mysteriously crashes.
#
# NCCL EFA plugin (aws-ofi-nccl) depends on mpi, hence we must rebuild openmpi before building the
# aws-ofi-ccnl.
####################################################################################################
ENV OPEN_MPI_PATH=/opt/amazon/openmpi

# OpenMPI build script claims PMIX_VERSION, and complains if we use it.
ENV CUSTOM_PMIX_VERSION=4.2.6
RUN apt-get update && apt-get install -y libevent-dev \
&& cd /tmp \
&& wget https://github.com/openpmix/openpmix/releases/download/v${CUSTOM_PMIX_VERSION}/pmix-${CUSTOM_PMIX_VERSION}.tar.gz \
&& tar -xzf pmix-${CUSTOM_PMIX_VERSION}.tar.gz \
&& rm pmix-${CUSTOM_PMIX_VERSION}.tar.gz \
&& cd pmix-${CUSTOM_PMIX_VERSION}/ \
&& ./autogen.pl \
&& ./configure --prefix=/opt/pmix \
&& make -j \
&& make install \
&& echo /opt/pmix/lib > /etc/ld.so.conf.d/pmix.conf \
&& ldconfig \
&& cd / \
&& rm -fr /tmp/pmix-${CUSTOM_PMIX_VERSION}/
# To silence this runtime error message:
# [p4de-st-p4de-2:110912] PMIX ERROR: ERROR in file gds_ds12_lock_pthread.c at line 168
ENV PMIX_GDS_MODULE=^ds12 \
PMIX_MCA_gds=^ds12

# Rebuild openmpi with DLC style (which it remarks as "without libfabric"), with the above pmix.
ENV OMPI_VERSION=4.1.6
RUN rm -fr ${OPEN_MPI_PATH} \
&& mkdir /tmp/openmpi \
&& cd /tmp/openmpi \
&& wget --quiet https://download.open-mpi.org/release/open-mpi/v4.1/openmpi-${OMPI_VERSION}.tar.gz \
&& tar zxf openmpi-${OMPI_VERSION}.tar.gz \
&& rm openmpi-${OMPI_VERSION}.tar.gz \
&& cd openmpi-${OMPI_VERSION} \
&& ./configure --enable-orterun-prefix-by-default --prefix=$OPEN_MPI_PATH --with-cuda=${CUDA_HOME} --with-slurm --with-pmix=/opt/pmix \
&& make -j $(nproc) all \
&& make install \
&& ldconfig \
&& cd / \
&& rm -rf /tmp/openmpi \
&& ompi_info --parsable --all | grep mpi_built_with_cuda_support:value \
# Verify pmix from /opt/pmix/
&& ldd /opt/amazon/openmpi/lib/openmpi/mca_pmix_ext3x.so | grep '/opt/pmix/lib/libpmix.so.* ' > /opt/amazon/openmpi-pmix.txt
####################################################################################################


## NCCL EFA Plugin
#RUN mkdir -p /tmp && \
# cd /tmp && \
# curl -LO https://github.com/aws/aws-ofi-nccl/archive/refs/tags/v${AWS_OFI_NCCL_VERSION}.tar.gz && \
# tar -xzf /tmp/v${AWS_OFI_NCCL_VERSION}.tar.gz && \
# rm /tmp/v${AWS_OFI_NCCL_VERSION}.tar.gz && \
# mv aws-ofi-nccl-${AWS_OFI_NCCL_VERSION} aws-ofi-nccl && \
# cd /tmp/aws-ofi-nccl && \
# ./autogen.sh && \
# ./configure --prefix=/opt/amazon/efa \
# --with-libfabric=/opt/amazon/efa \
# --with-cuda=/usr/local/cuda \
# --enable-platform-aws \
# --with-mpi=/opt/amazon/openmpi && \
# make -j$(nproc) install && \
# rm -rf /tmp/aws-ofi/nccl

###################################################
## Install AWS-OFI-NCCL plugin
RUN apt-get install libtool autoconf cmake nasm unzip pigz parallel nfs-common build-essential hwloc libhwloc-dev libjemalloc2 libnuma-dev numactl libjemalloc-dev preload htop iftop liblapack-dev libgfortran5 ipcalc wget curl devscripts debhelper check libsubunit-dev fakeroot pkg-config dkms -y
RUN export OPAL_PREFIX="" \
&& git clone https://github.com/aws/aws-ofi-nccl.git /opt/aws-ofi-nccl \
&& cd /opt/aws-ofi-nccl \
&& git checkout ${AWS_OFI_NCCL_VERSION} \
&& ./autogen.sh \
&& ./configure --prefix=/opt/aws-ofi-nccl/install \
--with-mpi=/opt/amazon/openmpi \
--with-libfabric=/opt/amazon/efa \
--with-cuda=/usr/local/cuda \
--enable-platform-aws \
&& make -j $(nproc) && make install


# Do this to minimize the ld path env vars that users need to define when running this image.
RUN echo "/usr/local/lib" >> /etc/ld.so.conf.d/local.conf && \
echo "/opt/amazon/openmpi/lib" >> /etc/ld.so.conf.d/efa.conf && \
ldconfig

ENV OMPI_MCA_pml=^cm,ucx \
OMPI_MCA_btl=tcp,self \
OMPI_MCA_btl_tcp_if_exclude=lo,docker0 \
OPAL_PREFIX=/opt/amazon/openmpi \
# https://discuss.pytorch.org/t/nccl-network-is-unreachable-connection-refused-when-initializing-ddp/137352
# https://github.com/pytorch/pytorch/issues/68893
NCCL_SOCKET_IFNAME=^docker,lo

ENV LD_LIBRARY_PATH="/usr/local/lib:/usr/local/cuda/lib64:${LD_LIBRARY_PATH}"

# NCCL-tests: always good to include this as a diagnostic tool.
RUN git clone https://github.com/NVIDIA/nccl-tests.git /opt/nccl-tests \
&& cd /opt/nccl-tests \
&& git checkout v${NCCL_TESTS_VERSION} \
&& make MPI=1 \
MPI_HOME=/opt/amazon/openmpi \
CUDA_HOME=/usr/local/cuda \
NVCC_GENCODE="-gencode=arch=compute_90,code=sm_90 -gencode=arch=compute_80,code=sm_80"


RUN pip install accelerate appdirs loralib bitsandbytes datasets fire peft transformers>=4.40.0 sentencepiece wandb vllm gradio openai
RUN pip install hydra-core huggingface_hub safetensors tiktoken blobfile>=2 tqdm torchao==0.1 lm_eval==0.4.*
RUN pip uninstall -y transformer-engine
2 changes: 2 additions & 0 deletions 3.test_cases/torchtune/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
torchtune
.env
28 changes: 28 additions & 0 deletions 3.test_cases/torchtune/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# End-to-End LLM Model Development with Torchtune <!-- omit in toc -->

This guide demonstrates the comprehensive process of developing a Large Language Model (LLM) from start to finish using [Torchtune](https://github.com/pytorch/torchtune). The journey of creating an LLM encompasses five pivotal steps:

![LLMOps](docs/LLMOps.png)

1. **(Continuous) Pretraining the Language Model**: Next, the language model undergoes pretraining on a vast corpus of text data. This step can be bypassed if starting with an already pretrained model. Pretraining is essential for the model to learn the general patterns and structures of language. Refer `torchtitan` test case for the large scale pretraining with the latest techniques such as 3D parallelism and `torch.compile`.

2. **Instruction Tuning**: The pretrained model is then fine-tuned to cater to specific tasks by updating its parameters with a new dataset. This process involves partially retraining the model with samples that exemplify the desired behavior, thus refining the model weights for the particular application.

3. **Aligment**: The pretrained model is then fine-tuned to cater to specific tasks by updating its parameters with a new dataset. This process involves partially retraining the model with samples that exemplify the desired behavior, thus refining the model weights for the particular application.

4. **Evaluation**: Evaluating the LLM's performance is a critical step. It involves using various metrics to assess the model's accuracy and effectiveness. This step is vital for validating new techniques and objectively comparing different model releases.

5. **Deployment**: Upon achieving the desired performance, the model is deployed as an API. This deployment enables the model's integration into applications, making it accessible to users and other systems.

Following these steps allows for the iterative development and refinement of a Large Language Model to meet specific needs and ensure its successful deployment. This guide specifically addresses all steps except the initial data preparation. The pretraining phase is facilitated by Torchtitan, while Torchtune manages the fine-tuning and evaluation phases.

**Torchtune** emerges as a PyTorch-native library dedicated to the easy authoring, fine-tuning, and experimentation with LLMs, proudly announcing its alpha release.

Features of Torchtune encompass:

* Native-PyTorch implementations of renowned LLMs using composable and modular building blocks.
* Straightforward and adaptable training recipes for popular fine-tuning techniques such as LoRA and QLoRA, emphasizing a PyTorch-centric approach without the need for trainers or frameworks.
* YAML configurations for simplifying the setup of training, evaluation, quantization, or inference recipes.
* Comprehensive support for numerous popular dataset formats and prompt templates, ensuring a smooth start to training endeavors.

This case study provides examples for two schedulers, Slurm and Kubernetes, with detailed instructions available in the `slurm` or `kubernetes` subdirectories.
Binary file added 3.test_cases/torchtune/docs/LLMOps.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file.
Loading