-
Notifications
You must be signed in to change notification settings - Fork 36
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
Add truss example for Qwen1.5-110B with vllm & streaming support #282
Open
ImmarKarim
wants to merge
5
commits into
basetenlabs:main
Choose a base branch
from
ImmarKarim:main
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
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
1bcdbbb
Add truss example for Qwen1.5-110B with vllm & streaming support
ImmarKarim ecc0070
Changed the resources section - PR feedback
ImmarKarim 5c90be0
Removed env from config
ImmarKarim ede8d24
Revert "Removed env from config"
ImmarKarim ee5a83a
Fixed all issues
ImmarKarim 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 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,16 @@ | ||
external_package_dirs: [] | ||
model_metadata: | ||
example_model_input: {"prompt": "How long would it take to reach the sun?"} | ||
model_name: Qwen1.5-vllm-streaming | ||
python_version: py310 | ||
requirements: | ||
- torch==2.2.1 | ||
- transformers==4.40.0 | ||
- vllm==0.4.1 | ||
- asyncio==3.4.3 | ||
- ray | ||
resources: | ||
accelerator: A100:4 | ||
use_gpu: true | ||
secrets: {} | ||
system_packages: [] |
Empty file.
This file contains 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,65 @@ | ||
import subprocess | ||
import uuid | ||
from transformers import AutoTokenizer | ||
|
||
from vllm import SamplingParams | ||
from vllm.engine.arg_utils import AsyncEngineArgs | ||
from vllm.engine.async_llm_engine import AsyncLLMEngine | ||
|
||
|
||
class Model: | ||
def __init__(self, model_name="Qwen/Qwen1.5-110B-Chat"): | ||
self.model_name = model_name | ||
self.tokenizer = None | ||
self.sampling_params = None | ||
|
||
command = "ray start --head" | ||
subprocess.check_output(command, shell=True, text=True) | ||
|
||
def load(self): | ||
self.model_args = AsyncEngineArgs( | ||
model=self.model_name, | ||
dtype='auto', | ||
enforce_eager=True, | ||
tensor_parallel_size=4 | ||
|
||
) | ||
|
||
self.tokenizer = AutoTokenizer.from_pretrained(self.model_name) | ||
|
||
self.sampling_params = SamplingParams( # Using default values | ||
temperature=0.7, | ||
top_p=0.8, | ||
repetition_penalty=1.05, | ||
max_tokens=512 | ||
) | ||
|
||
self.llm_engine = AsyncLLMEngine.from_engine_args(self.model_args) | ||
|
||
async def predict(self, model_input): | ||
message = model_input.pop("prompt") | ||
|
||
prompt = [ | ||
{"role": "system", "content": "You are a helpful assistant."}, | ||
{"role": "user", "content": message} | ||
] | ||
|
||
text = self.tokenizer.apply_chat_template( | ||
prompt, | ||
tokenize=False, | ||
add_generation_prompt=True | ||
) | ||
|
||
idx = str(uuid.uuid4().hex) | ||
vllm_generator = self.llm_engine.generate(text, self.sampling_params, idx) | ||
|
||
async def generator(): | ||
full_text = "" | ||
async for output in vllm_generator: | ||
text = output.outputs[0].text | ||
delta = text[len(full_text) :] | ||
full_text = text | ||
yield delta | ||
|
||
return generator() | ||
|
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this is still necessary with newer vlllm versions
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was getting this error without this command. I read it somewhere online to use this if our model loading isn't being done in the main thread.
during pod startup:
During inference: