Skip to content

Fix OverflowError in prompt_logprobs when external KV pre-fills prompt - #50795

Open
lililcode9527 wants to merge 1 commit into
vllm-project:mainfrom
lililcode9527:fix/prompt-logprobs-overflow
Open

lililcode9527 wants to merge 1 commit into
vllm-project:mainfrom
lililcode9527:fix/prompt-logprobs-overflow

Conversation

@lililcode9527

@lililcode9527 lililcode9527 commented Aug 3, 2026 •

Copy link
Copy Markdown

When an external KV connector (PD disagg / LMCache / NIXL) advances num_computed_tokens past local-computed, _get_prompt_logprobs_dict ships an unfilled LogprobsTensors.empty_cpu tensor; the stale int32 then overflows u32 in tokenizer.decode -> OverflowError, crashing the engine.

Only ship the logprobs tensor when there is something to fill (num_logits > 0).

Closes #50792

Purpose

In a PD-disaggregated (or any external-KV-connector) setup, a request with prompt_logprobs crashes the decode engine with OverflowError: out of range integral type conversion attempted.

prompt_logprobs needs per-position logits, which come from running the prompt forward. When an external KV connector (Mooncake / NIXL / LMCache) pre-fills the prompt KV, num_computed_tokens advances to prompt_len, so the engine skips the prompt forward and has no logits for the prompt positions.

In _get_prompt_logprobs_dict (vllm/v1/worker/gpu_model_runner.py), the last-chunk branch ships the logprobs tensor before checking whether there is anything to fill:

else:  # last-chunk branch
    num_logits = num_remaining_tokens          # 0 / -1 because num_computed >= N-1
    completed_prefill_reqs.append(req_id)
    prompt_logprobs_dict[req_id] = logprobs_tensors   # ships the tensor
if num_logits <= 0:
    continue                                   # skips the copy_ that fills it

The tensor is created by LogprobsTensors.empty_cpu with torch.empty(dtype=torch.int32) (uninitialized). Since the request is remote-prefilled, this is the first and only entry into the function, so the tensor is shipped without a single copy_. The API server then decodes every id via tokenizer.decode, and a negative stale int32 overflows the u32 conversion in the Rust tokenizer, raising OverflowError.

The local prefix-cache path is not affected because skip_reading_prefix_cache=True (auto-set when prompt_logprobs is enabled) forces a local recompute from position 0; the external connector path does not honor this flag, so num_computed_tokens still jumps to prompt_len.

Fix: only add the tensor to prompt_logprobs_dict when num_logits > 0:

             else:
                 # This is the last chunk of prompt tokens to return.
                 num_logits = num_remaining_tokens
                 completed_prefill_reqs.append(req_id)
-                prompt_logprobs_dict[req_id] = logprobs_tensors
+                if num_logits > 0:
+                    prompt_logprobs_dict[req_id] = logprobs_tensors

Test Plan

Manual reproduction on a PD-disaggregated setup (1 prefiller + 1 decoder + example proxy) with a prompt_logprobs=1 non-streaming request.

Test Result

Setup prompt_logprobs Before After
PD disagg (P+D) yes OverflowError, engine crash no crash, request returns
PD disagg (P+D) no no crash no crash (unchanged)
Single engine, no external connector yes no crash no crash (unchanged)

Before the fix, the decoder logs:

ERROR [async_llm.py:704] AsyncLLM output_handler failed.
File ".../vllm/v1/engine/async_llm.py", line 675, in output_handler
File ".../vllm/v1/engine/output_processor.py", line 648, in process_outputs
File ".../vllm/v1/engine/logprobs.py", line 352, in update_from_output
    self._update_prompt_logprobs(output.new_prompt_logprobs_tensors)
File ".../vllm/v1/engine/logprobs.py", line 147, in _update_prompt_logprobs
    else convert_ids_list_to_tokens(
File ".../vllm/v1/tokenizers/detokenizer_utils.py", line 100, in convert_ids_list_to_tokens
    token_str = tokenizer.decode([token_id])
File ".../vllm/v1/tokenizers/hf.py", line 86, in decode
File ".../transformers/tokenization_utils_tokenizers.py", line 1032, in _decode
    text = self._tokenizer.decode(token_ids, skip_special_tokens=...)
OverflowError: out of range integral type conversion attempted

After the fix, the decoder no longer ships the unfilled tensor; new_prompt_logprobs_tensors is absent so _update_prompt_logprobs skips it, the engine stays alive, and the request returns normally.

A companion proxy-side change (to return real prompt_logprobs by harvesting them from the prefiller) will be filed separately against vllm-ascend, since that logic lives in the disagg example there.


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.

@lililcode9527
lililcode9527 requested a review from njhill as a code owner August 3, 2026 03:06

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Claude Code Review

This pull request is from a fork — automated review is disabled. A repository maintainer can comment @claude review to run a one-time review.

@github-actions

github-actions Bot commented Aug 3, 2026

Copy link
Copy Markdown

👋 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.

PRs do not trigger a full CI run by default. Reviewers with write access and configured trusted contributors can comment /ci run whenever CI signals are needed.

Once the PR is approved or has the ready label, the PR author can also use /ci run or /ci retry. New commits do not start CI automatically.

If you have any questions, please reach out to us on Slack at https://slack.vllm.ai.

Agent Guidelines

IMPORTANT: 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.

🚀

Comment thread vllm/v1/worker/gpu_model_runner.py Outdated
@@ -5672,7 +5672,11 @@ def _get_prompt_logprobs_dict(
# This is the last chunk of prompt tokens to return.
num_logits = num_remaining_tokens
completed_prefill_reqs.append(req_id)
prompt_logprobs_dict[req_id] = logprobs_tensors
if num_logits > 0:

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

this also drops the tensor in the non-remote case the comment three lines down describes: a locally chunked prefill that computed exactly num_prompt_tokens-1 tokens in the prior step lands here with num_logits == 0, but its logprobs_tensors is fully populated from the earlier chunks, and now it never gets into prompt_logprobs_dict (and in_progress_prompt_logprobs_cpu is cleared right after via completed_prefill_reqs). would gating on request.num_computed_tokens == 0, or on whether any chunk was written, separate the two?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Thanks for the catch. Gating on num_logits > 0 also drops the normal chunked-prefill final step (num_logits == 0, but the tensor is already full from earlier chunks). Updated to gate
on "any chunk written" via is_new = (in_progress_prompt_logprobs_cpu is None) at entry:

  • is_new and num_logits <= 0 → externally pre-filled, tensor never written → don't ship (the crash case)
  • not is_new → prior chunk already filled it → ship (the normal final step)
  • num_logits > 0 → something to fill now → ship

num_computed_tokens == 0 doesn't separate them (it's N/N-1 at the last-chunk branch, same as normal). The request is still finalized via completed_prefill_reqs even when skipping
ship, so no re-entry. For PD-disagg, real prompt_logprobs come from a companion proxy fix (vllm-ascend#13366); this core fix handles the crash + normal/local case.

When an external KV connector (PD disagg / LMCache / NIXL) advances
num_computed_tokens past local-computed, _get_prompt_logprobs_dict ships an
unfilled LogprobsTensors.empty_cpu tensor; the stale int32 then overflows
u32 in tokenizer.decode -> OverflowError, crashing the engine.

Only ship the logprobs tensor when there is something to fill (num_logits > 0).

Closes vllm-project#50792

Signed-off-by: lililcode9527 <2445844864@qq.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

mrv1-only Issues/PRs which apply only to Model Runner V1 (not applicable to Model Runner V2)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: OverflowError crash in prompt_logprobs decode path on PD-disaggregated (external KV connector) setup

3 participants