Skip to content

Conversation

Abirdcfly
Copy link
Contributor

@Abirdcfly Abirdcfly commented Jul 29, 2025

Essential Elements of an Effective PR Description Checklist

  • The purpose of the PR, such as "Fix some issue (link existing issues this PR will resolve)".
  • The test plan, such as providing test command.
  • The test results, such as pasting the results comparison before and after, or e2e results
  • (Optional) The necessary documentation update, such as updating supported_models.md and examples for a new model.

Purpose

Test Plan

Test Result

(Optional) Documentation Update

Fix #21712

def get_max_tokens(max_model_len: int, request: Union[ChatCompletionRequest,
CompletionRequest],
input_length: int, default_sampling_params: dict) -> int:
max_tokens = getattr(request, "max_completion_tokens",
None) or request.max_tokens

func get_max_tokens used in chat or completions, It first looks for the value of max_completion_tokens, followed by the value of max_tokens, which means that if max_completion_tokens has a value, no matter how much max_tokens is set, it will not take effect.

when use python3 benchmark_serving.py --backend openai-chat --endpoint /v1/chat/completions the req has max_completion_tokens. Therefore, the proxy.py setting max_tokens=1 becomes useless, and only the value of max_completion_tokens is used in vllm serve. :

"max_completion_tokens": request_func_input.output_len,

Copy link

👋 Hi! Thank you for contributing to the vLLM project.

💬 Join our developer Slack at https://slack.vllm.ai to discuss your PR in #pr-reviews, coordinate on features in #feat- channels, or join special interest groups in #sig- channels.

Just a reminder: PRs would not trigger full CI run by default. Instead, it would only run fastcheck CI which starts running only a small and essential subset of CI tests to quickly catch errors. You can run other CI tests on top of those by going to your fastcheck build on Buildkite UI (linked in the PR checks section) and unblock them. If you do not have permission to unblock, ping simon-mo or khluu to add you in our Buildkite org.

Once the PR is approved and ready to go, your PR reviewer(s) can run CI to test the changes comprehensively before merging.

To run CI, PR reviewers can either: Add ready label to the PR or enable auto-merge.

🚀

@mergify mergify bot added the documentation Improvements or additions to documentation label Jul 29, 2025
Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request addresses a bug in the disaggregated serving examples where prefill requests were not correctly limited to generating a single token if the max_completion_tokens parameter was present. The fix correctly sets max_completion_tokens to 1 in addition to max_tokens.

The change is correctly applied for chat completion endpoints. However, in disagg_proxy_demo.py, the fix is missing for the standard completion endpoint (create_completion method), which could lead to the same bug persisting for those requests. I've added a comment to highlight this for a more complete fix.

Copy link
Contributor

@chaunceyjiang chaunceyjiang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch!!

curl http://localhost:10001/v1/chat/completions \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -d '{
    "messages": [
      {"role": "system", "content": "You are a helpful assistant."},
      {"role": "user", "content": "Hello! What can you do?"}
    ],
    "temperature": 0.7,
    "max_completion_tokens": 20
  }'

Indeed, using "max_completion_tokens": 20" can reliably reproduce the issue.

Does tests/v1/kv_connector/nixl_integration/toy_proxy_server.py have the same issue?

@Abirdcfly
Copy link
Contributor Author

Does tests/v1/kv_connector/nixl_integration/toy_proxy_server.py have the same issue?

I just checked these tests, and it seems that there are no tests added for /v1/chat/completions at all. I will add this change in another PR.

Copy link
Contributor

@chaunceyjiang chaunceyjiang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

Thanks~

@DarkLight1337 DarkLight1337 added the ready ONLY add when PR is ready to merge/full CI is needed label Aug 1, 2025
@DarkLight1337 DarkLight1337 enabled auto-merge (squash) August 1, 2025 09:07
@vllm-bot vllm-bot merged commit 5c54d97 into vllm-project:main Aug 1, 2025
52 of 54 checks passed
wenscarl pushed a commit to wenscarl/vllm that referenced this pull request Aug 4, 2025
wenscarl pushed a commit to wenscarl/vllm that referenced this pull request Aug 4, 2025
juuice-lee pushed a commit to juuice-lee/vllm-moe.code that referenced this pull request Aug 5, 2025
x22x22 pushed a commit to x22x22/vllm that referenced this pull request Aug 5, 2025
x22x22 pushed a commit to x22x22/vllm that referenced this pull request Aug 5, 2025
x22x22 pushed a commit to x22x22/vllm that referenced this pull request Aug 5, 2025
npanpaliya pushed a commit to odh-on-pz/vllm-upstream that referenced this pull request Aug 6, 2025
jingyu-ml pushed a commit to jingyu-ml/vllm that referenced this pull request Aug 8, 2025
jinzhen-lin pushed a commit to jinzhen-lin/vllm that referenced this pull request Aug 9, 2025
noamgat pushed a commit to noamgat/vllm that referenced this pull request Aug 9, 2025
paulpak58 pushed a commit to paulpak58/vllm that referenced this pull request Aug 13, 2025
taneem-ibrahim pushed a commit to taneem-ibrahim/vllm that referenced this pull request Aug 14, 2025
BoyuanFeng pushed a commit to BoyuanFeng/vllm that referenced this pull request Aug 14, 2025
diegocastanibm pushed a commit to diegocastanibm/vllm that referenced this pull request Aug 15, 2025
epwalsh pushed a commit to epwalsh/vllm that referenced this pull request Aug 28, 2025
zhewenl pushed a commit to zhewenl/vllm that referenced this pull request Aug 28, 2025
googlercolin pushed a commit to googlercolin/vllm that referenced this pull request Aug 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation ready ONLY add when PR is ready to merge/full CI is needed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug]: P2PNcclConnector Assertion Error for Chat Completeion Endpoint
4 participants