Skip to content

[Sampler] Support returning final logprobs#22387

Merged
njhill merged 34 commits intovllm-project:mainfrom
22quinn:topk-topp-logprobs
Aug 21, 2025
Merged

[Sampler] Support returning final logprobs#22387
njhill merged 34 commits intovllm-project:mainfrom
22quinn:topk-topp-logprobs

Conversation

@22quinn
Copy link
Collaborator

@22quinn 22quinn commented Aug 6, 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

RL workflows may need to get the final logprobs, after applying all logit processors including top_k/top_p, temperature. This PR updates the logprobs_mode's processed_logprobs, processed_logits to return the final values.

Test Plan

pytest tests/v1/sample/test_logprobs.py -k 'test_logprobs_mode'

Test Result

Unit tests passed

(Optional) Documentation Update

Added detailed sampling flow illustration in v1 Sampler class.
Updated v1 guide.
https://vllm--22387.org.readthedocs.build/en/22387/api/vllm/v1/sample/sampler.html#vllm.v1.sample.sampler.Sampler
https://vllm--22387.org.readthedocs.build/en/22387/usage/v1_guide.html#logprobs-calculation

Signed-off-by: 22quinn <33176974+22quinn@users.noreply.github.com>
@github-actions
Copy link

github-actions bot commented Aug 6, 2025

👋 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 v1 tpu Related to Google TPUs labels Aug 6, 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 PR introduces a new sampled_logprobs mode. I've identified a critical issue in vllm/v1/sample/sampler.py where the sample() method returns inconsistent types, and a high-severity issue in vllm/v1/sample/ops/topk_topp_sampler.py where the CUDA implementation's behavior is inconsistent with the native and TPU implementations. These issues could lead to incorrect log-probability values and subtle bugs.

Signed-off-by: 22quinn <33176974+22quinn@users.noreply.github.com>
@mergify mergify bot removed the tpu Related to Google TPUs label Aug 6, 2025
22quinn added 2 commits August 6, 2025 15:29
Signed-off-by: 22quinn <33176974+22quinn@users.noreply.github.com>
Signed-off-by: 22quinn <33176974+22quinn@users.noreply.github.com>
@22quinn
Copy link
Collaborator Author

22quinn commented Aug 6, 2025

/gemini review

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 introduces support for a new logprobs_mode, final_logprobs, which allows retrieving log probabilities after all sampling processors (including temperature, top-k, and top-p) have been applied. The overall implementation is good, but I've identified a critical issue that could lead to incorrect sampling results due to an in-place modification of the logits tensor. Additionally, there's a minor error in the documentation for the new mode. My review provides specific suggestions to address these points.

Signed-off-by: 22quinn <33176974+22quinn@users.noreply.github.com>
@22quinn 22quinn changed the title [Sampler] Support returning logprobs after sampling [Sampler] Support returning final logprobs Aug 6, 2025
22quinn added 2 commits August 6, 2025 15:59
Signed-off-by: 22quinn <33176974+22quinn@users.noreply.github.com>
Signed-off-by: 22quinn <33176974+22quinn@users.noreply.github.com>
@mergify mergify bot removed the needs-rebase label Aug 20, 2025
Copy link
Member

@njhill njhill left a comment

Choose a reason for hiding this comment

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

Thanks @22quinn!

@njhill njhill merged commit f571ff8 into vllm-project:main Aug 21, 2025
38 of 39 checks passed
djmmoss pushed a commit to djmmoss/vllm that referenced this pull request Aug 21, 2025
Signed-off-by: 22quinn <33176974+22quinn@users.noreply.github.com>
Co-authored-by: Nick Hill <nhill@redhat.com>
Co-authored-by: Woosuk Kwon <woosuk.kwon@berkeley.edu>
Signed-off-by: Duncan Moss <djm.moss@gmail.com>
wangxiyuan pushed a commit to vllm-project/vllm-ascend that referenced this pull request Aug 21, 2025
### What this PR does / why we need it?
1. use action/checkout@v5 instead of v4
2. remove dbo test case because there is issue with it and will be
refactored later
3. make vllm-ascend compatible with vllm v0.10.1.1 and add CI for it
4. fix sampler api changes introduced by
vllm-project/vllm#22387
6. fix qwen3 moe config changes intruoduced by
vllm-project/vllm#20562
7. fix kvcache block changes introduced by
vllm-project/vllm#23262

### Does this PR introduce _any_ user-facing change?
N/A

### How was this patch tested?
CI passed with existing test.


- vLLM version: v0.10.0
- vLLM main:
vllm-project/vllm@0c6e40b

---------

Signed-off-by: MengqingCao <cmq0113@163.com>
epwalsh pushed a commit to epwalsh/vllm that referenced this pull request Aug 28, 2025
Signed-off-by: 22quinn <33176974+22quinn@users.noreply.github.com>
Co-authored-by: Nick Hill <nhill@redhat.com>
Co-authored-by: Woosuk Kwon <woosuk.kwon@berkeley.edu>
xiao-llm pushed a commit to xiao-llm/vllm that referenced this pull request Aug 28, 2025
Signed-off-by: 22quinn <33176974+22quinn@users.noreply.github.com>
Co-authored-by: Nick Hill <nhill@redhat.com>
Co-authored-by: Woosuk Kwon <woosuk.kwon@berkeley.edu>
Signed-off-by: Xiao Yu <xiao.yu@amd.com>
zhewenl pushed a commit to zhewenl/vllm that referenced this pull request Aug 28, 2025
Signed-off-by: 22quinn <33176974+22quinn@users.noreply.github.com>
Co-authored-by: Nick Hill <nhill@redhat.com>
Co-authored-by: Woosuk Kwon <woosuk.kwon@berkeley.edu>
mengxingkongzhouhan pushed a commit to mengxingkongzhouhan/vllm that referenced this pull request Aug 30, 2025
Signed-off-by: 22quinn <33176974+22quinn@users.noreply.github.com>
Co-authored-by: Nick Hill <nhill@redhat.com>
Co-authored-by: Woosuk Kwon <woosuk.kwon@berkeley.edu>
zhewenl pushed a commit to zhewenl/vllm that referenced this pull request Sep 3, 2025
Signed-off-by: 22quinn <33176974+22quinn@users.noreply.github.com>
Co-authored-by: Nick Hill <nhill@redhat.com>
Co-authored-by: Woosuk Kwon <woosuk.kwon@berkeley.edu>
wangxiaoteng888 pushed a commit to LCAIZJ/vllm-ascend that referenced this pull request Sep 25, 2025
### What this PR does / why we need it?
1. use action/checkout@v5 instead of v4
2. remove dbo test case because there is issue with it and will be
refactored later
3. make vllm-ascend compatible with vllm v0.10.1.1 and add CI for it
4. fix sampler api changes introduced by
vllm-project/vllm#22387
6. fix qwen3 moe config changes intruoduced by
vllm-project/vllm#20562
7. fix kvcache block changes introduced by
vllm-project/vllm#23262

### Does this PR introduce _any_ user-facing change?
N/A

### How was this patch tested?
CI passed with existing test.


- vLLM version: v0.10.0
- vLLM main:
vllm-project/vllm@0c6e40b

---------

Signed-off-by: MengqingCao <cmq0113@163.com>
FeiDaLI pushed a commit to FeiDaLI/vllm that referenced this pull request Sep 25, 2025
Signed-off-by: 22quinn <33176974+22quinn@users.noreply.github.com>
Co-authored-by: Nick Hill <nhill@redhat.com>
Co-authored-by: Woosuk Kwon <woosuk.kwon@berkeley.edu>
chopper0126 pushed a commit to chopper0126/vllm-ascend that referenced this pull request Sep 26, 2025
### What this PR does / why we need it?
1. use action/checkout@v5 instead of v4
2. remove dbo test case because there is issue with it and will be
refactored later
3. make vllm-ascend compatible with vllm v0.10.1.1 and add CI for it
4. fix sampler api changes introduced by
vllm-project/vllm#22387
6. fix qwen3 moe config changes intruoduced by
vllm-project/vllm#20562
7. fix kvcache block changes introduced by
vllm-project/vllm#23262

### Does this PR introduce _any_ user-facing change?
N/A

### How was this patch tested?
CI passed with existing test.


- vLLM version: v0.10.0
- vLLM main:
vllm-project/vllm@0c6e40b

---------

Signed-off-by: MengqingCao <cmq0113@163.com>
Angazenn pushed a commit to Angazenn/vllm-ascend that referenced this pull request Oct 21, 2025
### What this PR does / why we need it?
1. use action/checkout@v5 instead of v4
2. remove dbo test case because there is issue with it and will be
refactored later
3. make vllm-ascend compatible with vllm v0.10.1.1 and add CI for it
4. fix sampler api changes introduced by
vllm-project/vllm#22387
6. fix qwen3 moe config changes intruoduced by
vllm-project/vllm#20562
7. fix kvcache block changes introduced by
vllm-project/vllm#23262

### Does this PR introduce _any_ user-facing change?
N/A

### How was this patch tested?
CI passed with existing test.


- vLLM version: v0.10.0
- vLLM main:
vllm-project/vllm@0c6e40b

---------

Signed-off-by: MengqingCao <cmq0113@163.com>
@22quinn 22quinn deleted the topk-topp-logprobs branch November 16, 2025 22:28
Clorist33 pushed a commit to Clorist33/vllm-ascend that referenced this pull request Dec 9, 2025
### What this PR does / why we need it?
1. use action/checkout@v5 instead of v4
2. remove dbo test case because there is issue with it and will be
refactored later
3. make vllm-ascend compatible with vllm v0.10.1.1 and add CI for it
4. fix sampler api changes introduced by
vllm-project/vllm#22387
6. fix qwen3 moe config changes intruoduced by
vllm-project/vllm#20562
7. fix kvcache block changes introduced by
vllm-project/vllm#23262

### Does this PR introduce _any_ user-facing change?
N/A

### How was this patch tested?
CI passed with existing test.


- vLLM version: v0.10.0
- vLLM main:
vllm-project/vllm@0c6e40b

---------

Signed-off-by: MengqingCao <cmq0113@163.com>
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 rl Related to RL workflows tpu Related to Google TPUs v1

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants