Skip to content

Conversation

zhuohan123
Copy link
Member

Summary: Enable command line logging for LLMEngine

Test Plan: All existing tests should pass

Differential Revision: D83118697

@facebook-github-bot
Copy link

@zhuohan123 has exported this pull request. If you are a Meta employee, you can view the originating diff in D83118697.

@mergify mergify bot added the v1 label Sep 24, 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 pull request enables command-line logging for the LLMEngine by introducing a StatLoggerManager and periodic logging logic. The changes are a good step towards better observability. My review focuses on improving the initialization of state related to logging to enhance code clarity and maintainability. Specifically, I've suggested moving the initialization of _last_log_time to the __init__ method to centralize attribute setup and make the code easier to reason about.

Comment on lines +122 to +129
self.logger_manager: Optional[StatLoggerManager] = None
if self.log_stats:
self.logger_manager = StatLoggerManager(
vllm_config=vllm_config,
custom_stat_loggers=stat_loggers,
enable_default_loggers=log_stats,
)
self.logger_manager.log_engine_initialized()
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 better code clarity and to ensure all instance attributes are initialized in one place, it's recommended to initialize _last_log_time here within the if self.log_stats: block. This avoids lazy initialization in the do_log_stats_with_interval method, makes the class's attributes more explicit, and improves overall maintainability.

Suggested change
self.logger_manager: Optional[StatLoggerManager] = None
if self.log_stats:
self.logger_manager = StatLoggerManager(
vllm_config=vllm_config,
custom_stat_loggers=stat_loggers,
enable_default_loggers=log_stats,
)
self.logger_manager.log_engine_initialized()
self.logger_manager: Optional[StatLoggerManager] = None
if self.log_stats:
self.logger_manager = StatLoggerManager(
vllm_config=vllm_config,
custom_stat_loggers=stat_loggers,
enable_default_loggers=log_stats,
)
self.logger_manager.log_engine_initialized()
self._last_log_time = time.time()

Comment on lines +332 to +339
def do_log_stats_with_interval(self) -> None:
"""Log stats when the time interval has passed."""
now = time.time()
if not hasattr(self, "_last_log_time"):
self._last_log_time = now
if now - self._last_log_time >= envs.VLLM_LOG_STATS_INTERVAL:
self.do_log_stats()
self._last_log_time = now
Copy link
Contributor

Choose a reason for hiding this comment

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

high

With _last_log_time being initialized in __init__, this lazy initialization check becomes redundant. Removing it simplifies the do_log_stats_with_interval method, making it cleaner and more straightforward.

Suggested change
def do_log_stats_with_interval(self) -> None:
"""Log stats when the time interval has passed."""
now = time.time()
if not hasattr(self, "_last_log_time"):
self._last_log_time = now
if now - self._last_log_time >= envs.VLLM_LOG_STATS_INTERVAL:
self.do_log_stats()
self._last_log_time = now
def do_log_stats_with_interval(self) -> None:
"""Log stats when the time interval has passed."""
now = time.time()
if now - self._last_log_time >= envs.VLLM_LOG_STATS_INTERVAL:
self.do_log_stats()
self._last_log_time = now

@zhuohan123 zhuohan123 added the ready ONLY add when PR is ready to merge/full CI is needed label Sep 24, 2025
@zhuohan123 zhuohan123 changed the title Enable command line logging for LLMEngine [Core] Enable command line logging for LLMEngine Sep 24, 2025
@facebook-github-bot
Copy link

@zhuohan123 has exported this pull request. If you are a Meta employee, you can view the originating diff in D83118697.

@facebook-github-bot
Copy link

@zhuohan123 has exported this pull request. If you are a Meta employee, you can view the originating diff in D83118697.

@facebook-github-bot
Copy link

@zhuohan123 has exported this pull request. If you are a Meta employee, you can view the originating diff in D83118697.

Summary:
Pull Request resolved: vllm-project#25610

Enable command line logging for LLMEngine

Signed-off-by: Zhuohan Li <zhuohan123@gmail.com>

Test Plan: All existing tests should pass

Differential Revision: D83118697
@facebook-github-bot
Copy link

@zhuohan123 has exported this pull request. If you are a Meta employee, you can view the originating diff in D83118697.

Copy link
Collaborator

@aarnphm aarnphm left a comment

Choose a reason for hiding this comment

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

LGTM

@yeqcharlotte yeqcharlotte enabled auto-merge (squash) September 25, 2025 06:58
@zhuohan123 zhuohan123 disabled auto-merge September 25, 2025 20:15
@zhuohan123 zhuohan123 merged commit 8c435c9 into vllm-project:main Sep 25, 2025
39 of 42 checks passed
yewentao256 pushed a commit that referenced this pull request Oct 3, 2025
Co-authored-by: Ye (Charlotte) Qi <yeq@meta.com>
Signed-off-by: Zhuohan Li <zhuohan123@gmail.com>
Signed-off-by: yewentao256 <zhyanwentao@126.com>
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 v1
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants