Skip to content

Commit

Permalink
2024-12-20 nightly release (74e6e7b)
Browse files Browse the repository at this point in the history
  • Loading branch information
pytorchbot committed Dec 20, 2024
1 parent cb4baba commit b2d9463
Show file tree
Hide file tree
Showing 33 changed files with 263 additions and 98 deletions.
4 changes: 3 additions & 1 deletion recipes/configs/eleuther_evaluation.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
# To launch, run the following command from root torchtune directory:
# tune run eleuther_eval --config eleuther_evaluation tasks=["truthfulqa_mc2","hellaswag"]

output_dir: ./ # Not needed

# Model Arguments
model:
_component_: torchtune.models.llama2.llama2_7b
Expand All @@ -14,7 +16,7 @@ checkpointer:
pytorch_model-00001-of-00002.bin,
pytorch_model-00002-of-00002.bin,
]
output_dir: /tmp/Llama-2-7b-hf
output_dir: ${output_dir}
model_type: LLAMA2

# Tokenizer
Expand Down
4 changes: 3 additions & 1 deletion recipes/configs/gemma/evaluation.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
# To launch, run the following command:
# tune run eleuther_eval --config gemma/evaluation

output_dir: ./ # Not needed

# Model Arguments
model:
_component_: torchtune.models.gemma.gemma_2b
Expand All @@ -15,7 +17,7 @@ checkpointer:
model-00001-of-00002.safetensors,
model-00002-of-00002.safetensors,
]
output_dir: ./ # Not needed
output_dir: ${output_dir}
model_type: GEMMA

# Tokenizer
Expand Down
4 changes: 3 additions & 1 deletion recipes/configs/generation.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
# To launch, run the following command from root torchtune directory:
# tune run generate --config generation

output_dir: ./ # Not needed

# Model arguments
model:
_component_: torchtune.models.llama2.llama2_7b
Expand All @@ -14,7 +16,7 @@ checkpointer:
pytorch_model-00001-of-00002.bin,
pytorch_model-00002-of-00002.bin,
]
output_dir: /tmp/Llama-2-7b-hf/
output_dir: ${output_dir}
model_type: LLAMA2

device: cuda
Expand Down
2 changes: 1 addition & 1 deletion recipes/configs/llama2/7B_lora_dpo.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ model:
tokenizer:
_component_: torchtune.models.llama2.llama2_tokenizer
path: /tmp/Llama-2-7b-hf/tokenizer.model
max_seq_len: 1024
max_seq_len: 1024 # higher increases memory

checkpointer:
_component_: torchtune.training.FullModelHFCheckpointer
Expand Down
2 changes: 1 addition & 1 deletion recipes/configs/llama2/7B_lora_dpo_single_device.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ model:
tokenizer:
_component_: torchtune.models.llama2.llama2_tokenizer
path: /tmp/Llama-2-7b-hf/tokenizer.model
max_seq_len: 1024
max_seq_len: 1024 # higher increases memory

checkpointer:
_component_: torchtune.training.FullModelHFCheckpointer
Expand Down
4 changes: 3 additions & 1 deletion recipes/configs/llama2/generation_v2.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
# To launch, run the following command:
# tune run dev/generate_v2 --config llama2/generation_v2

output_dir: ./ # Not needed

# Model arguments
model:
_component_: torchtune.models.llama2.llama2_7b
Expand All @@ -24,7 +26,7 @@ checkpointer:
pytorch_model-00001-of-00002.bin,
pytorch_model-00002-of-00002.bin
]
output_dir: ./
output_dir: ${output_dir}
model_type: LLAMA2

# Device
Expand Down
9 changes: 4 additions & 5 deletions recipes/configs/llama3/8B_qat_lora.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,10 @@ dtype: bf16
enable_activation_checkpointing: False # True reduces memory
enable_activation_offloading: False # True reduces memory

# QAT arguments
quantizer:
_component_: torchtune.training.quantization.Int8DynActInt4WeightQATQuantizer
groupsize: 256

# Profiler (disabled)
profiler:
Expand All @@ -108,8 +112,3 @@ profiler:
warmup_steps: 3
active_steps: 2
num_cycles: 1

# QAT arguments
quantizer:
_component_: torchtune.training.quantization.Int8DynActInt4WeightQATQuantizer
groupsize: 256
2 changes: 1 addition & 1 deletion recipes/configs/llama3_1/8B_lora_dpo.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ model:
tokenizer:
_component_: torchtune.models.llama3.llama3_tokenizer
path: /tmp/Meta-Llama-3.1-8B-Instruct/original/tokenizer.model
max_seq_len: null
max_seq_len: 1024 # higher increases memory

checkpointer:
_component_: torchtune.training.FullModelHFCheckpointer
Expand Down
2 changes: 1 addition & 1 deletion recipes/configs/llama3_1/8B_lora_dpo_single_device.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ model:
tokenizer:
_component_: torchtune.models.llama3.llama3_tokenizer
path: /tmp/Meta-Llama-3.1-8B-Instruct/original/tokenizer.model
max_seq_len: null
max_seq_len: 1024 # higher increases memory

checkpointer:
_component_: torchtune.training.FullModelHFCheckpointer
Expand Down
9 changes: 4 additions & 5 deletions recipes/configs/llama3_1/8B_qat_lora.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,10 @@ dtype: bf16
enable_activation_checkpointing: False # True reduces memory
enable_activation_offloading: False # True reduces memory

# QAT arguments
quantizer:
_component_: torchtune.training.quantization.Int8DynActInt4WeightQATQuantizer
groupsize: 256

# Profiler (disabled)
profiler:
Expand All @@ -111,8 +115,3 @@ profiler:
warmup_steps: 3
active_steps: 2
num_cycles: 1

# QAT arguments
quantizer:
_component_: torchtune.training.quantization.Int8DynActInt4WeightQATQuantizer
groupsize: 256
9 changes: 4 additions & 5 deletions recipes/configs/llama3_2/1B_qat_lora.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,10 @@ dtype: bf16
enable_activation_checkpointing: False # True reduces memory
enable_activation_offloading: False # True reduces memory

# QAT arguments
quantizer:
_component_: torchtune.training.quantization.Int8DynActInt4WeightQATQuantizer
groupsize: 256

# Profiler (disabled)
profiler:
Expand All @@ -107,8 +111,3 @@ profiler:
warmup_steps: 3
active_steps: 2
num_cycles: 1

# QAT arguments
quantizer:
_component_: torchtune.training.quantization.Int8DynActInt4WeightQATQuantizer
groupsize: 256
9 changes: 4 additions & 5 deletions recipes/configs/llama3_2/3B_qat_lora.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,10 @@ dtype: bf16
enable_activation_checkpointing: False # True reduces memory
enable_activation_offloading: False # True reduces memory

# QAT arguments
quantizer:
_component_: torchtune.training.quantization.Int8DynActInt4WeightQATQuantizer
groupsize: 256

# Profiler (disabled)
profiler:
Expand All @@ -108,8 +112,3 @@ profiler:
warmup_steps: 3
active_steps: 2
num_cycles: 1

# QAT arguments
quantizer:
_component_: torchtune.training.quantization.Int8DynActInt4WeightQATQuantizer
groupsize: 256
2 changes: 1 addition & 1 deletion recipes/configs/llama3_2/8B_to_1B_KD_lora_distributed.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ teacher_checkpointer:
model-00004-of-00004.safetensors
]
recipe_checkpoint: null
output_dir: /tmp/Meta-Llama-3.1-8B-Instruct/
output_dir: ${output_dir}
model_type: LLAMA3

# Dataset and Sampler
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ teacher_checkpointer:
model-00004-of-00004.safetensors
]
recipe_checkpoint: null
output_dir: /tmp/Meta-Llama-3.1-8B-Instruct/
output_dir: ${output_dir}
model_type: LLAMA3

# Dataset and Sampler
Expand Down
4 changes: 3 additions & 1 deletion recipes/configs/llama3_2_vision/11B_evaluation.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
# To launch, run the following command from root torchtune directory:
# tune run eleuther_eval --config llama3_2_vision/11B_evaluation

output_dir: ./ # Not needed

# Model arguments
model:
_component_: torchtune.models.llama3_2_vision.llama3_2_vision_11b
Expand All @@ -26,7 +28,7 @@ checkpointer:
checkpoint_files:
filename_format: model-{}-of-{}.safetensors
max_filename: "00005"
output_dir: ./
output_dir: ${output_dir}
model_type: LLAMA3_VISION

# Environment
Expand Down
4 changes: 3 additions & 1 deletion recipes/configs/llama3_2_vision/11B_generation_v2.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
# To launch, run the following command from root torchtune directory:
# tune run dev/generate_v2 --config llama3_2_vision/generation_v2

output_dir: ./ # Not needed

# Model arguments
model:
_component_: torchtune.models.llama3_2_vision.llama3_2_vision_11b
Expand All @@ -25,7 +27,7 @@ checkpointer:
checkpoint_files:
filename_format: model-{}-of-{}.safetensors
max_filename: "00005"
output_dir: ./
output_dir: ${output_dir}
model_type: LLAMA3_VISION

# Device
Expand Down
4 changes: 3 additions & 1 deletion recipes/configs/mistral/evaluation.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
# To launch, run the following command:
# tune run eleuther_eval --config mistral/evaluation

output_dir: ./ # Not needed

# Model Arguments
model:
_component_: torchtune.models.mistral.mistral_7b
Expand All @@ -15,7 +17,7 @@ checkpointer:
pytorch_model-00001-of-00002.bin,
pytorch_model-00002-of-00002.bin
]
output_dir: /tmp/Mistral-7B-v0.1/
output_dir: ${output_dir}
model_type: MISTRAL
resume_from_checkpoint: False

Expand Down
4 changes: 3 additions & 1 deletion recipes/configs/phi3/evaluation.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
# To launch, run the following command:
# tune run eleuther_eval --config phi3/evaluation

output_dir: ./ # Not needed

# Model Arguments
model:
_component_: torchtune.models.phi3.phi3_mini
Expand All @@ -16,7 +18,7 @@ checkpointer:
model-00002-of-00002.safetensors
]
recipe_checkpoint: null
output_dir: /tmp/Phi-3-mini-4k-instruct
output_dir: ${output_dir}
model_type: PHI3_MINI
resume_from_checkpoint: False

Expand Down
4 changes: 3 additions & 1 deletion recipes/configs/quantization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
# To launch, run the following command from root torchtune directory:
# tune run quantize --config quantization

output_dir: /tmp/torchtune/llama2_7B/quantized # /tmp may be deleted by your system. Change it to your preference.

#
# Model arguments
model:
Expand All @@ -16,7 +18,7 @@ checkpointer:
pytorch_model-00002-of-00002.bin,
]
recipe_checkpoint: null
output_dir: /tmp/Llama-2-7b-hf
output_dir: ${output_dir}
model_type: LLAMA2

device: cuda
Expand Down
2 changes: 1 addition & 1 deletion recipes/configs/qwen2/1.5_to_0.5B_KD_lora_distributed.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ teacher_checkpointer:
hf_model_0001_0.pt
]
recipe_checkpoint: null
output_dir: /tmp/Qwen2-1.5B-Instruct-lora-finetune
output_dir: ${output_dir}
model_type: QWEN2

resume_from_checkpoint: False
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ teacher_checkpointer:
model.safetensors
]
recipe_checkpoint: null
output_dir: /tmp/Qwen2-1.5B-Instruct
output_dir: ${output_dir}
model_type: QWEN2

resume_from_checkpoint: False
Expand Down
4 changes: 3 additions & 1 deletion recipes/configs/qwen2/evaluation.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
# To launch, run the following command:
# tune run eleuther_eval --config qwen2/evaluation

output_dir: ./ # Not needed

# Model Arguments
model:
_component_: torchtune.models.qwen2.qwen2_7b
Expand All @@ -17,7 +19,7 @@ checkpointer:
model-00003-of-00004.safetensors,
model-00004-of-00004.safetensors
]
output_dir: ./ # Not needed
output_dir: ${output_dir}
model_type: QWEN2

# Tokenizer
Expand Down
6 changes: 3 additions & 3 deletions recipes/dev/7B_full_early_exit.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
# This config works best for distributed training, hence when the model is being fine-tuned on 2+ GPUs.
#

output_dir: /tmp/torchtune/llama2_7b/full_early_exit # /tmp may be deleted by your system. Change it to your preference.

# Tokenizer
tokenizer:
Expand Down Expand Up @@ -61,7 +62,7 @@ checkpointer:
pytorch_model-00002-of-00002.bin
]
recipe_checkpoint: null
output_dir: /tmp/Llama-2-7b-hf
output_dir: ${output_dir}
model_type: LLAMA2
resume_from_checkpoint: False

Expand Down Expand Up @@ -92,8 +93,7 @@ dtype: bf16
# Logging
metric_logger:
_component_: torchtune.training.metric_logging.DiskLogger
log_dir: ${output_dir}
output_dir: /tmp/topv2-llama2-finetune
log_dir: ${output_dir}/logs
log_every_n_steps: 1
log_peak_memory_stats: True

Expand Down
12 changes: 12 additions & 0 deletions recipes/lora_dpo_distributed.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
DoRALinear,
get_adapter_params,
get_adapter_state_dict,
get_lora_module_names,
get_merged_lora_ckpt,
LoRALinear,
set_trainable_params,
Expand Down Expand Up @@ -595,6 +596,17 @@ def save_checkpoint(
}
)

adapter_config = {
"r": self._lora_rank,
"lora_alpha": self._lora_alpha,
"target_modules": get_lora_module_names(
self._lora_attn_modules,
self._apply_lora_to_mlp,
self._apply_lora_to_output,
),
"peft_type": "LORA",
}
checkpoint_dict.update({training.ADAPTER_CONFIG: adapter_config})
self._checkpointer.save_checkpoint(
checkpoint_dict,
epoch=epoch,
Expand Down
Loading

0 comments on commit b2d9463

Please sign in to comment.