Skip to content

Enable Pydantic mypy checks and convert configs to Pydantic dataclasses #17599

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 27 commits into
base: main
Choose a base branch
from

Conversation

hmellor
Copy link
Member

@hmellor hmellor commented May 2, 2025

  • Enables the mypy extension for Pydantic
  • Fix the new mypy errors created by doing that
  • Swap out the builtin dataclasses for Pydantic dataclasses (free input validation!)
    $ vllm serve meta-llama/Llama-3.2-1B-Instruct --gpu-memory-utilization 0.45 --compilation-config '{"level":2.5}'
    INFO 05-12 12:59:58 [__init__.py:248] Automatically detected platform cuda.
    WARNING 05-12 13:00:02 [config.py:2034] max_model_len was is not set. Defaulting to arbitrary value of 8192.
    WARNING 05-12 13:00:02 [config.py:2040] max_num_seqs was is not set. Defaulting to arbitrary value of 128.
    usage: vllm serve [model_tag] [options]
    vllm serve: error: argument --compilation-config/-O: 1 validation error for CompilationConfig
    level
      Input should be a valid integer, got a number with a fractional part [type=int_from_float, input_value=2.5, input_type=float]
        For further information visit https://errors.pydantic.dev/2.11/v/int_from_float

N.B. Pydantic base models handle mutable defaults correctly. x: list = [] looks much nicer than the alternative mypy will allow x: list = Field(default_factory=lambda: [])

hmellor added 4 commits May 2, 2025 20:46
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>
@hmellor hmellor requested review from mgoin and russellb as code owners May 2, 2025 19:32
Copy link

github-actions bot commented May 2, 2025

👋 Hi! Thank you for contributing to the vLLM project.

💬 Join our developer Slack at https://slack.vllm.ai to discuss your PR in #pr-reviews, coordinate on features in #feat- channels, or join special interest groups in #sig- channels.

Just a reminder: PRs would not trigger full CI run by default. Instead, it would only run fastcheck CI which starts running only a small and essential subset of CI tests to quickly catch errors. You can run other CI tests on top of those by going to your fastcheck build on Buildkite UI (linked in the PR checks section) and unblock them. If you do not have permission to unblock, ping simon-mo or khluu to add you in our Buildkite org.

Once the PR is approved and ready to go, your PR reviewer(s) can run CI to test the changes comprehensively before merging.

To run CI, PR reviewers can either: Add ready label to the PR or enable auto-merge.

🚀

@mergify mergify bot added frontend structured-output tpu Related to Google TPUs labels May 2, 2025
@hmellor hmellor changed the title Enable-pydantic-mypy Enable Pydantic mypy checks and convert configs to Pydantic dataclasses May 2, 2025
@hmellor
Copy link
Member Author

hmellor commented May 2, 2025

I think this PR must wait for #17485. Hopefully the switch to static analysis in the docs build will prevent the Pydantic errors

russellb
russellb previously approved these changes May 5, 2025
Copy link
Member

@russellb russellb left a comment

Choose a reason for hiding this comment

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

thanks!

Copy link
Member

@russellb russellb left a comment

Choose a reason for hiding this comment

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

well, I'm happy with the changes in general, but it looks like you have some failing tests.

@russellb russellb dismissed their stale review May 5, 2025 12:33

dismissing approval, pending test resolution

Copy link

mergify bot commented May 6, 2025

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 May 6, 2025
Signed-off-by: Harry Mellor <19981378+hmellor@users.noreply.github.com>
@hmellor hmellor marked this pull request as draft May 12, 2025 09:42
hmellor added 2 commits May 12, 2025 11:43
Signed-off-by: Harry Mellor <19981378+hmellor@users.noreply.github.com>
Signed-off-by: Harry Mellor <19981378+hmellor@users.noreply.github.com>
@mergify mergify bot removed tpu Related to Google TPUs needs-rebase labels May 12, 2025
hmellor added 4 commits May 12, 2025 12:11
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>
hmellor added 5 commits May 12, 2025 12:27
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>
@hmellor hmellor marked this pull request as ready for review May 12, 2025 19:39
Copy link

mergify bot commented May 12, 2025

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 May 12, 2025
Signed-off-by: Harry Mellor <19981378+hmellor@users.noreply.github.com>
Signed-off-by: Harry Mellor <19981378+hmellor@users.noreply.github.com>
@mergify mergify bot removed the needs-rebase label May 15, 2025
@simon-mo simon-mo enabled auto-merge (squash) May 15, 2025 22:45
@github-actions github-actions bot added the ready ONLY add when PR is ready to merge/full CI is needed label May 15, 2025
hmellor added 7 commits May 16, 2025 08:42
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>
Signed-off-by: Harry Mellor <19981378+hmellor@users.noreply.github.com>
@hmellor
Copy link
Member Author

hmellor commented May 16, 2025

Instead of fighting Sphinx, I will try and merge #18145 so that we never have to think about breaking the docs build again 🎉

Copy link

mergify bot commented May 19, 2025

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 May 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
frontend needs-rebase ready ONLY add when PR is ready to merge/full CI is needed structured-output
Projects
Status: No status
Development

Successfully merging this pull request may close these issues.

4 participants