Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions vllm/renderers/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,8 @@ def warmup(self, chat_params: ChatParams) -> None:
For multi-modal requests:
- Importing libraries such as librosa triggers JIT compilation.
"""
from vllm.entrypoints.chat_utils import ChatTemplateResolutionError

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

high

This local import suggests a potential circular dependency between vllm.renderers and vllm.entrypoints. While this works, circular dependencies can make the code harder to maintain and refactor. A better long-term solution is to break the cycle, for example, by moving ChatTemplateResolutionError to a common exceptions file. If refactoring is out of scope for this PR, adding a comment to explain the necessity of this local import would be helpful for future maintainability.

Suggested change
from vllm.entrypoints.chat_utils import ChatTemplateResolutionError
# Local import to avoid a circular dependency.
from vllm.entrypoints.chat_utils import ChatTemplateResolutionError
References
  1. According to PEP 8, imports should usually be at the top of the file. Local imports are acceptable to resolve circular dependencies, but this often points to a need for refactoring. Adding a comment clarifies the reason for deviating from the standard. (link)


try:
logger.info("Warming up chat template processing...")

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think we should also change this one to debug.

start_time = time.perf_counter()
Expand All @@ -184,6 +186,8 @@ def warmup(self, chat_params: ChatParams) -> None:

elapsed = time.perf_counter() - start_time
logger.info("Chat template warmup completed in %.3fs", elapsed)
except ChatTemplateResolutionError:
logger.info("This model does not support chat template.")
except Exception:
logger.exception("Chat template warmup failed")

Expand Down
Loading