|
| 1 | +# Config for multi-device full DPO alignment in full_dpo_distributed.py |
| 2 | +# using a Llama2 7B model |
| 3 | +# |
| 4 | +# This config assumes that you've run the following command before launching |
| 5 | +# this run: |
| 6 | +# tune download meta-llama/Llama-2-7b-hf --output-dir /tmp/Llama-2-7b-hf --ignore-patterns "*.safetensors" --hf-token <HF_TOKEN> |
| 7 | +# |
| 8 | +# To launch on 2 devices, run the following command from root: |
| 9 | +# tune run --nnodes 1 --nproc_per_node 2 full_dpo_distributed --config llama2/7B_lora_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 2 full_dpo_distributed --config llama2/7B_lora_dpo checkpointer.checkpoint_dir=<YOUR_CHECKPOINT_DIR> |
| 15 | +# |
| 16 | +# This config works best when the model is being fine-tuned on 2+ GPUs. |
| 17 | +# For single device LoRA DPO alignment please use 7B_lora_dpo_single_device.yaml |
| 18 | + |
| 19 | +# Model Arguments |
| 20 | +model: |
| 21 | + _component_: torchtune.models.sarvam1.sarvam1 |
| 22 | + |
| 23 | +# Tokenizer |
| 24 | +tokenizer: |
| 25 | + _component_: torchtune.models.llama2.llama2_tokenizer |
| 26 | + path: /projects/data/rahul_sarvam_ai/nemo_models/sarvam-1-pt/tokenizer.model |
| 27 | + max_seq_len: 8192 |
| 28 | +output_dir: /projects/data/rahul_sarvam_ai/torchtune_models/dpo_test |
| 29 | + |
| 30 | +checkpointer: |
| 31 | + _component_: torchtune.training.FullModelHFCheckpointer |
| 32 | + checkpoint_dir: /projects/data/rahul_sarvam_ai/models/sarvam-1-torchtune-sft |
| 33 | + checkpoint_files: |
| 34 | + [model-00001-of-00002.safetensors, model-00002-of-00002.safetensors] |
| 35 | + recipe_checkpoint: null |
| 36 | + output_dir: ${output_dir} |
| 37 | + model_type: LLAMA3 |
| 38 | + safe_serialization: True |
| 39 | +resume_from_checkpoint: False |
| 40 | +save_adapter_weights_only: False |
| 41 | + |
| 42 | +# Dataset and Sampler |
| 43 | +dataset: |
| 44 | + _component_: torchtune.datasets.preference_dataset |
| 45 | + source: allenai/llama-3.1-tulu-3-70b-preference-mixture |
| 46 | + split: train |
| 47 | +seed: null |
| 48 | +shuffle: True |
| 49 | +batch_size: 1 |
| 50 | + |
| 51 | +# Optimizer and Scheduler |
| 52 | +optimizer: |
| 53 | + _component_: torch.optim.AdamW |
| 54 | + fused: True |
| 55 | + weight_decay: 0.01 |
| 56 | + lr: 1e-5 |
| 57 | +lr_scheduler: |
| 58 | + _component_: torchtune.training.lr_schedulers.get_cosine_schedule_with_warmup |
| 59 | + num_warmup_steps: 100 |
| 60 | + |
| 61 | +loss: |
| 62 | + _component_: torchtune.rlhf.loss.DPOLoss |
| 63 | + beta: 0.1 |
| 64 | + label_smoothing: 0 |
| 65 | + |
| 66 | +# Training |
| 67 | +epochs: 1 |
| 68 | +max_steps_per_epoch: 1_000_000 |
| 69 | +gradient_accumulation_steps: 8 # Use to increase virtual batch size |
| 70 | +compile: False # pytorch compile, set to true for better perf/memory |
| 71 | + |
| 72 | +# Logging |
| 73 | +metric_logger: |
| 74 | + _component_: torchtune.training.metric_logging.WandBLogger |
| 75 | + # the W&B project to log to |
| 76 | + project: torchtune |
| 77 | +log_every_n_steps: 10 |
| 78 | +log_peak_memory_stats: True |
| 79 | + |
| 80 | +# Environment |
| 81 | +device: cuda |
| 82 | +dtype: bf16 |
| 83 | + |
| 84 | +# Memory management |
| 85 | +enable_activation_checkpointing: True # True reduces memory |
| 86 | +enable_activation_offloading: False # True reduces memory |
0 commit comments