|
| 1 | +# Top-level output directory |
| 2 | +output_dir: ./outputs/Llama-3.2-11B-Instruct-w2-lora |
| 3 | + |
| 4 | +# Model + LoRA settings |
| 5 | +model: |
| 6 | + _component_: torchtune.models.llama3_2_vision.lora_llama3_2_vision_11b |
| 7 | + # preserve your hyperparams |
| 8 | + lora_rank: 8 # higher increases accuracy and memory |
| 9 | + lora_alpha: 16 # usually alpha=2*rank |
| 10 | + lora_dropout: 0.05 |
| 11 | + image_size: 560 # Make sure this matches the image_size in tokenizer |
| 12 | + # example’s fixed settings |
| 13 | + decoder_trainable: "frozen" |
| 14 | + encoder_trainable: "lora" |
| 15 | + fusion_trainable: "lora" |
| 16 | + lora_attn_modules: |
| 17 | + - 'q_proj' |
| 18 | + - 'v_proj' |
| 19 | + - 'output_proj' |
| 20 | + apply_lora_to_mlp: true |
| 21 | + apply_lora_to_output: false |
| 22 | + |
| 23 | +# Tokenizer / vision transform |
| 24 | +tokenizer: |
| 25 | + _component_: torchtune.models.llama3_2_vision.llama3_2_vision_transform |
| 26 | + path: ./Llama-3.2-11B-Vision-Instruct/original/tokenizer.model |
| 27 | + image_size: 560 |
| 28 | + max_seq_len: 8192 |
| 29 | + |
| 30 | +# Checkpointing |
| 31 | +checkpointer: |
| 32 | + _component_: torchtune.training.FullModelHFCheckpointer |
| 33 | + checkpoint_dir: ./Llama-3.2-11B-Vision-Instruct |
| 34 | + checkpoint_files: |
| 35 | + filename_format: model-{}-of-{}.safetensors |
| 36 | + max_filename: "00005" |
| 37 | + recipe_checkpoint: null |
| 38 | + output_dir: ${output_dir} |
| 39 | + model_type: LLAMA3_VISION |
| 40 | + |
| 41 | +resume_from_checkpoint: false |
| 42 | +save_adapter_weights_only: false # PeFT formatting not available yet. This will save it in torchtune format only. |
| 43 | + |
| 44 | +# Dataset |
| 45 | +dataset: |
| 46 | + _component_: torchtune.datasets.multimodal.vqa_dataset |
| 47 | + source: arrow |
| 48 | + data_files: |
| 49 | + train: "fake_w2_us_tax_form_dataset_train30_test70/train/data-00000-of-00001.arrow" |
| 50 | + split: train |
| 51 | + column_map: |
| 52 | + input: input |
| 53 | + output: ground_truth |
| 54 | + image: image |
| 55 | + |
| 56 | +# General data handling |
| 57 | +seed: null |
| 58 | +shuffle: true |
| 59 | +collate_fn: torchtune.data.padded_collate_tiled_images_and_mask |
| 60 | + |
| 61 | +# Training loop & hyperparams |
| 62 | + |
| 63 | +# example’s train-control |
| 64 | +epochs: 5 |
| 65 | +max_steps_per_epoch: null |
| 66 | +batch_size: 1 |
| 67 | +gradient_accumulation_steps: 1 # Use to increase effective batch size |
| 68 | +# explicit optimizer / scheduler / loss |
| 69 | +optimizer: |
| 70 | + _component_: torch.optim.AdamW |
| 71 | + fused: true |
| 72 | + weight_decay: 0.01 |
| 73 | + lr: 1e-4 |
| 74 | +optimizer_in_bwd: true |
| 75 | + |
| 76 | +lr_scheduler: |
| 77 | + _component_: torchtune.training.lr_schedulers.get_cosine_schedule_with_warmup |
| 78 | + num_warmup_steps: 100 |
| 79 | + |
| 80 | +loss: |
| 81 | + _component_: torchtune.modules.loss.LinearCrossEntropyLoss |
| 82 | + |
| 83 | +clip_grad_norm: 1.0 |
| 84 | +compile: false |
| 85 | + |
| 86 | +# Device & memory |
| 87 | +device: cuda |
| 88 | +enable_activation_checkpointing: true |
| 89 | +dtype: bf16 |
| 90 | + |
| 91 | +# Logging |
| 92 | + |
| 93 | +metric_logger: |
| 94 | + _component_: torchtune.training.metric_logging.WandBLogger |
| 95 | + project: llama3_2_w2_extraction |
| 96 | + entity: <your_wandb_entity> |
| 97 | + job_type: lora_finetune_single_device |
| 98 | + group: llama-cookbook |
| 99 | +log_every_n_steps: 5 |
| 100 | +save_steps: 100 |
| 101 | +log_peak_memory_stats: true |
| 102 | +log_level: INFO |
| 103 | + |
| 104 | +# Profiler (off by default) |
| 105 | +profiler: |
| 106 | + _component_: torchtune.training.setup_torch_profiler |
| 107 | + enabled: false |
| 108 | + output_dir: ${output_dir}/profiling_outputs |
| 109 | + cpu: true |
| 110 | + cuda: true |
| 111 | + profile_memory: false |
| 112 | + with_stack: false |
| 113 | + record_shapes: true |
| 114 | + with_flops: false |
| 115 | + wait_steps: 5 |
| 116 | + warmup_steps: 3 |
| 117 | + active_steps: 2 |
| 118 | + num_cycles: 1 |
0 commit comments