-
-
Notifications
You must be signed in to change notification settings - Fork 11.1k
[feature] add log non default args in LLM #21680
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
|
👋 Hi! Thank you for contributing to the vLLM project. 💬 Join our developer Slack at https://slack.vllm.ai to discuss your PR in #pr-reviews, coordinate on features in #feat- channels, or join special interest groups in #sig- channels. Just a reminder: PRs would not trigger full CI run by default. Instead, it would only run Once the PR is approved and ready to go, your PR reviewer(s) can run CI to test the changes comprehensively before merging. To run CI, PR reviewers can either: Add 🚀 |
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 introduces a useful feature to log non-default arguments when initializing an LLM instance. However, the implementation has a critical issue where it unsafely retrieves default values by instantiating EngineArgs, which can cause side effects. Additionally, the new logging function is missing the logger definition, which would lead to a runtime error. I've provided a suggestion to fix the function's logic and pointed out the missing logger definition.
vllm/entrypoints/llm.py
Outdated
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.
This function has two critical issues:
-
NameErrorforlogger: Theloggerobject is used but not defined or imported in this file. This will cause aNameErrorat runtime. You need to importinit_loggerfromvllm.loggerand initialize it at the module level, e.g.,logger = init_logger(__name__). -
Unsafe default value retrieval: Instantiating
EngineArgs()to get default values is problematic as it executesEngineArgs.__post_init__, which has side effects (e.g.,load_general_plugins()). This is inefficient and can lead to subtle bugs. A safer approach is to get default values directly from the dataclass field definitions.
Here is a corrected version of the function. Please also ensure you add the logger import and initialization at the top of the file.
def log_non_default_args(args: EngineArgs):
"""Log non-default arguments from EngineArgs.
This function compares the current EngineArgs instance values with the
default values defined in the dataclass and logs any differences.
Args:
args: The EngineArgs instance to check for non-default values.
"""
non_default_args = {}
for field in dataclasses.fields(EngineArgs):
field_name = field.name
current_value = getattr(args, field_name)
# Get default value from the field definition to avoid
# instantiating EngineArgs and triggering side effects in __post_init__.
if field.default is not dataclasses.MISSING:
default_value = field.default
elif field.default_factory is not dataclasses.MISSING:
default_value = field.default_factory()
else:
# This should not happen for EngineArgs as all fields have defaults.
continue
# Compare current value with default value
if current_value != default_value:
non_default_args[field_name] = current_value
if non_default_args:
logger.info("Using non-default arguments: %s", non_default_args)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.
Can we consolidate this code with that for online inference?
1385265 to
1671314
Compare
Thanks, Merge into the same method. |
Signed-off-by: rongfu.leng <rongfu.leng@daocloud.io>
1671314 to
537d2a7
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.
LGTM, thanks
Signed-off-by: rongfu.leng <rongfu.leng@daocloud.io>
Signed-off-by: rongfu.leng <rongfu.leng@daocloud.io>
Signed-off-by: rongfu.leng <rongfu.leng@daocloud.io> Signed-off-by: x22x22 <wadeking@qq.com>
Signed-off-by: rongfu.leng <rongfu.leng@daocloud.io>
Signed-off-by: rongfu.leng <rongfu.leng@daocloud.io>
Signed-off-by: rongfu.leng <rongfu.leng@daocloud.io> Signed-off-by: Jinzhen Lin <linjinzhen@hotmail.com>
Signed-off-by: rongfu.leng <rongfu.leng@daocloud.io> Signed-off-by: Paul Pak <paulpak58@gmail.com>
Signed-off-by: rongfu.leng <rongfu.leng@daocloud.io> Signed-off-by: Diego-Castan <diego.castan@ibm.com>
Signed-off-by: rongfu.leng <rongfu.leng@daocloud.io>
Signed-off-by: rongfu.leng <rongfu.leng@daocloud.io>
Essential Elements of an Effective PR Description Checklist
supported_models.mdandexamplesfor a new model.Purpose
When use
LLMclass to running mode, log non default args, like cli args.Test Plan
Test Result
(Optional) Documentation Update