Skip to content

Commit 9dae7f1

Browse files
authored
torchdata integration - multi-dataset and streaming support (#1929)
1 parent c2c6f4a commit 9dae7f1

File tree

9 files changed

+1437
-25
lines changed

9 files changed

+1437
-25
lines changed
Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
# Config for multi-device LoRA finetuning in lora_finetune_distributed_td.py
2+
# using a Llama3.2 11B Vision Instruct model
3+
#
4+
# This config assumes that you've run the following command before launching:
5+
# tune download meta-llama/Llama-3.2-11B-Vision-Instruct --output-dir /tmp/Llama-3.2-11B-Vision-Instruct --ignore-patterns "original/consolidated*"
6+
#
7+
# To launch on 2 devices, run the following command from root:
8+
# tune run --nproc_per_node 2 lora_finetune_distributed_td --config llama3_2_vision/11B_lora_td
9+
#
10+
# You can add specific overrides through the command line. For example
11+
# to override the checkpointer directory while launching training:
12+
# tune run --nproc_per_node 2 lora_finetune_distributed_td --config llama3_2_vision/11B_lora_td checkpointer.checkpoint_dir=<YOUR_CHECKPOINT_DIR>
13+
#
14+
# This config works best when the model is being fine-tuned on 2+ GPUs.
15+
# For single device LoRA finetuning please use 11B_lora_single_device.yaml
16+
# or 11B_qlora_single_device.yaml
17+
18+
# Model arguments
19+
model:
20+
_component_: torchtune.models.llama3_2_vision.lora_llama3_2_vision_11b
21+
decoder_trainable: "frozen"
22+
encoder_trainable: "lora"
23+
fusion_trainable: "lora"
24+
lora_attn_modules: ['q_proj', 'v_proj']
25+
apply_lora_to_mlp: False
26+
apply_lora_to_output: False
27+
lora_rank: 8
28+
lora_alpha: 16
29+
lora_dropout: 0.0
30+
image_size: 560 # Make sure this matches the image_size in tokenizer
31+
32+
# Transform
33+
tokenizer:
34+
_component_: torchtune.models.llama3_2_vision.llama3_2_vision_transform
35+
path: /tmp/Llama-3.2-11B-Vision-Instruct/original/tokenizer.model
36+
image_size: 560
37+
max_seq_len: 8192
38+
39+
# Checkpointer
40+
checkpointer:
41+
_component_: torchtune.training.FullModelHFCheckpointer
42+
checkpoint_dir: /tmp/Llama-3.2-11B-Vision-Instruct/
43+
checkpoint_files:
44+
filename_format: model-{}-of-{}.safetensors
45+
max_filename: "00005"
46+
recipe_checkpoint: null
47+
output_dir: /tmp/Llama-3.2-11B-Vision-Instruct/
48+
model_type: LLAMA3_VISION
49+
resume_from_checkpoint: False
50+
save_adapter_weights_only: False # PeFT formatting not available yet. This will save it in torchtune format only.
51+
52+
# TorchData setup
53+
dataloader:
54+
shuffle: True
55+
collate_fn: torchtune.data.padded_collate_tiled_images_and_mask
56+
parallel_method: thread
57+
num_workers: 4 # Per dataset
58+
pin_memory: true
59+
packed: False # Set to true for great speed ups
60+
prefetch_factor: 2
61+
seed: null
62+
63+
datasets:
64+
- source: HuggingFaceM4/the_cauldron
65+
subset: ocrvqa
66+
split: train
67+
transform:
68+
_component_: torchtune.datasets.multimodal.the_cauldron_transform
69+
weight: 1.0
70+
- source: HuggingFaceM4/the_cauldron
71+
subset: dvqa
72+
split: train
73+
transform:
74+
_component_: torchtune.datasets.multimodal.the_cauldron_transform
75+
weight: 1.0
76+
- source: HuggingFaceM4/the_cauldron
77+
subset: docvqa
78+
split: train
79+
transform:
80+
_component_: torchtune.datasets.multimodal.the_cauldron_transform
81+
weight: 1.0
82+
- source: HuggingFaceM4/the_cauldron
83+
subset: tabmwp
84+
split: train
85+
transform:
86+
_component_: torchtune.datasets.multimodal.the_cauldron_transform
87+
weight: 1.0
88+
89+
# Fine-tuning arguments
90+
epochs: 1
91+
# max_steps_per_epoch is required for progress bar
92+
max_steps_per_epoch: 50
93+
batch_size: 4
94+
gradient_accumulation_steps: 1
95+
optimizer:
96+
_component_: torch.optim.AdamW
97+
fused: True
98+
weight_decay: 0.01
99+
lr: 1e-4
100+
101+
lr_scheduler:
102+
_component_: torchtune.training.lr_schedulers.get_cosine_schedule_with_warmup
103+
num_warmup_steps: 100
104+
loss:
105+
_component_: torchtune.modules.loss.CEWithChunkedOutputLoss
106+
clip_grad_norm: 1.0
107+
compile: True # pytorch compile, set to true for perf/memory improvement
108+
109+
# Training env
110+
device: cuda
111+
112+
# Memory management
113+
enable_activation_checkpointing: True
114+
dtype: bf16
115+
116+
# Logging
117+
output_dir: /tmp/lora-llama3.2-vision-finetune
118+
metric_logger:
119+
_component_: torchtune.training.metric_logging.DiskLogger
120+
log_dir: /tmp/Llama-3.2-11B-Vision-Instruct/logs
121+
log_every_n_steps: 1
122+
log_peak_memory_stats: True

0 commit comments

Comments
 (0)