-
-
Notifications
You must be signed in to change notification settings - Fork 11.9k
[BugFix] Fix cu_num_generated_tokens slicing logic in LogprobsLists.slice() method #28214
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
e85fa7c to
ca276e5
Compare
There was a problem hiding this 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 bug in the LogprobsLists.slice() method where cu_num_generated_tokens was not being correctly sliced and re-based, potentially leading to indexing errors. The proposed fix correctly recalculates the cumulative token counts for the sliced portion to ensure it starts from zero. The change is accompanied by a comprehensive new test suite in tests/v1/test_outputs.py which thoroughly validates the fix across various scenarios, including slicing from the start, middle, and end, as well as handling single and full slices. The logic of the fix is sound, and the tests are well-written, covering the relevant edge cases. Overall, this is a solid contribution that improves the correctness and robustness of the code.
07c5086 to
94c4919
Compare
…thod Signed-off-by: Bradley <[email protected]>
53dfc41 to
2f78584
Compare
|
Hi @hmellor |
njhill
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @usberkeley!
|
The new test file is not run in CI. @usberkeley please make a follow up PR ensuring that these tests are actually run. |
@hmellor Sorry about that. Sure, I’ll submit a new PR to fix this issue |
|
Don't worry, it's an easy mistake to make with the current CI setup. This should not have to be somthing contributors need to think about. In future we hope to make this a non-issue. |
Thanks for the clarification! Glad to hear it’ll be easier in the future. |
…thod (vllm-project#28214) Signed-off-by: Bradley <[email protected]> Signed-off-by: xuebwang-amd <[email protected]>
…thod (vllm-project#28214) Signed-off-by: Bradley <[email protected]>
Purpose
Problem Description
In
LogprobsLists.slice(), directly slicingcu_num_generated_tokensusingself.cu_num_generated_tokens[start_req_idx:end_req_idx]caused the sliced cumulative array to not start from 0, which could lead to indexing errors in subsequent operations.Solution
Recalculate the sliced
cu_num_generated_tokensto ensure it starts from 0:cu_num_offset = self.cu_num_generated_tokens[start_req_idx]Test Plan
Add
TestLogprobsLists(TestCase)test_slice_without_cu_num_generated_tokens: Test slicing without cu_num_generated_tokenstest_slice_from_start: Test slicing from the start positiontest_slice_from_middle: Test slicing from the middle positiontest_slice_single_request: Test slicing a single requesttest_slice_last_request: Test slicing the last requesttest_slice_all_requests: Test slicing all requests (full slice)Test Result
Pass
Essential Elements of an Effective PR Description Checklist
supported_models.mdandexamplesfor a new model.