Skip to content

[Misc][BE] Type coverage for vllm/compilation [1/3]#31554

Merged
zou3519 merged 2 commits intovllm-project:mainfrom
Lucaskabela:lucaskabela/compilation_type_coverage
Jan 7, 2026
Merged

[Misc][BE] Type coverage for vllm/compilation [1/3]#31554
zou3519 merged 2 commits intovllm-project:mainfrom
Lucaskabela:lucaskabela/compilation_type_coverage

Conversation

@Lucaskabela
Copy link
Copy Markdown
Contributor

@Lucaskabela Lucaskabela commented Dec 31, 2025

Purpose

We want to provide better type hint coverage in vllm/compilation to improve maintainability, readability, and reduce silent errors

Test Plan

mypy vllm/compilation


Essential Elements of an Effective PR Description Checklist
  • The purpose of the PR, such as "Fix some issue (link existing issues this PR will resolve)".
  • The test plan, such as providing test command.
  • The test results, such as pasting the results comparison before and after, or e2e results
  • (Optional) The necessary documentation update, such as updating supported_models.md and examples for a new model.
  • (Optional) Release notes update. If your change is user facing, please update the release notes draft in the Google Doc.

@Lucaskabela Lucaskabela changed the title [BE] Type coverage for vllm/compilation [BE] Type coverage for vllm/compilation [1/?] Dec 31, 2025
@mergify mergify bot added the nvidia label Dec 31, 2025
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 significantly improves the type coverage for the vllm/compilation module. The added type hints are accurate and comprehensive, covering function signatures, variables, and return types, which will enhance code maintainability, readability, and help prevent silent errors. The use of more specific types like Generator, Literal, ParamSpec, and TypeVar is particularly noteworthy. Additionally, a crucial assertion was added to prevent a potential runtime TypeError, further improving the code's robustness. The changes are well-executed and represent a valuable improvement to the codebase.

@mergify
Copy link
Copy Markdown

mergify bot commented Dec 31, 2025

Hi @Lucaskabela, 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: Lucas Kabela <lucaskabela@meta.com>
@Lucaskabela Lucaskabela force-pushed the lucaskabela/compilation_type_coverage branch from 51066b2 to 40793b5 Compare January 2, 2026 16:05
@Lucaskabela Lucaskabela changed the title [BE] Type coverage for vllm/compilation [1/?] [Misc][BE] Type coverage for vllm/compilation [1/?] Jan 5, 2026
@Lucaskabela Lucaskabela changed the title [Misc][BE] Type coverage for vllm/compilation [1/?] [Misc][BE] Type coverage for vllm/compilation [1/3] Jan 5, 2026
def is_func(node: fx.Node, target) -> bool:
return node.op == "call_function" and node.target == target
def is_func(node: fx.Node, target: Target) -> bool:
return bool(node.op == "call_function" and node.target == target)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

why does this need a cast to bool?

Copy link
Copy Markdown
Contributor Author

@Lucaskabela Lucaskabela Jan 6, 2026

Choose a reason for hiding this comment

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

vLLM type checking is in a kind of weird mode - the follow_imports currently is set for pre-commit (locally), which for the case of some torch functions, means they are stubbed as Any types. This raises an error mismatch (returning Any when declared type bool), so an explicit cast makes the linter happy here

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

For all the directories in

https://github.com/vllm-project/vllm/blob/3c3c547ce0b35fb9d43808e8609f5e86fc34cca1/tools/pre_commit/mypy.py#L26C1-L54

follow imports has its default value for mypy. Note that vllm/compilation is not included in this list.

For all the directories in

SEPARATE_GROUPS = [
"tests",
# v0 related
"vllm/compilation",
"vllm/lora",
"vllm/model_executor",
# v1 related
"vllm/v1/kv_offload",
"vllm/v1/spec_decode",
]

mypy is run separately with --follow-imports skip.

Once all the import following related issues have been fixed for a directory in SEPARATE_GROUPS, it should be moved to FILES.

@Lucaskabela Lucaskabela requested a review from zou3519 January 6, 2026 00:42
@github-project-automation github-project-automation bot moved this to Ready in NVIDIA Jan 6, 2026
@zou3519 zou3519 added the ready ONLY add when PR is ready to merge/full CI is needed label Jan 6, 2026
@zou3519 zou3519 merged commit 873480d into vllm-project:main Jan 7, 2026
47 checks passed
@github-project-automation github-project-automation bot moved this from Ready to Done in NVIDIA Jan 7, 2026
tom-zju pushed a commit to tom-zju/vllm that referenced this pull request Jan 7, 2026
Signed-off-by: Lucas Kabela <lucaskabela@meta.com>
yugong333 pushed a commit to yugong333/vllm that referenced this pull request Jan 9, 2026
Signed-off-by: Lucas Kabela <lucaskabela@meta.com>
akh64bit pushed a commit to akh64bit/vllm that referenced this pull request Jan 16, 2026
Signed-off-by: Lucas Kabela <lucaskabela@meta.com>
dsuhinin pushed a commit to dsuhinin/vllm that referenced this pull request Jan 21, 2026
Signed-off-by: Lucas Kabela <lucaskabela@meta.com>
Signed-off-by: dsuhinin <suhinin.dmitriy@gmail.com>
@Lucaskabela Lucaskabela deleted the lucaskabela/compilation_type_coverage branch February 19, 2026 16:41
ItzDEXX pushed a commit to ItzDEXX/vllm that referenced this pull request Feb 19, 2026
Signed-off-by: Lucas Kabela <lucaskabela@meta.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

nvidia ready ONLY add when PR is ready to merge/full CI is needed

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

4 participants