|
| 1 | +# Config for multi-device full DPO alignment in full_dpo_distributed.py |
| 2 | +# using a Llama3.1 8B model |
| 3 | +# |
| 4 | +# This config assumes that you've run the following command before launching |
| 5 | +# this run: |
| 6 | +# tune download meta-llama/Meta-Llama-3.1-8B-Instruct --output-dir /tmp/Meta-Llama-3.1-8B-Instruct --ignore-patterns "original/consolidated.00.pth" |
| 7 | +# |
| 8 | +# To launch on 4 devices, run the following command from root: |
| 9 | +# tune run --nnodes 1 --nproc_per_node 4 full_dpo_distributed --config llama3_1/8B_full_dpo |
| 10 | +# |
| 11 | +# You can add specific overrides through the command line. For example |
| 12 | +# to override the checkpointer directory while launching training |
| 13 | +# you can run: |
| 14 | +# tune run --nnodes 1 --nproc_per_node 4 full_dpo_distributed --config llama3_1/8B_full_dpo checkpointer.checkpoint_dir=<YOUR_CHECKPOINT_DIR> |
| 15 | +# |
| 16 | + |
| 17 | +output_dir: /tmp/torchtune/llama3_1_8B/full_dpo # /tmp may be deleted by your system. Change it to your preference. |
| 18 | + |
| 19 | +# Model Arguments |
| 20 | +model: |
| 21 | + _component_: torchtune.models.llama3_1.llama3_1_8b |
| 22 | + |
| 23 | +# Tokenizer |
| 24 | +tokenizer: |
| 25 | + _component_: torchtune.models.llama3.llama3_tokenizer |
| 26 | + path: /tmp/Meta-Llama-3.1-8B-Instruct/original/tokenizer.model |
| 27 | + max_seq_len: 1024 # higher increases memory |
| 28 | + |
| 29 | +checkpointer: |
| 30 | + _component_: torchtune.training.FullModelHFCheckpointer |
| 31 | + checkpoint_dir: /tmp/Meta-Llama-3.1-8B-Instruct/ |
| 32 | + checkpoint_files: [ |
| 33 | + model-00001-of-00004.safetensors, |
| 34 | + model-00002-of-00004.safetensors, |
| 35 | + model-00003-of-00004.safetensors, |
| 36 | + model-00004-of-00004.safetensors |
| 37 | + ] |
| 38 | + recipe_checkpoint: null |
| 39 | + output_dir: ${output_dir} |
| 40 | + model_type: LLAMA3 |
| 41 | +resume_from_checkpoint: False |
| 42 | + |
| 43 | +# The ref_checkpointer should always point to the original weights. |
| 44 | +ref_checkpointer: |
| 45 | + _component_: torchtune.training.FullModelHFCheckpointer |
| 46 | + checkpoint_dir: /tmp/Meta-Llama-3.1-8B-Instruct/ |
| 47 | + checkpoint_files: [ |
| 48 | + model-00001-of-00004.safetensors, |
| 49 | + model-00002-of-00004.safetensors, |
| 50 | + model-00003-of-00004.safetensors, |
| 51 | + model-00004-of-00004.safetensors |
| 52 | + ] |
| 53 | + recipe_checkpoint: null |
| 54 | + output_dir: ${output_dir} |
| 55 | + model_type: LLAMA3 |
| 56 | + |
| 57 | +# Dataset and Sampler |
| 58 | +dataset: |
| 59 | + _component_: torchtune.datasets.stack_exchange_paired_dataset |
| 60 | +seed: null |
| 61 | +shuffle: True |
| 62 | +batch_size: 4 |
| 63 | + |
| 64 | +# Optimizer and Scheduler |
| 65 | +optimizer: |
| 66 | + _component_: torch.optim.AdamW |
| 67 | + fused: True |
| 68 | + weight_decay: 0.05 |
| 69 | + lr: 2e-5 |
| 70 | +lr_scheduler: |
| 71 | + _component_: torchtune.training.lr_schedulers.get_cosine_schedule_with_warmup |
| 72 | + num_warmup_steps: 20 |
| 73 | + |
| 74 | +loss: |
| 75 | + _component_: torchtune.rlhf.loss.DPOLoss |
| 76 | + beta: 0.05 |
| 77 | + label_smoothing: 0 |
| 78 | + |
| 79 | +# Training |
| 80 | +epochs: 1 |
| 81 | +max_steps_per_epoch: 1000 |
| 82 | +gradient_accumulation_steps: 8 # Use to increase effective batch size |
| 83 | +compile: False # torch.compile the model + loss, True increases speed + decreases memory |
| 84 | + |
| 85 | +# Logging |
| 86 | +metric_logger: |
| 87 | + _component_: torchtune.training.metric_logging.DiskLogger |
| 88 | + log_dir: ${output_dir}/logs |
| 89 | +log_every_n_steps: 1 |
| 90 | +log_peak_memory_stats: True |
| 91 | + |
| 92 | +# Environment |
| 93 | +device: cuda |
| 94 | +dtype: bf16 |
| 95 | + |
| 96 | +# Memory management |
| 97 | +enable_activation_checkpointing: True # True reduces memory |
| 98 | +enable_activation_offloading: False # True reduces memory |
0 commit comments