Skip to content
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

VLLM version support #167

Merged
merged 1 commit into from
Jun 14, 2024
Merged
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
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,7 @@ results_fn_postgres/*.json
.vscode

# all eda notebooks
eda_*.ipynb
eda_*.ipynb

# wandb output (created when running upload_wandb.ipynb)
wandb/
20 changes: 14 additions & 6 deletions utils/api_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from vllm.engine.async_llm_engine import AsyncLLMEngine
from vllm.sampling_params import SamplingParams
from vllm.utils import random_uuid
from vllm import __version__ as vllm_version

TIMEOUT_KEEP_ALIVE = 5 # seconds.
app = FastAPI()
Expand Down Expand Up @@ -56,12 +57,19 @@ async def generate(request: Request) -> Response:
if prompt_token_ids[0] != tokenizer.bos_token_id:
prompt_token_ids = [tokenizer.bos_token_id] + prompt_token_ids

results_generator = engine.generate(
prompt=None,
sampling_params=sampling_params,
request_id=request_id,
prompt_token_ids=prompt_token_ids,
)
if vllm_version >= "0.4.2":
results_generator = engine.generate(
inputs={"prompt_token_ids": prompt_token_ids},
sampling_params=sampling_params,
request_id=request_id,
)
else:
results_generator = engine.generate(
prompt=None,
sampling_params=sampling_params,
request_id=request_id,
prompt_token_ids=prompt_token_ids,
)

# Streaming case
async def stream_results() -> AsyncGenerator[bytes, None]:
Expand Down
Loading