Skip to content

Commit 7d46519

Browse files
authored
[CI/Build] Add bc-linter to vLLM CI (#21234)
Signed-off-by: zhewenli <[email protected]>
1 parent 569bf1c commit 7d46519

File tree

5 files changed

+121
-0
lines changed

5 files changed

+121
-0
lines changed

.github/.bc-linter.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# doc: https://github.com/pytorch/test-infra/blob/main/tools/stronghold/docs/bc_linter_config.md
2+
version: 1
3+
paths:
4+
# We temporarily disable globally, and will only enable with `annotations.include`
5+
# include:
6+
# - "vllm/v1/attetion/*.py"
7+
# - "vllm/v1/core/*.py"
8+
exclude:
9+
- "**/*.py"
10+
11+
scan:
12+
functions: true # check free functions and methods
13+
classes: true # check classes/dataclasses
14+
public_only: true # ignore names starting with "_" at any level
15+
16+
annotations:
17+
include: # decorators that force‑include a symbol
18+
- name: "bc_linter_include" # matched by simple name or dotted suffix
19+
propagate_to_members: false # for classes, include methods/inner classes
20+
exclude: # decorators that force‑exclude a symbol
21+
- name: "bc_linter_skip" # matched by simple name or dotted suffix
22+
propagate_to_members: true # for classes, exclude methods/inner classes
23+
24+
excluded_violations: [] # e.g. ["ParameterRenamed", "FieldTypeChanged"]

.github/workflows/bc-lint.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: BC Lint
2+
3+
on:
4+
pull_request:
5+
types:
6+
- opened
7+
- synchronize
8+
- reopened
9+
10+
jobs:
11+
bc_lint:
12+
if: github.repository_owner == 'vllm-project'
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Run BC Lint Action
16+
uses: pytorch/test-infra/.github/actions/bc-lint@main
17+
with:
18+
repo: ${{ github.event.pull_request.head.repo.full_name }}
19+
base_sha: ${{ github.event.pull_request.base.sha }}
20+
head_sha: ${{ github.event.pull_request.head.sha }}
21+
suppression: ${{ contains(github.event.pull_request.labels.*.name, 'suppress-bc-linter') }}
22+
docs_link: 'https://github.com/pytorch/test-infra/wiki/BC-Linter'
23+
config_dir: .github
24+
25+
concurrency:
26+
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }}
27+
cancel-in-progress: true

vllm/__init__.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
import vllm.env_override # noqa: F401
1515

1616
MODULE_ATTRS = {
17+
"bc_linter_skip": "._bc_linter:bc_linter_skip",
18+
"bc_linter_include": "._bc_linter:bc_linter_include",
1719
"AsyncEngineArgs": ".engine.arg_utils:AsyncEngineArgs",
1820
"EngineArgs": ".engine.arg_utils:EngineArgs",
1921
"AsyncLLMEngine": ".engine.async_llm_engine:AsyncLLMEngine",
@@ -54,6 +56,8 @@
5456
ScoringRequestOutput)
5557
from vllm.pooling_params import PoolingParams
5658
from vllm.sampling_params import SamplingParams
59+
60+
from ._bc_linter import bc_linter_include, bc_linter_skip
5761
else:
5862

5963
def __getattr__(name: str) -> typing.Any:
@@ -70,6 +74,8 @@ def __getattr__(name: str) -> typing.Any:
7074

7175
__all__ = [
7276
"__version__",
77+
"bc_linter_skip",
78+
"bc_linter_include",
7379
"__version_tuple__",
7480
"LLM",
7581
"ModelRegistry",

vllm/_bc_linter.py

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
# SPDX-License-Identifier: Apache-2.0
2+
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
3+
# vllm/_bc_linter.py
4+
from __future__ import annotations
5+
6+
from typing import Any, Callable, TypeVar, overload
7+
8+
T = TypeVar("T")
9+
10+
11+
@overload
12+
def bc_linter_skip(obj: T) -> T:
13+
...
14+
15+
16+
@overload
17+
def bc_linter_skip(*, reason: str | None = ...) -> Callable[[T], T]:
18+
...
19+
20+
21+
def bc_linter_skip(obj: Any = None, *, reason: str | None = None):
22+
"""
23+
No-op decorator to mark symbols/files for BC-linter suppression.
24+
25+
Usage:
26+
@bc_linter_skip
27+
def legacy_api(...): ...
28+
"""
29+
30+
def _wrap(x: T) -> T:
31+
return x
32+
33+
return _wrap if obj is None else obj
34+
35+
36+
@overload
37+
def bc_linter_include(obj: T) -> T:
38+
...
39+
40+
41+
@overload
42+
def bc_linter_include(*, reason: str | None = ...) -> Callable[[T], T]:
43+
...
44+
45+
46+
def bc_linter_include(obj: Any = None, *, reason: str | None = None):
47+
"""
48+
Usage:
49+
@bc_linter_include
50+
def public_api(...): ...
51+
"""
52+
53+
def _wrap(x: T) -> T:
54+
return x
55+
56+
return _wrap if obj is None else obj
57+
58+
59+
__all__ = ["bc_linter_skip", "bc_linter_include"]

vllm/v1/core/sched/output.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
from dataclasses import dataclass
77
from typing import TYPE_CHECKING, Optional
88

9+
from vllm import bc_linter_include
10+
911
if TYPE_CHECKING:
1012
import numpy as np
1113
import numpy.typing as npt
@@ -19,6 +21,7 @@
1921
from vllm.v1.request import Request
2022

2123

24+
@bc_linter_include
2225
@dataclass
2326
class NewRequestData:
2427

@@ -80,6 +83,7 @@ def anon_repr(self):
8083
")")
8184

8285

86+
@bc_linter_include
8387
@dataclass
8488
class CachedRequestData:
8589

@@ -109,6 +113,7 @@ def make_empty(cls) -> CachedRequestData:
109113
)
110114

111115

116+
@bc_linter_include
112117
@dataclass
113118
class SchedulerOutput:
114119

0 commit comments

Comments
 (0)