Fix chat CLI GPU loading and request_id validation issues (#40230) #40232
+1
−1
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.
What does this PR do?
This PR fixes two critical bugs in the
transformers chat
CLI that prevent users from using chat:Issue 1: Chat CLI doesn't use GPU by default
Problem: The chat CLI was defaulting to CPU inference even when GPUs are available, leading to slow performance.
Root Cause: The
device
parameter inChatArguments
was hardcoded to"cpu"
instead of"auto"
.Solution: Changed the default from
"cpu"
to"auto"
insrc/transformers/commands/chat.py:249
to match the serving backend behavior.Issue 2: Chat breaks on second message with validation error
Problem: After the first message, subsequent messages fail with error:
"Unexpected keys in the request: {'request_id'}"
Root Cause: The chat client sends a
request_id
field in the request body, but the server's validation schema (TransformersCompletionCreateParamsStreaming
) doesn't recognize this field as valid.Solution: Added
request_id: Optional[str] = None
to the schema insrc/transformers/commands/serving.py:128
to allow this field to pass validation.Testing
ruff check
,ruff format
)Fixes #40230
Before submitting
Pull Request section?
to it if that's the case.
documentation guidelines, and
here are tips on formatting docstrings.
Who can review?