Skip to content

Add single lora adapter support for vLLM inference. #1679

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

Merged
merged 1 commit into from
Nov 12, 2024

Conversation

yqchen0205
Copy link
Contributor

Motivation

When evaluating SFT/DPO trained models, vLLM accelerated inference with a single LoRA adapter is often used, but this feature isn’t supported in the source code. Therefore, I added a few lines of code to enable this simple functionality.

Modification

Added a lora_path in opencompass/models/vllm.py and utilized it during generate.

Use cases (Optional)

Now we can use LoRA vLLM inference as shown in the code below.

models = [
dict(
type=VLLM,
abbr='Llama3_8B_LoRA_SFT',
path='llama-3-8b-instruct',
model_kwargs=dict(tensor_parallel_size=2, dtype='bfloat16', seed=0, max_model_len=4096, enable_lora=True,),
max_out_len=100,
max_seq_len=4096,
batch_size=32,
lora_path="Llama3_8B_LoRA_checkpoints/checkpoint-1250/",
generation_kwargs=dict(temperature=0.0, top_p=0.8, max_tokens=1024,),
stop_words=['<|end_of_text|>', '<|eot_id|>'],
run_cfg=dict(num_gpus=2),
)
]

@bittersweet1999 bittersweet1999 merged commit 3ec178f into open-compass:main Nov 12, 2024
5 of 7 checks passed
bittersweet1999 added a commit that referenced this pull request Nov 12, 2024
@yqchen0205 yqchen0205 deleted the add_lora_for_vllm branch November 14, 2024 01:29
stephen-nju pushed a commit to stephen-nju/opencompass that referenced this pull request May 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants