-
-
Notifications
You must be signed in to change notification settings - Fork 8.7k
[Model] Activated LoRA #19710
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
Open
tdoublep
wants to merge
21
commits into
vllm-project:main
Choose a base branch
from
tdoublep:alora
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
[Model] Activated LoRA #19710
Changes from all commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
8a9610e
Initial working implementation of a-LoRA.
tdoublep a68e70b
Fix type hint for query_start_locs
tdoublep b254fb7
vllm/model_executor/layers/linear.py: add comment on torch.compile
tdoublep 3897b1b
vllm/v1/worker/gpu_model_runner.py: remove print statement
tdoublep 24ff376
vllm/v1/core/sched/scheduler.py: remove debug code
tdoublep 412eacd
vllm/envs.py
tdoublep 32098e4
Inject aLoRA behaviour via mixin
tdoublep fb6d28e
Simpler implementation without mixin
tdoublep 5f62d8b
Scan for invocation tokens in one place
tdoublep f9396b0
Just use single field in request
tdoublep 6f36f6d
Use peft_helper instead of reading files directly
tdoublep c6ffe8f
Remove online example for now.
tdoublep 4a4b568
Further simplification; works with chunked prefill; correct output wi…
tdoublep 4cbef84
Add enable_activated_lora engine arg
tdoublep 49a5bdc
Disable tqdm in example
tdoublep a9ac26d
Resolve merge conflicts
tdoublep 5c2e181
Trigger Build
tdoublep ceae7c7
vllm/model_executor/layers/linear.py: check lora_config exists before…
tdoublep 99b8b60
arg_utils.py: fix typo
tdoublep 477ab6e
Additional checking of lora_config
tdoublep 91f39d1
Merge branch 'main' into alora
tdoublep File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
# SPDX-License-Identifier: Apache-2.0 | ||
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project | ||
import os | ||
import time | ||
|
||
import torch | ||
from huggingface_hub import snapshot_download | ||
|
||
from vllm import LLM, SamplingParams | ||
from vllm.lora.request import LoRARequest | ||
|
||
BASE_NAME = "ibm-granite/granite-3.2-8b-instruct" | ||
|
||
ALORA_NAME = "ibm-granite/granite-3.2-8b-alora-uncertainty" | ||
invocation_string = "<|start_of_role|>certainty<|end_of_role|>" | ||
|
||
os.environ["VLLM_USE_V1"] = "1" | ||
|
||
# download your LoRA adapter to ~/.cache/huggingface/… | ||
alora_path = snapshot_download(repo_id=ALORA_NAME) | ||
|
||
print(alora_path) | ||
####################################### | ||
|
||
|
||
llm = LLM( | ||
model=BASE_NAME, | ||
enable_lora=True, | ||
enable_activated_lora=True, | ||
dtype=torch.bfloat16, | ||
max_lora_rank=64, | ||
) | ||
|
||
prompts = [ | ||
( | ||
"<|start_of_role|>user<|end_of_role|>What is MIT?<|end_of_text|>\n" | ||
"<|start_of_role|>assistant<|end_of_role|>" | ||
), | ||
] | ||
|
||
sampling_params = SamplingParams(temperature=0, max_tokens=600) | ||
|
||
outputsBase = llm.generate( | ||
prompts, | ||
sampling_params, | ||
use_tqdm=False, | ||
) | ||
generated_text = [] | ||
for output in outputsBase: | ||
prompt = output.prompt | ||
generated_text += [output.outputs[0].text] | ||
print(f"Prompt: {prompt!r}, Generated text: {generated_text[-1]!r}") | ||
|
||
prompts_alora = [ | ||
x + y + "<|end_of_text|>\n" + invocation_string | ||
for x, y in zip(prompts, generated_text) | ||
] | ||
|
||
sampling_params = SamplingParams(temperature=0, max_tokens=10) | ||
|
||
t0 = time.time() | ||
outputs = llm.generate( | ||
prompts_alora, | ||
sampling_params, | ||
lora_request=LoRARequest("UQ_adapter", 1, alora_path), | ||
use_tqdm=False, | ||
) | ||
t = time.time() - t0 | ||
print(f"Time: {t}") | ||
|
||
for output in outputs: | ||
prompt = output.prompt | ||
generated_text = output.outputs[0].text | ||
print(f"Prompt: {prompt!r}, Generated text: {generated_text!r}") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.