Repository navigation
fix(vllm): support legacy generate session API #15008
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1034,6 +1034,22 @@ def _engine_generate_reasoning_kwargs( | |
| return kwargs | ||
|
|
||
|
|
||
| def _engine_generate_session_kwargs( | ||
| engine_client: Any, session_id: str | None | ||
| ) -> dict[str, str | None]: | ||
| try: | ||
| parameters = inspect.signature(engine_client.generate).parameters.values() | ||
| except (TypeError, ValueError): | ||
| return {"session_id": session_id} | ||
| if any( | ||
| parameter.name == "session_id" | ||
| or parameter.kind is inspect.Parameter.VAR_KEYWORD | ||
| for parameter in parameters | ||
| ): | ||
| return {"session_id": session_id} | ||
| return {} | ||
|
|
||
|
|
||
| def _engine_generate_reasoning_support( | ||
| engine_client: Any, | ||
| ) -> tuple[bool, bool] | None: | ||
|
|
@@ -3258,7 +3274,7 @@ async def generate_tokens( | |
| data_parallel_rank=data_parallel_rank, | ||
| trace_headers=trace_headers, | ||
| priority=priority, | ||
| session_id=session_id, | ||
| **_engine_generate_session_kwargs(self.engine_client, session_id), | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This compatibility helper is applied only to the BaseWorkerHandler token path. Legacy vLLM still receives 🤖 AI FixUse There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This compatibility wrapper is only used by 🤖 AI FixApply |
||
| **_engine_generate_reasoning_kwargs( | ||
| self.engine_client, | ||
| reasoning_ended, | ||
|
coderabbitai[bot] marked this conversation as resolved.
|
||
|
|
@@ -3823,7 +3839,7 @@ async def _generate_text_mode(self, request, context, request_id): | |
| data_parallel_rank=dp_rank, | ||
| trace_headers=trace_headers, | ||
| priority=priority, | ||
| session_id=session_id, | ||
| **_engine_generate_session_kwargs(self.engine_client, session_id), | ||
| ) | ||
|
|
||
| async for res in gen: | ||
|
|
@@ -4022,7 +4038,9 @@ async def _generate_token_mode(self, request, context, request_id): | |
| lora_request=admitted_lora_request, | ||
| trace_headers=trace_headers, | ||
| priority=priority, | ||
| session_id=session_id, | ||
| **_engine_generate_session_kwargs( | ||
| self.engine_client, session_id | ||
| ), | ||
| **_engine_generate_reasoning_kwargs( | ||
| self.engine_client, | ||
| reasoning_ended, | ||
|
|
||
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.
This compatibility guard only covers
BaseWorkerHandler.generate_tokens.DecodeWorkerHandler.generateroutesuse_vllm_tokenizer=Truerequests through_generate_text_mode, which still callsengine_client.generate(..., session_id=session_id)directly, andPrefillWorkerHandler._generate_token_modedoes the same. Both paths therefore still raiseTypeErroron the stated legacy vLLM engine, leaving supported text-mode decode and prefill requests broken.🤖 AI Fix
Apply
_engine_generate_session_kwargsto every remaining directengine_client.generatecall that forwardssession_id, including text-mode decode and prefill generation.