[Bugfix] Update target probs to target logits in rejection sample#6685
[Bugfix] Update target probs to target logits in rejection sample#6685whx-sjtu merged 1 commit intovllm-project:mainfrom
Conversation
Signed-off-by: Zetong Li <slippersss@126.com>
Summary of ChangesHello @slippersss, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request refactors the Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
|
👋 Hi! Thank you for contributing to the vLLM Ascend project. The following points will speed up your PR merge:
If CI fails, you can run linting and testing checks locally according Contributing and Testing. |
There was a problem hiding this comment.
Code Review
This pull request refactors the rejection_sample function to accept target_logits instead of target_probs. This is a crucial bugfix that allows for the correct application of temperature scaling on logits, addressing a potential accuracy issue in sampling. The implementation is sound: it correctly uses argmax on logits for the greedy path and applies softmax to derive probabilities for the random sampling path. The changes are consistent and well-contained. I have added one comment to suggest an improvement for robustness by checking for NaN values in the input logits.
| assert draft_probs is None or draft_probs.ndim == 2 | ||
| assert cu_num_draft_tokens.ndim == 1 | ||
| assert target_probs.ndim == 2 | ||
| assert target_logits.ndim == 2 |
There was a problem hiding this comment.
To improve robustness, it's good practice to check for NaN values in input tensors. Logits can sometimes become NaN due to numerical instability in upstream computations. If target_logits contains NaNs, they will propagate through the softmax operation and subsequent calculations, leading to incorrect sampling results (e.g., argmax on a NaN tensor often returns 0, a silent failure). Adding an assertion here would help catch such issues early.
| assert target_logits.ndim == 2 | |
| assert target_logits.ndim == 2 | |
| assert not torch.isnan(target_logits).any(), "target_logits should not contain NaNs" |
…to qwen3next_rebase * 'main' of https://github.com/vllm-project/vllm-ascend: [Docs] Fix GLM-5 deploy command (vllm-project#6711) [npugraph_ex]enable npugraph_ex by default (vllm-project#6664) [doc]add GLM5.md (vllm-project#6709) [Model] GLM5 adaptation (vllm-project#6642) [Bugfix] Update target probs to target logits in rejection sample (vllm-project#6685) [Main][Ops] Make triton rope support index_selecting from cos_sin_cache (vllm-project#5450) [CI]fix nightly multi node test error for wait for pod ready (vllm-project#6675) [main to main] upgrade main 0210 (vllm-project#6673) [main][Quant] Remove unused rotation functions and parameters from W4A4 LAOS quantization (vllm-project#6648) [Test][BugFix] Fix torch.rand usage in triton penalty test (vllm-project#6680) Add Worker Interface:check_health (vllm-project#6681)
…lm-project#6685) ### What this PR does / why we need it? This PR aims to update `target_probs` to `target_logits` in `rejection_sample`, for catching up with vllm-project/vllm#32852. Otherwise, sampling with temperature will incur accuracy problem where tokens can be accepted or rejected unreasonably. ### Does this PR introduce _any_ user-facing change? N/A ### How was this patch tested? by ci - vLLM version: v0.15.0 - vLLM main: vllm-project/vllm@1339784 Signed-off-by: Zetong Li <slippersss@126.com> Signed-off-by: momochenchuw <chenchuw@huawei.com>
…lm-project#6685) ### What this PR does / why we need it? This PR aims to update `target_probs` to `target_logits` in `rejection_sample`, for catching up with vllm-project/vllm#32852. Otherwise, sampling with temperature will incur accuracy problem where tokens can be accepted or rejected unreasonably. ### Does this PR introduce _any_ user-facing change? N/A ### How was this patch tested? by ci - vLLM version: v0.15.0 - vLLM main: vllm-project/vllm@1339784 Signed-off-by: Zetong Li <slippersss@126.com>
…lm-project#6685) ### What this PR does / why we need it? This PR aims to update `target_probs` to `target_logits` in `rejection_sample`, for catching up with vllm-project/vllm#32852. Otherwise, sampling with temperature will incur accuracy problem where tokens can be accepted or rejected unreasonably. ### Does this PR introduce _any_ user-facing change? N/A ### How was this patch tested? by ci - vLLM version: v0.15.0 - vLLM main: vllm-project/vllm@1339784 Signed-off-by: Zetong Li <slippersss@126.com> Signed-off-by: zrj026 <zhangrunjiang026@gmail.com>
…lm-project#6685) ### What this PR does / why we need it? This PR aims to update `target_probs` to `target_logits` in `rejection_sample`, for catching up with vllm-project/vllm#32852. Otherwise, sampling with temperature will incur accuracy problem where tokens can be accepted or rejected unreasonably. ### Does this PR introduce _any_ user-facing change? N/A ### How was this patch tested? by ci - vLLM version: v0.15.0 - vLLM main: vllm-project/vllm@1339784 Signed-off-by: Zetong Li <slippersss@126.com>
…lm-project#6685) ### What this PR does / why we need it? This PR aims to update `target_probs` to `target_logits` in `rejection_sample`, for catching up with vllm-project/vllm#32852. Otherwise, sampling with temperature will incur accuracy problem where tokens can be accepted or rejected unreasonably. ### Does this PR introduce _any_ user-facing change? N/A ### How was this patch tested? by ci - vLLM version: v0.15.0 - vLLM main: vllm-project/vllm@1339784 Signed-off-by: Zetong Li <slippersss@126.com> Signed-off-by: zrj026 <zhangrunjiang026@gmail.com>
…lm-project#6685) ### What this PR does / why we need it? This PR aims to update `target_probs` to `target_logits` in `rejection_sample`, for catching up with vllm-project/vllm#32852. Otherwise, sampling with temperature will incur accuracy problem where tokens can be accepted or rejected unreasonably. ### Does this PR introduce _any_ user-facing change? N/A ### How was this patch tested? by ci - vLLM version: v0.15.0 - vLLM main: vllm-project/vllm@1339784 Signed-off-by: Zetong Li <slippersss@126.com>
…lm-project#6685) ### What this PR does / why we need it? This PR aims to update `target_probs` to `target_logits` in `rejection_sample`, for catching up with vllm-project/vllm#32852. Otherwise, sampling with temperature will incur accuracy problem where tokens can be accepted or rejected unreasonably. ### Does this PR introduce _any_ user-facing change? N/A ### How was this patch tested? by ci - vLLM version: v0.15.0 - vLLM main: vllm-project/vllm@1339784 Signed-off-by: Zetong Li <slippersss@126.com>
What this PR does / why we need it?
This PR aims to update
target_probstotarget_logitsinrejection_sample, for catching up with vllm-project/vllm#32852. Otherwise, sampling with temperature will incur accuracy problem where tokens can be accepted or rejected unreasonably.Does this PR introduce any user-facing change?
N/A
How was this patch tested?
by ci