Repository navigation
[MRV2] Cap torch.topk rows in chunked prompt logprobs - #64914
Merged
Merged
Conversation
torch.topk with k near the vocab size sorts each row, and its workspace grows with rows x k: ~5.5 GiB for a 1024-row chunk over a 152k vocab. That dominated the step's peak for full-vocab prompt logprobs, and the output buffer preallocated since vllm-project#64841 sat on top of it, so a 2048-row prompt peaked at 9.9 GiB, up from 7.5 GiB. Rank each chunk in blocks of at most 64M elements and free each block's results and chunk's logits before the next. Chunks split only for k above ~65k, so smaller k runs as before. For full-vocab prompt logprobs the peak drops to 5.0 GiB at 2048 rows and 11.9 GiB at 8192 (from 15.1), at ~3.5% latency. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Xgy3B2NXY4GnQaw2WwsqpC Signed-off-by: Nick Hill <nickhill123@gmail.com>
Member
Author
|
/ci run |
|
✅ Triggered Buildkite CI #98957 for commit |
Member
Author
|
/ci retry |
|
✅ Triggered Buildkite CI #98968 for commit |
Member
Author
|
/ci retry |
|
✅ No failed, timed-out, or expired jobs need retrying in Buildkite CI #98968. |
Member
Author
|
/ci run |
|
✅ Triggered Buildkite CI #98969 for commit |
fuscof-ibm
reviewed
Nov 1, 2026
ivanium
approved these changes
Nov 2, 2026
Contributor
|
/ci retry |
ivanium
enabled auto-merge (squash)
November 2, 2026 00:56
|
✅ Queued 1 failed job(s) for retry in Buildkite CI #98969. |
Member
Author
|
/ci retry |
|
✅ Triggered Buildkite CI #99030 for commit |
5 of 6 tasks
mvanhorn
added a commit
to mvanhorn/vllm
that referenced
this pull request
Nov 2, 2026
…ogprobs Resolve the conflict in compute_prompt_logprobs_with_chunking by keeping the top-k row cap from vllm-project#64914 and this branch's per-token ranks, so the preallocated ranks tensor stays 2D. Signed-off-by: Matt Van Horn <455140+mvanhorn@users.noreply.github.com>
6 tasks done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Overview
Bound the
torch.topkworkspace in Model Runner V2's chunked prompt-logprobs computation by ranking each logits chunk in row blocks of at most 64M elements. Follow-up to #64841, whose preallocated outputs raised the peak for full-vocab prompt logprobs on short multi-chunk prompts.Claims
kbelow ~65k (e.g. the defaultmax_logprobs=20): each chunk is still ranked in onetopkcall, with identical latency and peak.Validation
GB200,
compute_prompt_logprobs_with_chunkingon a 151936-vocab, 1536-hidden fp16 head, median of 20 runs (5 at full vocab); all variants return identical results:Peak memory for k ≤ 1000 is 0.30–0.37 GiB in every variant.
test_chunked_prompt_logprobs_match_unchunkedgains asplit_topkcase that shrinks the cap so 100-row blocks straddle the chunk boundaries.Details
torch.topkwith k near the vocab size sorts each row; its workspace grows with rows × k, ~5.5 GiB for a 1024-row chunk of a 152k vocab, and was the step's peak. [ModelRunner V2] Reduce peak memory of chunked prompt logprobs #64841 preallocates the whole prompt's outputs after the first chunk, so for a 2-chunk prompt they (plus the previous chunk's still-referenced results) sat on top of the second chunk'stopk. The per-block results and per-chunk logits are now freed before the next block / chunk.max_logprobsprompt logprobs, andtests/entrypoints/openai/chat_completion/test_chat_echo.py(--max-logprobs 151936) reserved ~7.5 GiB for this on an 18 GB H200 MIG slice, leaving no KV cache.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.
🤖 Generated with Claude Code
https://claude.ai/code/session_01Xgy3B2NXY4GnQaw2WwsqpC