fix(vllm): apply Options[] engine flags before engine init - #11147
Open
localai-bot wants to merge 1 commit into
Open
fix(vllm): apply Options[] engine flags before engine init#11147localai-bot wants to merge 1 commit into
localai-bot wants to merge 1 commit into
Conversation
CLI-style flags in a model's `options:` array (`--quantization:gptq_marlin`, `--enable-prefix-caching`, `--kv-cache-dtype:fp8_e5m2`) were discarded: the backend only ever read `tool_parser`/`reasoning_parser` out of Options[], and did so *after* `AsyncLLMEngine.from_engine_args()`, where nothing it set could still reach the engine. Map `--` prefixed options onto the AsyncEngineArgs dataclass before the engine is constructed. Names are normalized the way vLLM's CLI spells them (`--enable-prefix-caching` -> `enable_prefix_caching`), values are coerced to the target field's type (bare flag -> True for booleans), and unknown or uncoercible flags warn and are skipped instead of failing the load, since Options[] is a bag shared with backend-level settings. Field types come from the annotation's base so `Literal["auto", "float16"]` (vLLM's dtype) is not mistaken for a float. Precedence is typed proto fields -> `options:` -> `engine_args:`. The production engine_args defaults seeded in hooks_vllm.go therefore skip any key the user already set as an option, otherwise the later engine_args pass would silently override it. Parser lookups now accept both spellings, so `--reasoning-parser:qwen3` selects LocalAI's parser as well. The helper's tests are stdlib-only and run in the lint workflow's dependency-light job via `make test-python-helpers`. Signed-off-by: Ettore Di Giacinto <mudler@localai.io> Assisted-by: Claude:claude-opus-5 golangci-lint
Owner
|
@localai-org-maint-bot CI is failing, pick this up and fix the branch |
Repository owner
deleted a comment from
localai-org-maint-bot
Jul 27, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #11130
Problem
CLI-style flags in a model's
options:array were silently discarded:The vLLM backend read
Options[]only fortool_parser/reasoning_parser, and read it afterAsyncLLMEngine.from_engine_args()- past the point where anything it set could still reach the engine.Fix
apply_options_to_engine_args()inbackend/python/common/vllm_utils.pymaps--prefixed options onto theAsyncEngineArgsdataclass, applied inLoadModelbefore the engine is constructed.--prefixed entries are engine flags, sotool_parser:,reasoning_parser:,vad_onlyand friends keep their meaning. Both--flag:value(LocalAI convention) and--flag=value(vLLM CLI convention) are accepted.--enable-prefix-caching->enable_prefix_caching); values are coerced to the target field's type; a bare--flagsets a boolean field totrue.engine_args:,Options[]is a shared bag that carries entries this mapping knows nothing about. Unknown flags get a closest-field hint.--tool-parser/--reasoning-parserare never reported as unknown: LocalAI consumes them itself, and whether the engine dataclass also carries the field varies by vLLM version.Type inference reads the annotation's base, not a substring. The first cut matched substrings and misread vLLM's
dtype: Literal["auto", "float16", "bfloat16"]as a float, silently dropping--dtype:bfloat16; there is a regression test for it. It also handles PEP 563 string annotations, which is how vLLM'sarg_utilsis written.Precedence: typed proto fields ->
options:->engine_args:. Sinceengine_args:lands last,applyEngineArgDefaultsincore/config/hooks_vllm.gonow skips seeding a production default whose key the user already set as an option - otherwise the seededenable_prefix_caching: truewould silently beat a user's--enable-prefix-caching:false.normalize_option_keyalso makes the parser lookup accept the CLI spelling, so--reasoning-parser:qwen3selects LocalAI's reasoning parser and not just the engine field.Tests
backend/python/common/vllm_utils_test.py- 20 stdlib-only specs covering coercion (bool/int/float/dict/str), bare flags,=separator, unknown-flag warn-and-skip with hint, uncoercible values,Literal-typed fields, PEP 563 string annotations, and non-flag options being left alone.core/config/hooks_test.go- two new specs: a default is not seeded when the user set that key viaoptions:, and unrelated options still get the defaults.make test-python-helperstarget, wired into the lint workflow's dependency-light job. These shared python helper tests previously ran nowhere in CI.make lintclean;core/configsuite green (409 specs).Not covered
vllm-omnibuildsOmni(**kwargs)rather than anAsyncEngineArgsdataclass, so it needs a different mapping and is untouched here.Docs
docs/content/features/text-generation.mdgains a "CLI-style engine flags inoptions" section stating the rules and the precedence;.agents/vllm-backend.mdrecords the ordering trap for future work.