Skip to content

Conversation

@lengrongfu
Copy link
Contributor

@lengrongfu lengrongfu commented Jul 27, 2025

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.

Purpose

When use LLM class to running mode, log non default args, like cli args.

Test Plan

Test Result

(Optional) Documentation Update

@lengrongfu lengrongfu requested a review from aarnphm as a code owner July 27, 2025 16:35
@github-actions
Copy link

👋 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 fastcheck CI which starts running only a small and essential subset of CI tests to quickly catch errors. You can run other CI tests on top of those by going to your fastcheck build on Buildkite UI (linked in the PR checks section) and unblock them. If you do not have permission to unblock, ping simon-mo or khluu to add you in our Buildkite org.

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 ready label to the PR or enable auto-merge.

🚀

@mergify mergify bot added the frontend label Jul 27, 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 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.

Comment on lines 1746 to 1771
Copy link
Contributor

Choose a reason for hiding this comment

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

critical

This function has two critical issues:

  1. NameError for logger: The logger object is used but not defined or imported in this file. This will cause a NameError at runtime. You need to import init_logger from vllm.logger and initialize it at the module level, e.g., logger = init_logger(__name__).

  2. Unsafe default value retrieval: Instantiating EngineArgs() to get default values is problematic as it executes EngineArgs.__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)

@lengrongfu lengrongfu changed the title [feature] add log non default args [feature] add log non default args in LLM Jul 27, 2025
Copy link
Member

@DarkLight1337 DarkLight1337 left a 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?

@lengrongfu lengrongfu force-pushed the feat/add-llm-printlog branch from 1385265 to 1671314 Compare July 28, 2025 04:31
@lengrongfu
Copy link
Contributor Author

Can we consolidate this code with that for online inference?

Thanks, Merge into the same method.

Signed-off-by: rongfu.leng <rongfu.leng@daocloud.io>
@lengrongfu lengrongfu force-pushed the feat/add-llm-printlog branch from 1671314 to 537d2a7 Compare July 28, 2025 04:34
Copy link
Member

@DarkLight1337 DarkLight1337 left a comment

Choose a reason for hiding this comment

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

LGTM, thanks

@vllm-bot vllm-bot merged commit 2cc5711 into vllm-project:main Jul 28, 2025
14 checks passed
liuyumoye pushed a commit to liuyumoye/vllm that referenced this pull request Jul 31, 2025
Signed-off-by: rongfu.leng <rongfu.leng@daocloud.io>
HsChen-sys pushed a commit to HsChen-sys/vllm that referenced this pull request Aug 1, 2025
Signed-off-by: rongfu.leng <rongfu.leng@daocloud.io>
x22x22 pushed a commit to x22x22/vllm that referenced this pull request Aug 5, 2025
Signed-off-by: rongfu.leng <rongfu.leng@daocloud.io>
Signed-off-by: x22x22 <wadeking@qq.com>
Pradyun92 pushed a commit to Pradyun92/vllm that referenced this pull request Aug 6, 2025
Signed-off-by: rongfu.leng <rongfu.leng@daocloud.io>
npanpaliya pushed a commit to odh-on-pz/vllm-upstream that referenced this pull request Aug 6, 2025
Signed-off-by: rongfu.leng <rongfu.leng@daocloud.io>
jinzhen-lin pushed a commit to jinzhen-lin/vllm that referenced this pull request Aug 9, 2025
Signed-off-by: rongfu.leng <rongfu.leng@daocloud.io>
Signed-off-by: Jinzhen Lin <linjinzhen@hotmail.com>
paulpak58 pushed a commit to paulpak58/vllm that referenced this pull request Aug 13, 2025
Signed-off-by: rongfu.leng <rongfu.leng@daocloud.io>
Signed-off-by: Paul Pak <paulpak58@gmail.com>
diegocastanibm pushed a commit to diegocastanibm/vllm that referenced this pull request Aug 15, 2025
Signed-off-by: rongfu.leng <rongfu.leng@daocloud.io>
Signed-off-by: Diego-Castan <diego.castan@ibm.com>
epwalsh pushed a commit to epwalsh/vllm that referenced this pull request Aug 28, 2025
Signed-off-by: rongfu.leng <rongfu.leng@daocloud.io>
zhewenl pushed a commit to zhewenl/vllm that referenced this pull request Aug 28, 2025
Signed-off-by: rongfu.leng <rongfu.leng@daocloud.io>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants