-
-
Notifications
You must be signed in to change notification settings - Fork 11.1k
[Misc] FlattenLogprobs -> FlatLogprobs #28335
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
base: main
Are you sure you want to change the base?
Conversation
Signed-off-by: Zhuohan Li <zhuohan123@gmail.com>
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 refactors the codebase by renaming FlattenLogprobs to FlatLogprobs for better clarity. The changes are mostly correct and applied across the necessary files. However, to make this refactoring more complete and consistent, I've identified a few areas for improvement. Specifically, some test function names in tests/test_logprobs.py still use the old flatten_logprobs naming. Additionally, the environment variable VLLM_FLATTEN_LOGPROBS in vllm/envs.py has not been renamed, creating an inconsistency with the new class name. My review includes suggestions to address these points for better code maintainability.
tests/test_logprobs.py
Outdated
| } | ||
|
|
||
|
|
||
| def test_flatten_logprobs_append() -> None: |
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.
tests/test_logprobs.py
Outdated
| assert logprobs.decoded_tokens == ["10", "20", "30", "40", "50", "60"] | ||
|
|
||
|
|
||
| def test_flatten_logprobs_extend() -> None: |
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.
tests/test_logprobs.py
Outdated
| assert logprobs.decoded_tokens == ["40", "50", "60", "10", "20", "30", "10"] | ||
|
|
||
|
|
||
| def test_flatten_logprobs_access() -> None: |
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.
vllm/envs.py
Outdated
| # Flag to enable FlatLogprobs whose GC overhead is significantly smaller than | ||
| # the original list[dict[int, Logprob]] approach. | ||
| # After enabled, PromptLogprobs and SampleLogprobs would populated as | ||
| # FlattenLogprobs. | ||
| # FlatLogprobs. | ||
| "VLLM_FLATTEN_LOGPROBS": lambda: bool(int(os.getenv("VLLM_FLATTEN_LOGPROBS", "0"))), |
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.
While the comment and class name are updated to FlatLogprobs, the environment variable is still named VLLM_FLATTEN_LOGPROBS. This creates an inconsistency. To complete the refactoring, consider renaming the environment variable to VLLM_FLAT_LOGPROBS. This would be a breaking change for users who set this variable. If backward compatibility is a concern, you could support both variables for a transition period or add a note to the comment explaining why the old name is kept.
Signed-off-by: Zhuohan Li <zhuohan123@gmail.com>
|
/gemini review |
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 refactors the codebase by renaming FlattenLogprobs to the more succinct FlatLogprobs. The change has been applied consistently across all relevant files, including class definitions, variable names, function names, environment variables, and associated comments and documentation. The refactoring is clean and achieves its goal of improving naming consistency. I have no further comments.
Purpose
Fix #28171 (comment)
Test Plan
All existing tests should pass.
Essential Elements of an Effective PR Description Checklist
supported_models.mdandexamplesfor a new model.