Skip to content

fix(vllm): preserve user-specified --runner flag in update_engine_config_with_dynamo - #7918

Closed
MatejKosec wants to merge 1 commit into
mainfrom
user/mkosec/agent-fix-7670
Closed

fix(vllm): preserve user-specified --runner flag in update_engine_config_with_dynamo#7918
MatejKosec wants to merge 1 commit into
mainfrom
user/mkosec/agent-fix-7670

Conversation

@MatejKosec

@MatejKosec MatejKosec commented Apr 6, 2026

Copy link
Copy Markdown
Contributor

Fixes #7670

Problem

update_engine_config_with_dynamo() unconditionally sets runner: "generate" in the defaults dict, overriding any user-specified --runner flag. This breaks embedding models which require --runner embed.

Fix

Removed runner from the unconditional defaults. Only sets runner = "generate" when engine_config.runner is None (user did not specify).

Tests

3 new unit tests in test_vllm_unit.py (TestRunnerDefaultNotOverridden) — all pass.

Fixes #7670

Summary by CodeRabbit

  • Bug Fixes
    • Fixed an issue where explicitly configured vLLM runner values (such as "embed" and "pooling") were being incorrectly overridden by default engine configuration settings. User-specified runner configurations are now properly preserved. The system applies default values only when the user has not explicitly set a runner configuration, preventing accidental configuration overrides.

Open with Devin

@MatejKosec
MatejKosec requested a review from ishandhanani April 6, 2026 21:04
@MatejKosec
MatejKosec requested a review from a team as a code owner April 6, 2026 21:04
@MatejKosec
MatejKosec requested a review from a team April 6, 2026 21:04
@copy-pr-bot

copy-pr-bot Bot commented Apr 6, 2026

Copy link
Copy Markdown

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@github-actions github-actions Bot added fix backend::vllm Relates to the vllm backend labels Apr 6, 2026
@coderabbitai

coderabbitai Bot commented Apr 6, 2026

Copy link
Copy Markdown
Contributor

Walkthrough

The update_engine_config_with_dynamo function now conditionally applies the default runner="generate" only when the runner attribute is explicitly None, preventing it from overriding user-provided runner values. Tests verify that explicit runner values such as "pooling" and "embed" are preserved.

Changes

Cohort / File(s) Summary
Runner Default Conditional Logic
components/src/dynamo/vllm/args.py
Modified update_engine_config_with_dynamo to apply runner="generate" default only when engine_config.runner is None, rather than unconditionally via a defaults dict. Prevents override of explicitly set runner values like "pooling" for embedding models.
Unit Tests for Runner Preservation
components/src/dynamo/vllm/tests/test_vllm_unit.py
Added test helpers and TestRunnerDefaultNotOverridden class with three new test cases verifying that runner="generate" is applied when None, while "embed" and "pooling" values are preserved when explicitly set.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and specifically describes the main change: preserving user-specified --runner flags in update_engine_config_with_dynamo.
Description check ✅ Passed The description covers the problem, fix, and tests. It follows the template structure with Overview, Problem, Fix, and Tests sections, and links to issue #7670.
Linked Issues check ✅ Passed The code changes directly address issue #7670 by removing unconditional runner override and only setting runner="generate" when None, plus adding verification tests.
Out of Scope Changes check ✅ Passed All changes are within scope: the fix targets the specific bug in update_engine_config_with_dynamo, and tests are limited to verifying the runner defaulting behavior.
Docstring Coverage ✅ Passed Docstring coverage is 85.71% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

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.

Actionable comments posted: 1

🧹 Nitpick comments (2)
components/src/dynamo/vllm/args.py (1)

237-244: Simplify the hasattr/getattr combination to direct attribute access.

After hasattr(engine_config, "runner") confirms the attribute exists, using getattr(engine_config, "runner") is redundant. Per coding guidelines, prefer direct attribute access on known fields. This also addresses the Ruff B009 warning.

✨ Suggested simplification
     # Set runner default only when the user did not explicitly pass --runner.
     # vLLM 0.13+ renamed 'task' to 'runner'; None means the user did not
     # specify a value, so we can safely apply the 'generate' default.
     # Embedding models require --runner embed, which must not be overridden.
-    if hasattr(engine_config, "runner") and getattr(engine_config, "runner") is None:
+    if hasattr(engine_config, "runner") and engine_config.runner is None:
         engine_config.runner = "generate"
         logger.debug(" engine_args.runner = generate (default)")

As per coding guidelines: "prefer direct attribute access over defensive getattr on known fields".

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@components/src/dynamo/vllm/args.py` around lines 237 - 244, The code uses
hasattr(engine_config, "runner") followed by getattr(engine_config, "runner")
which is redundant and triggers Ruff B009; change the conditional to check the
attribute and access it directly (e.g., if hasattr(engine_config, "runner") and
engine_config.runner is None:) and then set engine_config.runner = "generate"
and call logger.debug(" engine_args.runner = generate (default)"); update the
block around engine_config.runner and logger.debug accordingly.
components/src/dynamo/vllm/tests/test_vllm_unit.py (1)

732-744: Remove redundant in-function import.

DisaggregationMode is already imported at module level (line 27). The in-function import on line 734 is unnecessary and violates the coding guideline to keep imports at the top of the file.

✨ Suggested fix
 def _make_dynamo_config_stub():
     """Minimal dynamo config stub for update_engine_config_with_dynamo tests."""
-    from dynamo.vllm.constants import DisaggregationMode
-
     stub = SimpleNamespace(
         disaggregation_mode=DisaggregationMode.AGGREGATED,
         multimodal_worker=False,

As per coding guidelines: "keep imports at the top of the file (no in-function/class imports)".

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@components/src/dynamo/vllm/tests/test_vllm_unit.py` around lines 732 - 744,
The _make_dynamo_config_stub function contains an unnecessary in-function import
of DisaggregationMode; remove the line "from dynamo.vllm.constants import
DisaggregationMode" and use the module-level DisaggregationMode import (already
present at top of the file) inside _make_dynamo_config_stub so imports are kept
at the top and the function simply references DisaggregationMode when
constructing the SimpleNamespace.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@components/src/dynamo/vllm/tests/test_vllm_unit.py`:
- Around line 812-815: The multi-line assertion for engine_cfg.runner is failing
formatting; collapse the assertion message into a single-line expression or
assign the f-string to a temporary variable and use that in the assert so
Black/ruff will accept it (e.g., assert engine_cfg.runner == "pooling",
f"Expected runner='pooling' to be preserved, but got
runner='{engine_cfg.runner}'."), then run pre-commit hooks (pre-commit run
--all-files or ruff format) to auto-apply formatting fixes.

---

Nitpick comments:
In `@components/src/dynamo/vllm/args.py`:
- Around line 237-244: The code uses hasattr(engine_config, "runner") followed
by getattr(engine_config, "runner") which is redundant and triggers Ruff B009;
change the conditional to check the attribute and access it directly (e.g., if
hasattr(engine_config, "runner") and engine_config.runner is None:) and then set
engine_config.runner = "generate" and call logger.debug(" engine_args.runner =
generate (default)"); update the block around engine_config.runner and
logger.debug accordingly.

In `@components/src/dynamo/vllm/tests/test_vllm_unit.py`:
- Around line 732-744: The _make_dynamo_config_stub function contains an
unnecessary in-function import of DisaggregationMode; remove the line "from
dynamo.vllm.constants import DisaggregationMode" and use the module-level
DisaggregationMode import (already present at top of the file) inside
_make_dynamo_config_stub so imports are kept at the top and the function simply
references DisaggregationMode when constructing the SimpleNamespace.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: f24a1c05-18d7-42d2-a204-5ff12e9151db

📥 Commits

Reviewing files that changed from the base of the PR and between ffe2062 and 88e95f9.

📒 Files selected for processing (2)
  • components/src/dynamo/vllm/args.py
  • components/src/dynamo/vllm/tests/test_vllm_unit.py

Comment on lines +812 to +815

assert engine_cfg.runner == "pooling", (
f"Expected runner='pooling' to be preserved, but got runner='{engine_cfg.runner}'."
)

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.

⚠️ Potential issue | 🟡 Minor

Fix formatting to pass pre-commit hooks.

The pipeline failure indicates that black reformatted this file. The multi-line assertion message likely needs adjustment to satisfy the formatter.

Run pre-commit run --all-files or ruff format locally to auto-fix the formatting before merging.

🧰 Tools
🪛 GitHub Actions: Pre Merge

[error] 812-814: pre-commit failed: black hook re-formatted files (1 file modified). Reproduce with pre-commit run --all-files.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@components/src/dynamo/vllm/tests/test_vllm_unit.py` around lines 812 - 815,
The multi-line assertion for engine_cfg.runner is failing formatting; collapse
the assertion message into a single-line expression or assign the f-string to a
temporary variable and use that in the assert so Black/ruff will accept it
(e.g., assert engine_cfg.runner == "pooling", f"Expected runner='pooling' to be
preserved, but got runner='{engine_cfg.runner}'."), then run pre-commit hooks
(pre-commit run --all-files or ruff format) to auto-apply formatting fixes.

@MatejKosec
MatejKosec requested a review from a team as a code owner April 6, 2026 21:11
@MatejKosec
MatejKosec requested a review from a team April 6, 2026 21:11
@github-actions github-actions Bot added deployment::k8s Relates to dynamo deployment in kubernetes backend::sglang Relates to the sglang backend backend::trtllm Relates to the trtllm backend planner frontend `python -m dynamo.frontend` and `dynamo-run in=http|text|grpc` multimodal actions labels Apr 6, 2026
@MatejKosec
MatejKosec force-pushed the user/mkosec/agent-fix-7670 branch from 6dfe973 to 88e95f9 Compare April 6, 2026 21:12
…rate' default

update_engine_config_with_dynamo placed "runner": "generate" in the
`defaults` dict and then unconditionally applied every entry via setattr,
silently overriding any value the user passed on the CLI (e.g. --runner embed
required for embedding models).

Move the runner default out of the blanket loop and guard it with an explicit
None check: only set runner="generate" when the field is None, meaning the
user did not specify --runner at all.

Also adds TestRunnerDefaultNotOverridden unit tests that verify:
- runner defaults to "generate" when unset
- runner="embed" is preserved (embedding model use case)
- runner="pooling" is preserved

Fixes #7670

Signed-off-by: Matej Kosec <mkosec@4u2g-0421.ipp3a2.colossus.nvidia.com>
Signed-off-by: Matej Kosec <mkosec@nvidia.com>
@MatejKosec
MatejKosec force-pushed the user/mkosec/agent-fix-7670 branch from 88e95f9 to 7856cb2 Compare April 6, 2026 21:17
@MatejKosec

Copy link
Copy Markdown
Contributor Author

Closing — #7680 addresses the same issue.

@MatejKosec MatejKosec closed this Apr 6, 2026

@devin-ai-integration devin-ai-integration Bot left a comment

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.

Devin Review found 1 new potential issue.

View 4 additional findings in Devin Review.

Open in Devin Review


def _make_dynamo_config_stub():
"""Minimal dynamo config stub for update_engine_config_with_dynamo tests."""
from dynamo.vllm.constants import DisaggregationMode

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.

🟡 Redundant import inside function body violates "Keep imports at the top of the file" critical rule

_make_dynamo_config_stub() at line 734 imports from dynamo.vllm.constants import DisaggregationMode inside the function body, but this exact import already exists at module level on components/src/dynamo/vllm/tests/test_vllm_unit.py:27. Per .ai/python-guidelines.md critical rule "Keep imports at the top of the file": "Always flag any import statement that appears inside a function body." The module-level import is sufficient; the in-function import is redundant and hides the dependency.

Suggested change
from dynamo.vllm.constants import DisaggregationMode
Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

actions backend::sglang Relates to the sglang backend backend::trtllm Relates to the trtllm backend backend::vllm Relates to the vllm backend deployment::k8s Relates to dynamo deployment in kubernetes fix frontend `python -m dynamo.frontend` and `dynamo-run in=http|text|grpc` multimodal planner size/XXL

Projects

None yet

Development

Successfully merging this pull request may close these issues.

update_engine_config_with_dynamo unconditionally overrides --runner, breaking embedding models

1 participant