Skip to content

Commit 6eda9ff

Browse files
author
pytorchbot
committed
2025-02-08 nightly release (8c9235e)
1 parent 7665d93 commit 6eda9ff

File tree

7 files changed

+1426
-22
lines changed

7 files changed

+1426
-22
lines changed

.github/workflows/gpu_test.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ jobs:
4646
run: python -m pip install --upgrade pip
4747
- name: Install torch nightly
4848
if: ${{ matrix.torch-version == 'nightly' }}
49-
run: python -m pip install --pre torch torchvision torchao --index-url https://download.pytorch.org/whl/nightly/cu126
49+
run: python -m pip install --pre torch==2.7.0.dev20250201 torchvision==0.22.0.dev20250201 torchao==0.9.0.dev20250201 --index-url https://download.pytorch.org/whl/nightly/cu126
5050
- name: Install torch stable
5151
if: ${{ matrix.torch-version == 'stable' }}
5252
run: python -m pip install torch torchvision torchao

docs/source/recipes/dpo.rst

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ To see the best results when using this recipe, it may be helpful to first fine-
1313
on-distribution for the domain you're interested in. To do this, check out our other fine-tuning recipes in the :ref:`recipe overview <recipes_overview_label>` which
1414
support a variety of SFT paradigms.
1515

16-
After supervised fine-tuning, here is an example of DPO with Llama 3.1 8B:
16+
After supervised fine-tuning, here is an example of using either LoRA-based finetuning, or full-finetuning Llama 3.1 8B with DPO:
1717

1818
.. note::
1919

@@ -27,12 +27,15 @@ After supervised fine-tuning, here is an example of DPO with Llama 3.1 8B:
2727
--ignore-patterns "original/consolidated.00.pth"
2828
--HF_TOKEN <HF_TOKEN>
2929
30-
# run on a single device
30+
# run lora dpo on a single device
3131
tune run lora_dpo_single_device --config llama3_1/8B_lora_dpo_single_device
3232
33-
# run on two gpus
33+
# run lora dpo on two gpus
3434
tune run --nproc_per_node 2 lora_dpo_distributed --config llama3_1/8B_lora_dpo
3535
36+
# run full dpo on four gpus
37+
tune run --nproc_per_node 4 full_dpo_distributed --config llama3_1/8B_full_dpo
38+
3639
It's easy to get started with this recipe with your dataset of choice, including custom local datasets,
3740
and datasets from Hugging Face. Check out our primer on :ref:`preference datasets <preference_dataset_usage_label>` to
3841
see how to do this.
Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
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

Comments
 (0)