Skip to content

Turn @config into a dataclass_transform#31541

Merged
DarkLight1337 merged 20 commits intovllm-project:mainfrom
hmellor:merge-config-dataclass
Feb 3, 2026
Merged

Turn @config into a dataclass_transform#31541
DarkLight1337 merged 20 commits intovllm-project:mainfrom
hmellor:merge-config-dataclass

Conversation

@hmellor
Copy link
Copy Markdown
Member

@hmellor hmellor commented Dec 30, 2025

Main changes:

  • Converts the config decorator into a dataclass_transform
  • Now we only have to decorate new configs with config instead of config and dataclass
  • It also sets the default ConfigDict for this transformed dataclass to forbid extra fields (cc @mgoin who added this to some configs in /vllm/config/compilation.py)

Other changes:

  • Update tests to use config alone
  • mypy pre-commit hook updated because mypy needs to import config to understand it
  • Update config validator pre-commit hook to use config alone

Issues that doing this revealed:

  • One test was still passing decoding_config which was ignored prior to this PR
  • The same method was being used to generate the dict passed to SpeculativeConfig(**kwargs) and SpeculatorsConfig(**kwargs). This was not a problem for SpeculativeConfig because the PretrainedConfig would just accept the extra kwargs and ignore them. SpeculativeConfig also used to accept and ignore these fields but by adding extra="forbid", this became a problem. This PR also untangles the generation of kwargs for constructing these two classes for Speculators models.

Signed-off-by: Harry Mellor <19981378+hmellor@users.noreply.github.com>
Signed-off-by: Harry Mellor <19981378+hmellor@users.noreply.github.com>
Signed-off-by: Harry Mellor <19981378+hmellor@users.noreply.github.com>
Signed-off-by: Harry Mellor <19981378+hmellor@users.noreply.github.com>
Signed-off-by: Harry Mellor <19981378+hmellor@users.noreply.github.com>
Signed-off-by: Harry Mellor <19981378+hmellor@users.noreply.github.com>
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request correctly refactors the @config decorator into a dataclass_transform, simplifying config class definitions by removing the need for an explicit @dataclass decorator. The changes are applied consistently across the codebase, and the tests and pre-commit hooks are updated accordingly.

I found one issue in the updated validate_config.py pre-commit hook where the logic to validate decorators is flawed. I've provided a suggestion to fix this. Other than that, the changes look good and improve the developer experience when defining new configuration classes.

Comment thread tools/pre_commit/validate_config.py
@mergify
Copy link
Copy Markdown
Contributor

mergify Bot commented Dec 30, 2025

Hi @hmellor, the pre-commit checks have failed. Please run:

uv pip install pre-commit
pre-commit install
pre-commit run --all-files

Then, commit the changes and push to your branch.

For future commits, pre-commit will run automatically on changed files before each commit.

Tip

Is mypy or markdownlint failing?
mypy and markdownlint are run differently in CI. If the failure is related to either of these checks, please use the following commands to run them locally:
# For mypy (substitute "3.10" with the failing version if needed)
pre-commit run --hook-stage manual mypy-3.10
# For markdownlint
pre-commit run --hook-stage manual markdownlint

Signed-off-by: Harry Mellor <19981378+hmellor@users.noreply.github.com>
Signed-off-by: Harry Mellor <19981378+hmellor@users.noreply.github.com>
@DarkLight1337 DarkLight1337 enabled auto-merge (squash) January 2, 2026 14:14
@github-actions github-actions Bot added the ready ONLY add when PR is ready to merge/full CI is needed label Jan 2, 2026
Signed-off-by: Harry Mellor <19981378+hmellor@users.noreply.github.com>
Signed-off-by: Harry Mellor <19981378+hmellor@users.noreply.github.com>
@mergify
Copy link
Copy Markdown
Contributor

mergify Bot commented Jan 6, 2026

This pull request has merge conflicts that must be resolved before it can be
merged. Please rebase the PR, @hmellor.

https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/syncing-a-fork

@mergify mergify Bot added the needs-rebase label Jan 6, 2026
Signed-off-by: Harry Mellor <19981378+hmellor@users.noreply.github.com>
@mergify mergify Bot removed the needs-rebase label Jan 30, 2026
Signed-off-by: Harry Mellor <19981378+hmellor@users.noreply.github.com>
Signed-off-by: Harry Mellor <19981378+hmellor@users.noreply.github.com>
@mergify
Copy link
Copy Markdown
Contributor

mergify Bot commented Feb 2, 2026

Hi @hmellor, the pre-commit checks have failed. Please run:

uv pip install pre-commit
pre-commit install
pre-commit run --all-files

Then, commit the changes and push to your branch.

For future commits, pre-commit will run automatically on changed files before each commit.

Tip

Is mypy or markdownlint failing?
mypy and markdownlint are run differently in CI. If the failure is related to either of these checks, please use the following commands to run them locally:
# For mypy (substitute "3.10" with the failing version if needed)
pre-commit run --hook-stage manual mypy-3.10
# For markdownlint
pre-commit run --hook-stage manual markdownlint

Signed-off-by: Harry Mellor <19981378+hmellor@users.noreply.github.com>
Signed-off-by: Harry Mellor <19981378+hmellor@users.noreply.github.com>
Signed-off-by: Harry Mellor <19981378+hmellor@users.noreply.github.com>
@DarkLight1337 DarkLight1337 merged commit 61e632a into vllm-project:main Feb 3, 2026
50 checks passed
gameofdimension pushed a commit to gameofdimension/vllm that referenced this pull request Feb 5, 2026
Signed-off-by: Harry Mellor <19981378+hmellor@users.noreply.github.com>
Signed-off-by: felix01.yu <felix01.yu@vipshop.com>
@hmellor hmellor deleted the merge-config-dataclass branch February 5, 2026 11:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

frontend ready ONLY add when PR is ready to merge/full CI is needed speculative-decoding structured-output v1

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants