Skip to content

[automodel] move examples #13434

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

# Run this example with torchrun, for example:
# torchrun --nproc-per-node=8 \
# examples/llm/peft/automodel.py \
# examples/llm/finetune/automodel.py
# --strategy fsdp2 \
# --devices 8 \
# --model meta-llama/Llama-3.2-1B \
Expand Down Expand Up @@ -269,6 +269,9 @@ def main():
'are currently supported only with position_ids and not attention_mask. Hence packed sequences needs to be'
'run with --attn-implementation=flash_attention_2',
)
parser.add_argument(
'--lora', action='store_true', help='Enables LoRA finetuning (PEFT); Default: Supervised fine-tuning (SFT).'
)

args = parser.parse_args()

Expand Down Expand Up @@ -341,7 +344,7 @@ def main():
model,
args.devices,
args.num_nodes,
False,
args.lora,
args.enable_cpu_offload,
dp_size=args.dp_size,
tp_size=args.tp_size,
Expand Down Expand Up @@ -411,6 +414,14 @@ def main():
optim=optimizer,
log=logger(args.ckpt_folder, args.max_steps // 2),
resume=resume,
peft=(
llm.peft.LoRA(
target_modules=['*_proj'],
dim=8,
)
if args.lora
else None
),
)


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,19 @@

parser = argparse.ArgumentParser()
parser.add_argument('--model', required=True, type=str, help="Local path or model name on Hugging Face")
parser.add_argument('--lora', required=True, type=str, default=None, help="Local path of the lora model")
parser.add_argument('--triton-model-name', required=True, type=str, help="Name for the service")
args = parser.parse_args()

exporter = vLLMHFExporter()
exporter.export(model=args.model)
if args.lora is not None:
exporter.add_lora_models(lora_model_name=lora_model_name, lora_model=args.lora_model)
print(
"------------- Output: ",
exporter.forward(input_texts=["How are you doing?"], lora_model_name=lora_model_name),
)
quit()

nm = DeployPyTriton(
model=exporter,
Expand Down
240 changes: 0 additions & 240 deletions examples/llm/peft/automodel.py

This file was deleted.

42 changes: 0 additions & 42 deletions examples/llm/peft/automodel_vllm.py

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,9 @@ def make_strategy(strategy, model, devices, num_nodes, adapter_only=False):
default="quintend/rdr-items",
help="Path to the dataset. Can be a local path or a HF dataset name",
)
parser.add_argument("--peft", type=str, default="none", choices=["lora", "none"], help="Which peft to use")
parser.add_argument(
"--lora", action='store_ture', help='Enables LoRA finetuning (PEFT); Default: Supervised fine-tuning (SFT).'
)
parser.add_argument("--freeze-vision-model", action="store_true", help="Freeze the vision model parameters")
parser.add_argument("--freeze-language-model", action="store_true", help="Freeze the language model parameters")
args = parser.parse_args()
Expand Down Expand Up @@ -119,7 +121,7 @@ def make_strategy(strategy, model, devices, num_nodes, adapter_only=False):
)

peft = None
if args.peft == 'lora':
if args.lora:
peft = llm.peft.LoRA(
target_modules=['*_proj'],
dim=16,
Expand Down
Loading
Loading