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

[Bug]: Invalid inputs do not result in error #4339

Closed
dyastremsky opened this issue Apr 24, 2024 · 5 comments · Fixed by #4355
Closed

[Bug]: Invalid inputs do not result in error #4339

dyastremsky opened this issue Apr 24, 2024 · 5 comments · Fixed by #4355
Labels
bug Something isn't working

Comments

@dyastremsky
Copy link

Your current environment

Start vLLM: docker run --gpus all -v ~/.cache/huggingface:/root/.cache/huggingface -p 8000:8000 --ipc=host vllm/vllm-openai:latest --model gpt2 --dtype float16 --max-model-len 1024

🐛 Describe the bug

When running inference with vLLM, errors are not returned when an invalid input is supplied.

After starting vLLM as specified above, run a curl command that supplies invalid inputs: curl http://localhost:8000/v1/chat/completions -H "Content-Type: application/json" -d '{ "model": "gpt2", "messages": [ { "role": "system", "content": "You are a helpful assistant.", "fake_input": "2" }, { "role": "user", "content": "Hello!", "fake_input": "3" } ] }'

You get a successful response. Fake_input is dropped instead of returning an error. This silent failure can be dangerous with typos or invalid inputs. Can this be fixed?

@dyastremsky dyastremsky added the bug Something isn't working label Apr 24, 2024
@simon-mo
Copy link
Collaborator

Thanks for raising this issue. It does puzzle me why it happen since we have the pydantic model defined here

class ChatCompletionRequest(BaseModel):

and fastapi reference here
async def create_chat_completion(request: ChatCompletionRequest,

We also did not enable extra fields allowed.

@simon-mo
Copy link
Collaborator

Any help appreciated!

@DarkLight1337
Copy link
Member

DarkLight1337 commented Apr 25, 2024

The default setting in Pydantic (as documented here) silently drops extra fields.

In order to disallow extra fields, we have to explicitly disable it in the model class (extra="forbid"). Going to open a PR shortly.

@DarkLight1337
Copy link
Member

DarkLight1337 commented Apr 25, 2024

I have tested this and found that there is another reason why invalid keys in messages isn't being checked. Currently, messages is being annotated as Dict[str, str] so the schema is not fully specified. PR #3467 improves the type annotations but still does not limit the allowed keys. To fix this issue, I'm going to port over some type annotations from my WIP PR #4200.

Edit: Opened PR #4355.

@dyastremsky
Copy link
Author

Wow, that was lightning fast, @DarkLight1337 and @simon-mo. Thanks for working on this so quickly!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants