Skip to content

[Bug] sgl router error on /v1/completions in PD mode #8201

@bigerous

Description

@bigerous

Checklist

  • 1. I have searched related issues but cannot get the expected help.
  • 2. The bug has not been fixed in the latest version.
  • 3. Please note that if the bug-related issue you submitted lacks corresponding environment info and a minimal reproducible demo, it will be challenging for us to reproduce and resolve the issue, reducing the likelihood of receiving feedback.
  • 4. If the issue you raised is not a bug but a question, please raise a discussion at https://github.com/sgl-project/sglang/discussions/new/choose Otherwise, it will be closed.
  • 5. Please use English, otherwise it will be closed.

Describe the bug

sgl-router work fine in PD mode when using api /v1/chat/completions. But fails on /v1/completions.

I have some questions about this:

  • Why change CompletionRequest to GenerateReqInput?
  • Why using GenerateReqInput model to request /v1/completions here?

match serde_json::from_value::<CompletionRequest>(body.clone()) {
Ok(openai_req) => {
// Convert OpenAI format to PD format (CompletionRequest -> GenerateReqInput)
let pd_req = openai_req.to_pd_request();
PDRouter::route_generate(self, client, req, pd_req, "/v1/completions").await

Reproduction

sgl-router branch and commit: main(# 429bb0e)

run curl :

curl -v -X POST http://localhost:30000/v1/completions \
 -H "Content-Type: application/json" \
  -d '{
    "model": "Qwen/Qwen2.5-7B-Instruct",
    "prompt": ["列出5个深度学习框架"],
    "max_tokens": 100
  }'

get error response :

< HTTP/1.1 400 Bad Request
< content-length: 794
< date: Mon, 21 Jul 2025 03:28:10 GMT
<
* Connection #0 to host localhost left intact
{"object":"error","message":"[{'type': 'missing', 'loc': ('body', 'prompt'), 'msg': 'Field required', 'input': {'bootstrap_host': ['192.168.0.151'], 'bootstrap_port': [None], 'bootstrap_room': [3282254548847947510], 'input_ids': None, 'model': 'Qwen/Qwen2.5-7B-Instruct', 'parameters': {'max_new_tokens': 100}, 'stream': False, 'text': ['列出5个深度学习框架']}}, {'type': 'string_type', 'loc': ('body', 'bootstrap_host'), 'msg': 'Input should be a valid string', 'input': ['192.168.0.151']}, {'type': 'int_type', 'loc': ('body', 'bootstrap_port'), 'msg': 'Input should be a valid integer', 'input': [None]}, {'type': 'int_type', 'loc': ('body', 'bootstrap_room'), 'msg': 'Input should be a valid integer', 'input': [3282254548847947510]}]","type":"Bad Request","param":null,"code":400}%

Environment

not need

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions