Skip to content

feat(vllm): extract tensor_parallel_size and max_model_len from hf_overrides as server flags - #1083

Draft
Ravijangid820 wants to merge 2 commits into
docker:mainfrom
Ravijangid820:feat/vllm-hf-overrides-server-params
Draft

Ravijangid820 wants to merge 2 commits into
docker:mainfrom
Ravijangid820:feat/vllm-hf-overrides-server-params

Conversation

@Ravijangid820

Copy link
Copy Markdown

Summary

vLLM ignores server parameters like tensor_parallel_size and max_model_len when passed via --hf-overrides. This PR extracts these known server parameters from hf_overrides and passes them as proper --tensor-parallel-size and --max-model-len flags to the vLLM serve command.

Closes #912

Changes

  • pkg/inference/backends/vllm/vllm_config.go: After serializing hf_overrides, extract max_model_len and tensor_parallel_size and append them as proper vLLM serve flags
  • pkg/inference/backends/vllm/vllm_config_test.go: Add 4 test cases covering the new extraction behavior

Testing

  • All existing tests pass
  • New tests for tensor_parallel_size extraction
  • New tests for max_model_len extraction
  • New tests for both parameters together
  • New test verifying backend context size takes precedence over hf_overrides max_model_len
  • go test -race ./pkg/inference/... passes

🤖 Generated with Claude Code

…errides as server flags

vLLM ignores server parameters passed via --hf-overrides, so extract them
and pass as proper --tensor-parallel-size and --max-model-len flags.

Fixes docker#912

@sourcery-ai sourcery-ai 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.

Hey - I've found 1 issue

Prompt for AI Agents
Please address the comments from this code review:

## Individual Comments

### Comment 1
<location path="pkg/inference/backends/vllm/vllm_config.go" line_range="107" />
<code_context>
+			}
+			if tpSize, ok := config.VLLM.HFOverrides["tensor_parallel_size"]; ok {
+				if tp, ok := toInt(tpSize); ok {
+					args = append(args, "--tensor-parallel-size", strconv.Itoa(tp))
+				}
+			}
</code_context>
<issue_to_address>
**Explicit runtime settings are overridden**

When runtimeFlags and HFOverrides specify different values for the same extracted server parameter, `GetArgs` appends the HF-derived flag after `config.RuntimeFlags`, so vLLM receives duplicate options and uses the later HF-derived value. The caller's explicit runtime setting is ignored.

Avoid appending an HF-derived flag when RuntimeFlags already specifies that option, so the explicit runtime setting takes precedence.

Also at `pkg/inference/backends/vllm/vllm_config.go:97-102`.
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨

Comment thread pkg/inference/backends/vllm/vllm_config.go
When RuntimeFlags already specifies --tensor-parallel-size or
--max-model-len, skip the HF-derived flag so vLLM receives the
explicit runtime setting (no duplicate flags).

Fixes docker#912 follow-up

Copilot AI 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.

🟡 Changes recommended

Numeric conversion and short runtime-flag alias handling can produce incorrect server arguments.

3 open findings
What changed in this PR

Extracts vLLM server-specific settings from Hugging Face overrides into command-line flags.

Changes:

  • Adds extraction and runtime-flag precedence handling.
  • Adds coverage for extraction and precedence scenarios.
File Description
vllm_config.go Converts selected overrides into vLLM server flags.
vllm_config_test.go Tests extraction and precedence behavior.

🧠 Review effort: Balanced


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

}
}
if tpSize, ok := config.VLLM.HFOverrides["tensor_parallel_size"]; ok {
if tp, ok := toInt(tpSize); ok && !hasRuntimeFlag(config.RuntimeFlags, "--tensor-parallel-size") {
Comment on lines +120 to +121
case float64:
return int(val), true
Comment on lines +128 to +129
default:
return 0, false
@ericcurtin

Copy link
Copy Markdown
Contributor

Thanks @Ravijangid820! model-runner is being deprecated in favour of https://github.com/llmmanorg/llmman, so please open PRs there instead. If continuing here, please fix the gci lint failure and Copilot's findings (non-integral floats, -tp alias, int overflow). Setting to draft, please reopen when ready for re-review.

@ericcurtin
ericcurtin marked this pull request as draft October 14, 2026 20:16

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Unable to set vllm serve parameters using hf_overrides

3 participants