forked from pytorch/torchtune
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added multinode capabilities for distributed training (#19)
* multinode fsdp finetuning * full dpo
- Loading branch information
1 parent
0fb4536
commit b1e0666
Showing
5 changed files
with
918 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
# Config for multi-device full DPO alignment in full_dpo_distributed.py | ||
# using a Llama2 7B model | ||
# | ||
# This config assumes that you've run the following command before launching | ||
# this run: | ||
# tune download meta-llama/Llama-2-7b-hf --output-dir /tmp/Llama-2-7b-hf --ignore-patterns "*.safetensors" --hf-token <HF_TOKEN> | ||
# | ||
# To launch on 2 devices, run the following command from root: | ||
# tune run --nnodes 1 --nproc_per_node 2 full_dpo_distributed --config llama2/7B_lora_dpo | ||
# | ||
# You can add specific overrides through the command line. For example | ||
# to override the checkpointer directory while launching training | ||
# you can run: | ||
# tune run --nnodes 1 --nproc_per_node 2 full_dpo_distributed --config llama2/7B_lora_dpo checkpointer.checkpoint_dir=<YOUR_CHECKPOINT_DIR> | ||
# | ||
# This config works best when the model is being fine-tuned on 2+ GPUs. | ||
# For single device LoRA DPO alignment please use 7B_lora_dpo_single_device.yaml | ||
|
||
# Model Arguments | ||
model: | ||
_component_: torchtune.models.sarvam1.sarvam1 | ||
|
||
# Tokenizer | ||
tokenizer: | ||
_component_: torchtune.models.llama2.llama2_tokenizer | ||
path: /projects/data/rahul_sarvam_ai/nemo_models/sarvam-1-pt/tokenizer.model | ||
max_seq_len: 8192 | ||
output_dir: /projects/data/rahul_sarvam_ai/torchtune_models/dpo_test | ||
|
||
checkpointer: | ||
_component_: torchtune.training.FullModelHFCheckpointer | ||
checkpoint_dir: /projects/data/rahul_sarvam_ai/models/sarvam-1-torchtune-sft | ||
checkpoint_files: | ||
[model-00001-of-00002.safetensors, model-00002-of-00002.safetensors] | ||
recipe_checkpoint: null | ||
output_dir: ${output_dir} | ||
model_type: LLAMA3 | ||
safe_serialization: True | ||
resume_from_checkpoint: False | ||
save_adapter_weights_only: False | ||
|
||
# Dataset and Sampler | ||
dataset: | ||
_component_: torchtune.datasets.preference_dataset | ||
source: allenai/llama-3.1-tulu-3-70b-preference-mixture | ||
split: train | ||
seed: null | ||
shuffle: True | ||
batch_size: 1 | ||
|
||
# Optimizer and Scheduler | ||
optimizer: | ||
_component_: torch.optim.AdamW | ||
fused: True | ||
weight_decay: 0.01 | ||
lr: 1e-5 | ||
lr_scheduler: | ||
_component_: torchtune.training.lr_schedulers.get_cosine_schedule_with_warmup | ||
num_warmup_steps: 100 | ||
|
||
loss: | ||
_component_: torchtune.rlhf.loss.DPOLoss | ||
beta: 0.1 | ||
label_smoothing: 0 | ||
|
||
# Training | ||
epochs: 1 | ||
max_steps_per_epoch: 1_000_000 | ||
gradient_accumulation_steps: 8 # Use to increase virtual batch size | ||
compile: False # pytorch compile, set to true for better perf/memory | ||
|
||
# Logging | ||
metric_logger: | ||
_component_: torchtune.training.metric_logging.WandBLogger | ||
# the W&B project to log to | ||
project: torchtune | ||
log_every_n_steps: 10 | ||
log_peak_memory_stats: True | ||
|
||
# Environment | ||
device: cuda | ||
dtype: bf16 | ||
|
||
# Memory management | ||
enable_activation_checkpointing: True # True reduces memory | ||
enable_activation_offloading: False # True reduces memory |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.