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

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
update test paths
Signed-off-by: Alexandros Koumparoulis <[email protected]>
  • Loading branch information
akoumpa committed May 5, 2025
commit bdaf9dd8c0aa9b5f54c43e3e2767c536a3f7f751
13 changes: 11 additions & 2 deletions examples/llm/finetune/automodel.py
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,11 @@ 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 +346,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 +416,10 @@ 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
10 changes: 9 additions & 1 deletion examples/llm/finetune/automodel_vllm.py
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 All @@ -59,4 +67,4 @@
)

print("------------- Output: ", output_deployed)
nm.stop()
nm.stop()
4 changes: 2 additions & 2 deletions tests/functional_tests/L2_HF_Transformer_PEFT_2gpu_FSDP2.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ TRANSFORMERS_OFFLINE=1 coverage run -a --data-file=/workspace/.coverage --source
--strategy fsdp2 \
--ckpt-folder /tmp/hf_peft_ckpt_fsdp2 --auto-resume

TRANSFORMERS_OFFLINE=1 HF_HOME=/home/TestData/automodel/hf_home coverage run -a --data-file=/workspace/.coverage --source=/workspace/nemo examples/llm/peft/automodel.py \
TRANSFORMERS_OFFLINE=1 HF_HOME=/home/TestData/automodel/hf_home coverage run -a --data-file=/workspace/.coverage --source=/workspace/nemo examples/llm/finetune/automodel.py \
--model /home/TestData/akoumparouli/hf_mixtral_2l/ \
--max-steps 3 \
--devices 2 \
--strategy fsdp2
--strategy fsdp2 --lora
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
export TRANSFORMERS_OFFLINE=1
export HF_HOME=/home/TestData/automodel/hf_home
coverage run -a --data-file=/workspace/.coverage --source=/workspace/nemo examples/llm/peft/automodel.py \
coverage run -a --data-file=/workspace/.coverage --source=/workspace/nemo examples/llm/finetune/automodel.py \
--model /home/TestData/akoumparouli/hf_mixtral_2l/ \
--max-steps 3 \
--devices 2 \
--strategy fsdp2 --fp8
--strategy fsdp2 --fp8 --lora
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
export TRANSFORMERS_OFFLINE=1
export HF_HOME=/home/TestData/automodel/hf_home

coverage run -a --data-file=/workspace/.coverage --source=/workspace/nemo examples/llm/peft/automodel.py \
coverage run -a --data-file=/workspace/.coverage --source=/workspace/nemo examples/llm/finetune/automodel.py \
--model /home/TestData/akoumparouli/hf_mixtral_2l/ \
--max-steps 3 \
--devices 2 \
--strategy fsdp2 --liger
--strategy fsdp2 --liger --lora
Loading