Skip to content

Conversation

@ghphotoframe
Copy link

@ghphotoframe ghphotoframe commented Nov 18, 2025

What this PR does / why we need it?

The logprobs_tensor was not initialized before accessing its token_id
member, leading to a crash when tokenizer.decode() is called by passing a negative token_id

Does this PR introduce any user-facing change?

No

How was this patch tested?

Constructed an inference request with two prompts and set SamplingParams(prompt_logprobs=) (e.g., prompt_logprobs=1).
After applying the fix (proper initialization of logprobs_tensor), the same request completed successfully without errors, and the returned logprobs matched expected values.

@github-actions
Copy link

👋 Hi! Thank you for contributing to the vLLM Ascend project. The following points will speed up your PR merge:‌‌

  • A PR should do only one thing, smaller PRs enable faster reviews.
  • Every PR should include unit tests and end-to-end tests ‌to ensure it works and is not broken by other future PRs.
  • Write the commit message by fulfilling the PR description to help reviewer and future developers understand.

If CI fails, you can run linting and testing checks locally according Contributing and Testing.

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 critical out-of-bounds access bug that could occur when processing prompt logprobs for requests with empty or very short prompts. The fix introduces a necessary check to ensure that logprobs are only processed if there are a positive number of logits to compute. This prevents potential crashes and undefined behavior, making the implementation more robust. The change is correct and effectively resolves the issue.

@ghphotoframe ghphotoframe changed the title Fix out-of-bounds access to token_id due to uninitialized logprobs [Bugfix] Fix out-of-bounds access to token_id due to uninitialized logprobs Nov 18, 2025
@MengqingCao MengqingCao added ready read for review ready-for-test start test by label for PR labels Nov 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready read for review ready-for-test start test by label for PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants