Skip to content

Conversation

@zhuohan123
Copy link
Member

@zhuohan123 zhuohan123 commented Nov 8, 2025

Purpose

Fix #28171 (comment)

Test Plan

All existing tests should pass.


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.
  • (Optional) Release notes update. If your change is user facing, please update the release notes draft in the Google Doc.

Signed-off-by: Zhuohan Li <zhuohan123@gmail.com>
@zhuohan123 zhuohan123 requested a review from njhill November 8, 2025 01:16
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 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.

}


def test_flatten_logprobs_append() -> None:
Copy link
Contributor

Choose a reason for hiding this comment

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

high

For consistency with the class rename from FlattenLogprobs to FlatLogprobs, this test function should be renamed to test_flat_logprobs_append.

Suggested change
def test_flatten_logprobs_append() -> None:
def test_flat_logprobs_append() -> None:

assert logprobs.decoded_tokens == ["10", "20", "30", "40", "50", "60"]


def test_flatten_logprobs_extend() -> None:
Copy link
Contributor

Choose a reason for hiding this comment

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

high

To maintain consistency with the refactoring, this test function should be renamed to test_flat_logprobs_extend.

Suggested change
def test_flatten_logprobs_extend() -> None:
def test_flat_logprobs_extend() -> None:

assert logprobs.decoded_tokens == ["40", "50", "60", "10", "20", "30", "10"]


def test_flatten_logprobs_access() -> None:
Copy link
Contributor

Choose a reason for hiding this comment

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

high

Consistent with the rename of FlattenLogprobs, this function should be renamed to test_flat_logprobs_access.

Suggested change
def test_flatten_logprobs_access() -> None:
def test_flat_logprobs_access() -> None:

vllm/envs.py Outdated
Comment on lines 1467 to 1471
# 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"))),
Copy link
Contributor

Choose a reason for hiding this comment

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

high

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>
@zhuohan123
Copy link
Member Author

/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 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.

@zhuohan123 zhuohan123 enabled auto-merge (squash) November 8, 2025 06:59
@github-actions github-actions bot added the ready ONLY add when PR is ready to merge/full CI is needed label Nov 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready ONLY add when PR is ready to merge/full CI is needed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants