Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions .github/.bc-linter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# doc: https://github.com/pytorch/test-infra/blob/main/tools/stronghold/docs/bc_linter_config.md
version: 1
paths:
# We temporarily disable globally, and will only enable with `annotations.include`
# include:
# - "vllm/v1/attetion/*.py"
# - "vllm/v1/core/*.py"
exclude:
- "**/*.py"

scan:
functions: true # check free functions and methods
classes: true # check classes/dataclasses
public_only: true # ignore names starting with "_" at any level

annotations:
include: # decorators that force‑include a symbol
- name: "bc_linter_include" # matched by simple name or dotted suffix
propagate_to_members: false # for classes, include methods/inner classes
exclude: # decorators that force‑exclude a symbol
- name: "bc_linter_skip" # matched by simple name or dotted suffix
propagate_to_members: true # for classes, exclude methods/inner classes

excluded_violations: [] # e.g. ["ParameterRenamed", "FieldTypeChanged"]
26 changes: 26 additions & 0 deletions .github/workflows/bc-lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: BC Lint

on:
pull_request:
types:
- opened
- synchronize
- reopened

jobs:
bc_lint:
if: github.repository_owner == 'vllm-project'
runs-on: ubuntu-latest
steps:
- name: Run BC Lint Action
uses: pytorch/test-infra/.github/actions/bc-lint@main
with:
repo: ${{ github.event.pull_request.head.repo.full_name }}
base_sha: ${{ github.event.pull_request.base.sha }}
head_sha: ${{ github.event.pull_request.head.sha }}
suppression: ${{ contains(github.event.pull_request.labels.*.name, 'suppress-bc-linter') }}
docs_link: 'https://github.com/pytorch/test-infra/wiki/BC-Linter'

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }}
cancel-in-progress: true
6 changes: 6 additions & 0 deletions vllm/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
import vllm.env_override # noqa: F401

MODULE_ATTRS = {
"bc_linter_skip": "._bc_linter:bc_linter_skip",
+ "bc_linter_include": "._bc_linter:bc_linter_include",

Check failure on line 18 in vllm/__init__.py

View workflow job for this annotation

GitHub Actions / pre-commit

Unsupported operand type for unary + ("str") [operator]

Check failure on line 18 in vllm/__init__.py

View workflow job for this annotation

GitHub Actions / pre-commit

Unsupported operand type for unary + ("str") [operator]

Check failure on line 18 in vllm/__init__.py

View workflow job for this annotation

GitHub Actions / pre-commit

Unsupported operand type for unary + ("str") [operator]

Check failure on line 18 in vllm/__init__.py

View workflow job for this annotation

GitHub Actions / pre-commit

Unsupported operand type for unary + ("str") [operator]

Check failure on line 18 in vllm/__init__.py

View workflow job for this annotation

GitHub Actions / pre-commit

Unsupported operand type for unary + ("str") [operator]

Check failure on line 18 in vllm/__init__.py

View workflow job for this annotation

GitHub Actions / pre-commit

Unsupported operand type for unary + ("str") [operator]

Check failure on line 18 in vllm/__init__.py

View workflow job for this annotation

GitHub Actions / pre-commit

Unsupported operand type for unary + ("str") [operator]

Check failure on line 18 in vllm/__init__.py

View workflow job for this annotation

GitHub Actions / pre-commit

Unsupported operand type for unary + ("str") [operator]

Check failure on line 18 in vllm/__init__.py

View workflow job for this annotation

GitHub Actions / pre-commit

Unsupported operand type for unary + ("str") [operator]

Check failure on line 18 in vllm/__init__.py

View workflow job for this annotation

GitHub Actions / pre-commit

Unsupported operand type for unary + ("str") [operator]

Check failure on line 18 in vllm/__init__.py

View workflow job for this annotation

GitHub Actions / pre-commit

Unsupported operand type for unary + ("str") [operator]

Check failure on line 18 in vllm/__init__.py

View workflow job for this annotation

GitHub Actions / pre-commit

Unsupported operand type for unary + ("str") [operator]

Check failure on line 18 in vllm/__init__.py

View workflow job for this annotation

GitHub Actions / pre-commit

Unsupported operand type for unary + ("str") [operator]

Check failure on line 18 in vllm/__init__.py

View workflow job for this annotation

GitHub Actions / pre-commit

Unsupported operand type for unary + ("str") [operator]

Check failure on line 18 in vllm/__init__.py

View workflow job for this annotation

GitHub Actions / pre-commit

Unsupported operand type for unary + ("str") [operator]

Check failure on line 18 in vllm/__init__.py

View workflow job for this annotation

GitHub Actions / pre-commit

Unsupported operand type for unary + ("str") [operator]

Check failure on line 18 in vllm/__init__.py

View workflow job for this annotation

GitHub Actions / pre-commit

Unsupported operand type for unary + ("str") [operator]

Check failure on line 18 in vllm/__init__.py

View workflow job for this annotation

GitHub Actions / pre-commit

Unsupported operand type for unary + ("str") [operator]
"AsyncEngineArgs": ".engine.arg_utils:AsyncEngineArgs",
"EngineArgs": ".engine.arg_utils:EngineArgs",
"AsyncLLMEngine": ".engine.async_llm_engine:AsyncLLMEngine",
Expand Down Expand Up @@ -54,6 +56,8 @@
ScoringRequestOutput)
from vllm.pooling_params import PoolingParams
from vllm.sampling_params import SamplingParams

from ._bc_linter import bc_linter_include, bc_linter_skip
else:

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

__all__ = [
"__version__",
"bc_linter_skip",
"bc_linter_include",
"__version_tuple__",
"LLM",
"ModelRegistry",
Expand Down
59 changes: 59 additions & 0 deletions vllm/_bc_linter.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# SPDX-License-Identifier: Apache-2.0
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
# vllm/_bc_linter.py
from __future__ import annotations

from typing import Any, Callable, TypeVar, overload

T = TypeVar("T")


@overload
def bc_linter_skip(obj: T) -> T:
...


@overload
def bc_linter_skip(*, reason: str | None = ...) -> Callable[[T], T]:
...


def bc_linter_skip(obj: Any = None, *, reason: str | None = None):
"""
No-op decorator to mark symbols/files for BC-linter suppression.

Usage:
@bc_linter_skip
def legacy_api(...): ...
"""

def _wrap(x: T) -> T:
return x

return _wrap if obj is None else obj


@overload
def bc_linter_include(obj: T) -> T:
...


@overload
def bc_linter_include(*, reason: str | None = ...) -> Callable[[T], T]:
...


def bc_linter_include(obj: Any = None, *, reason: str | None = None):
"""
Usage:
@bc_linter_include
def public_api(...): ...
"""

def _wrap(x: T) -> T:
return x

return _wrap if obj is None else obj


__all__ = ["bc_linter_skip", "bc_linter_include"]
10 changes: 8 additions & 2 deletions vllm/v1/core/sched/output.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
from dataclasses import dataclass
from typing import TYPE_CHECKING, Optional

from vllm import bc_linter_include

if TYPE_CHECKING:
import numpy as np
import numpy.typing as npt
Expand All @@ -19,6 +21,7 @@
from vllm.v1.request import Request


@bc_linter_include
@dataclass
class NewRequestData:

Expand Down Expand Up @@ -92,7 +95,8 @@
# When PP is not used, new_token_ids will be empty.
new_token_ids: list[list[int]]
new_block_ids: list[Optional[tuple[list[int], ...]]]
num_computed_tokens: list[int]
# NOTE: this class is NOT protected by `@bc_linter_include`, expect no bc failure

Check failure on line 98 in vllm/v1/core/sched/output.py

View workflow job for this annotation

GitHub Actions / pre-commit

Ruff (E501)

vllm/v1/core/sched/output.py:98:81: E501 Line too long (85 > 80)

Check failure on line 98 in vllm/v1/core/sched/output.py

View workflow job for this annotation

GitHub Actions / pre-commit

Ruff (E501)

vllm/v1/core/sched/output.py:98:81: E501 Line too long (85 > 80)
num_computed_tokens: list[float]

Check warning on line 99 in vllm/v1/core/sched/output.py

View workflow job for this annotation

GitHub Actions / bc_lint

Function CachedRequestData: num_computed_tokens changed from list[int] to list[float]

Check warning on line 99 in vllm/v1/core/sched/output.py

View workflow job for this annotation

GitHub Actions / bc_lint

Function CachedRequestData: num_computed_tokens changed from list[int] to list[float]

@property
def num_reqs(self) -> int:
Expand All @@ -109,6 +113,7 @@
)


@bc_linter_include
@dataclass
class SchedulerOutput:

Expand All @@ -126,7 +131,8 @@
num_scheduled_tokens: dict[str, int]
# Total number of tokens scheduled for all requests.
# Equal to sum(num_scheduled_tokens.values())
total_num_scheduled_tokens: int
# NOTE: this class is protected by `@bc_linter_include`, expect bc failure
total_num_scheduled_tokens: float

Check warning on line 135 in vllm/v1/core/sched/output.py

View workflow job for this annotation

GitHub Actions / bc_lint

Function SchedulerOutput: total_num_scheduled_tokens changed from int to float

Check warning on line 135 in vllm/v1/core/sched/output.py

View workflow job for this annotation

GitHub Actions / bc_lint

Function SchedulerOutput: total_num_scheduled_tokens changed from int to float
# req_id -> spec_token_ids
# If a request does not have any spec decode tokens, it will not be
# included in the dictionary.
Expand Down
Loading