fix: preserve user-provided --runner flag in update_engine_config_with_dynamo - #7680
fix: preserve user-provided --runner flag in update_engine_config_with_dynamo#7680pecord-ent wants to merge 3 commits into
Conversation
|
👋 Hi pecord-ent! Thank you for contributing to ai-dynamo/dynamo. Just a reminder: The 🚀 |
WalkthroughFixes a bug where Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ 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. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
components/src/dynamo/vllm/args.py (1)
262-268: Consider simplifying redundantgetattrafterhasattrcheck.Since line 262 already confirms
runnerexists viahasattr(), thegetattr(engine_config, "runner", "auto")on line 263 is unnecessarily defensive. Direct attribute access is preferred per coding guidelines.Suggested simplification
if hasattr(engine_config, "runner"): - if getattr(engine_config, "runner", "auto") == "auto": + if engine_config.runner == "auto": defaults["runner"] = "generate" else: logger.debug( f"Preserving user-provided runner: {engine_config.runner}" )As per coding guidelines: "Avoid 'defensive'
getattr(obj, 'attr', default)on known types/fields—prefer direct attribute access so contract changes fail loudly."🤖 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 262 - 268, The code redundantly uses getattr(engine_config, "runner", "auto") after confirming the attribute exists with hasattr(engine_config, "runner"); replace the defensive getattr with direct attribute access (use engine_config.runner) in the conditional so it becomes if engine_config.runner == "auto": defaults["runner"]="generate" else logger.debug(f"Preserving user-provided runner: {engine_config.runner}"), keeping the same behavior and touching the symbols engine_config, defaults, and logger.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@components/src/dynamo/vllm/args.py`:
- Around line 262-268: The code redundantly uses getattr(engine_config,
"runner", "auto") after confirming the attribute exists with
hasattr(engine_config, "runner"); replace the defensive getattr with direct
attribute access (use engine_config.runner) in the conditional so it becomes if
engine_config.runner == "auto": defaults["runner"]="generate" else
logger.debug(f"Preserving user-provided runner: {engine_config.runner}"),
keeping the same behavior and touching the symbols engine_config, defaults, and
logger.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 12c6450a-8e72-4674-b48a-2589a0896c42
📒 Files selected for processing (2)
components/src/dynamo/vllm/args.pycomponents/src/dynamo/vllm/tests/test_vllm_unit.py
33455f6 to
05e1e83
Compare
|
/ok to test 0088066 |
|
Hi @pecord-ent, thanks for the contribution! Seems like some of the new tests fail with same issue along these lines: Can you take a look? |
|
Good catch @rmccorm4, thanks! The Fixed in 5b38db7 — added |
|
To clarify — the fix doesn't skip any test or code path. The test helper was simply an incomplete mock of DynamoConfig. |
5b38db7 to
1caa5b0
Compare
…overriding Fixes ai-dynamo#7670. `update_engine_config_with_dynamo()` unconditionally set `engine_args.runner = "generate"`, overwriting any user-provided --runner value. This broke embedding models that require `--runner pooling`. Now only defaults to "generate" when the user didn't explicitly set --runner (i.e. vLLM's default "auto" is still in place). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Signed-off-by: pecord-ent <patrick.ecord@ent.ai>
Address review nitpick: getattr with default is redundant inside the hasattr check. Direct access is clearer and fails loudly if the contract changes. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Signed-off-by: pecord-ent <patrick.ecord@ent.ai>
The _make_dynamo_config() helper was missing benchmark_mode, causing all TestRunnerPreservation tests to fail with AttributeError when update_engine_config_with_dynamo() accessed dynamo_config.benchmark_mode. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Signed-off-by: pecord-ent <patrick.ecord@ent.ai>
8e464b2 to
89e4d40
Compare
…ig_with_dynamo
`update_engine_config_with_dynamo()` placed `"runner": "generate"` in the
unconditional `defaults` dict, which the subsequent setattr loop applied
without checking whether the user had set the value. Any `--runner pooling`
(required for embedding models like Qwen3-Embedding-0.6B / google/embeddinggemma-300m)
was silently overwritten and the engine crashed with:
pydantic_core._pydantic_core.ValidationError: 1 validation error for ModelConfig
Value error, This model does not support `--runner generate`.
Move the `runner` default out of the unconditional dict and guard it: only set
it to `"generate"` when `engine_config.runner == "auto"` (vLLM's default when
the user did not pass `--runner`). User-provided values (`pooling`, `draft`,
or explicit `generate`) are preserved.
Adds `TestRunnerPreservation` with five cases:
- auto -> generate default
- pooling preserved (embedding model use case from #7670 / DYN-3048)
- explicit generate preserved
- draft preserved
- missing `runner` attr (older vLLM) handled gracefully
This is a rebased + black-formatted version of #7680 by @pecord-ent.
GitHub issue #7670 was marked as fixed in a commit (7856cb2) that lives on
a diverged branch (1 ahead, 853 behind main) and never landed, so the bug
is still present on main today.
Fixes #7670
Refs DYN-3048
Co-authored-by: pecord-ent <patrick.ecord@ent.ai>
Signed-off-by: Tzu-Ling <tzulingk@nvidia.com>
…ig_with_dynamo
`update_engine_config_with_dynamo()` placed `"runner": "generate"` in the
unconditional `defaults` dict, which the subsequent setattr loop applied
without checking whether the user had set the value. Any `--runner pooling`
(required for embedding models like Qwen3-Embedding-0.6B / google/embeddinggemma-300m)
was silently overwritten and the engine crashed with:
pydantic_core._pydantic_core.ValidationError: 1 validation error for ModelConfig
Value error, This model does not support `--runner generate`.
Move the `runner` default out of the unconditional dict and guard it: only set
it to `"generate"` when `engine_config.runner == "auto"` (vLLM's default when
the user did not pass `--runner`). User-provided values (`pooling`, `draft`,
or explicit `generate`) are preserved.
Adds `TestRunnerPreservation` with five cases:
- auto -> generate default
- pooling preserved (embedding model use case from #7670 / DYN-3048)
- explicit generate preserved
- draft preserved
- missing `runner` attr (older vLLM) handled gracefully
This is a rebased + black-formatted version of #7680 by @pecord-ent.
GitHub issue #7670 was marked as fixed in a commit (7856cb2) that lives on
a diverged branch (1 ahead, 853 behind main) and never landed, so the bug
is still present on main today.
Fixes #7670
Refs DYN-3048
Co-authored-by: pecord-ent <patrick.ecord@ent.ai>
Signed-off-by: Tzu-Ling <tzulingk@nvidia.com>
…) (ai-dynamo#9710) Signed-off-by: Tzu-Ling <tzulingk@nvidia.com> Co-authored-by: pecord-ent <patrick.ecord@ent.ai>
…) (ai-dynamo#9710) Signed-off-by: Tzu-Ling <tzulingk@nvidia.com> Co-authored-by: pecord-ent <patrick.ecord@ent.ai> Signed-off-by: Michael Feil <63565275+michaelfeil@users.noreply.github.com>
Summary
update_engine_config_with_dynamo()unconditionally setengine_args.runner = "generate", overwriting any user-provided--runnerCLI argumentgoogle/embeddinggemma-300m) that require--runner pooling"generate"when the user didn't explicitly set--runner(i.e. vLLM's default"auto"is still in place)Root cause
The
defaultsdict inupdate_engine_config_with_dynamo()hardcoded"runner": "generate"and the subsequent loop applied all defaults unconditionally viasetattr, with no check for whether the user had already set the value.Fix
Moved the
runnerdefault out of the unconditionaldefaultsdict. Before adding it, we check ifengine_config.runneris still"auto"(vLLM's default when the user doesn't specify--runner). If the user explicitly provided a value likepoolingordraft, it is preserved.Changelog
components/src/dynamo/vllm/args.py: Checkengine_config.runnerbefore defaulting to"generate"components/src/dynamo/vllm/tests/test_vllm_unit.py: AddedTestRunnerPreservationclass with 5 test cases covering auto→generate default, pooling/generate/draft preservation, and graceful handling when therunnerattr is absent (older vLLM)Test plan
TestRunnerPreservation::test_runner_defaults_to_generate_when_auto— default behavior unchangedTestRunnerPreservation::test_runner_pooling_preserved— embedding model case from update_engine_config_with_dynamo unconditionally overrides --runner, breaking embedding models #7670TestRunnerPreservation::test_runner_generate_explicit_preserved— explicit generate still worksTestRunnerPreservation::test_runner_draft_preserved— draft runner preservedTestRunnerPreservation::test_no_runner_attr_skipped_gracefully— backward compat with older vLLM--runner poolingand verify it starts without theValidationErrorFixes #7670
🤖 Generated with Claude Code
Summary by CodeRabbit
Bug Fixes
Tests