Skip to content

[Fix] Avoid duplicate generation config override kwargs - #5055

Open
kokyouu wants to merge 2 commits into
InternLM:mainfrom
kokyouu:kokyouu/fix-generation-config-overrides
Open

kokyouu wants to merge 2 commits into
InternLM:mainfrom
kokyouu:kokyouu/fix-generation-config-overrides

Conversation

@kokyouu

@kokyouu kokyouu commented Oct 22, 2026

Copy link
Copy Markdown

Motivation

A custom --generation-config directory may contain LMDeploy-compatible keys such as stop_words. The loader retains those keys, while the serving endpoints also supply mapped/computed kwargs (for example, stop_words=request.stop). The builder currently removes overlaps only from the request before merging server defaults. The default therefore reaches the constructor alongside the explicit kwarg and raises TypeError: GenerationConfig() got multiple values for keyword argument 'stop_words'.

This is reproducible offline with a temporary generation_config.json containing {"do_sample": true, "temperature": 0.6, "stop_words": ["default-stop"]}, loaded through resolve_default_gen_config and passed to build_serving_generation_config. Both an omitted stop and an explicit request stop fail on main. random_seed and computed logprobs have the same collision when present in the defaults.

Modification

  • Remove explicit kwarg overlaps from the merged config, so they cannot be reintroduced by the server defaults.
  • Preserve explicit kwarg precedence, including None, without mutating the defaults or changing the special handling of generation length and sampling mode.
  • Add four direct regressions for mapped/computed values, plus two regressions that load a real local config file and use the serving builder.

Validation

  • On base aba987ad2266d2fd2204e9d22d1ce43a5984dc91, the six added cases fail with duplicate-keyword TypeError.
  • After the fix: 386 passed across the generation-config suite, parser suite, chat runner, Responses request conversion, completions/chat-completions, generate-logprobs and Anthropic tests.
  • All applicable repository pre-commit hooks pass for the two changed files; git diff --check passes.

Local validation uses Python 3.12.3 on Windows with PyTorch 2.7.1 and Transformers 4.57.1. No model downloads, GPU inference, full-repository suite or dependency-version matrix was run. The existing deprecation/Pydantic/optional-JIT warnings remain.

Checklist

  • Run the repository's pre-commit hooks on the changed files.
  • Add regression tests and run adjacent unit suites.
  • Update the helper docstring to describe explicit kwarg precedence.
  • No dependency changes or intentional compatibility break.

Developed with AI assistance; the patch, baseline failures and final test results were checked locally.

Update generation configuration logic to prioritize extra kwargs.
Cover mapped stop words, random seeds, computed logprobs, explicit None and an offline custom generation_config.json.

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.

1 participant