[CI] Ignore ruff D209, rejoin the docstrings it split, and silence incompatible-rule warnings (#57212)

Signed-off-by: Harry Mellor <19981378+hmellor@users.noreply.github.com>
Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Harry Mellor
2026-09-16 10:57:24 -07:00
committed by GitHub
co-authored by Claude Opus 5
parent 1085b64425
commit 651a88c09a
693 changed files with 2088 additions and 4171 deletions
+1 -2
View File
@@ -76,8 +76,7 @@ class EncoderCudaGraphManager:
model: SupportsEncoderCudaGraph,
):
"""Initialize CUDA graph manager with provided token budgets
and max batch size.
"""
and max batch size."""
self.vllm_config = vllm_config
self.device = device
self.dtype = dtype
+4 -8
View File
@@ -62,8 +62,7 @@ class AttentionState(NamedTuple):
@dataclass(frozen=True)
class BatchExecutionDescriptor:
"""Describes the shape of the batch and CG mode to run; this is used to make shape
matches between the capture and runtime.
"""
matches between the capture and runtime."""
cg_mode: CUDAGraphMode
num_tokens: int
@@ -91,8 +90,7 @@ def make_cudagraph_stats(
class CreateForwardFn(Protocol):
"""Factory that prepares inputs (OUTSIDE the graph) and returns a
forward_fn. Called with warmup=True for the warmup pass and warmup=False
for the captured pass.
"""
for the captured pass."""
def __call__(
self,
@@ -955,8 +953,7 @@ def profile_cudagraph_memory(runner: "GPUModelRunner") -> int:
def _extrapolate_full_graph_memory(mem_samples: list[int], total_graphs: int) -> int:
"""Extrapolate the total FULL capture cost from samples of the largest
graphs. The first capture allocates the pool baseline; later graphs mostly
reuse it, so the second sample is taken as the per-graph cost.
"""
reuse it, so the second sample is taken as the per-graph cost."""
if not mem_samples:
return 0
first_capture = mem_samples[0]
@@ -993,8 +990,7 @@ def _init_minimal_kv_cache_for_profiling(runner: "GPUModelRunner") -> None:
def _teardown_profiling_state(runner: "GPUModelRunner") -> None:
"""Release the profiling KV cache and captured graphs while keeping model
weights, so the real ``initialize_kv_cache`` starts from a clean slate.
"""
weights, so the real ``initialize_kv_cache`` starts from a clean slate."""
torch.accelerator.synchronize()
if hasattr(runner.model_state, "_mamba_ctx"):
runner.model_state._mamba_ctx = None
+1 -2
View File
@@ -2228,8 +2228,7 @@ class GPUModelRunner(LoRAModelRunnerMixin):
def shutdown(self) -> None:
"""Release GPU tensors (model weights, KV caches, workspace) so that
memory is reclaimable when running in the same process.
"""
memory is reclaimable when running in the same process."""
torch.accelerator.synchronize()
self.cudagraph_manager = None
self.fast_prefill = None
+1 -2
View File
@@ -144,8 +144,7 @@ class ModelState(ABC):
) -> None:
"""Hook run on real batches before the forward pass (after block tables
are gathered). Used by mamba "align" prefix caching to pre-copy state
across block boundaries. No-op by default.
"""
across block boundaries. No-op by default."""
return None
def postprocess_state(
+2 -4
View File
@@ -38,8 +38,7 @@ def compute_need_sampled_mask(input_batch: InputBatch) -> np.ndarray | None:
"""Return a bool array of shape `[input_batch.num_reqs]` marking requests
that produce a sampled token this step, and therefore must have that token
(and the draft block proposed from it) propagated to the earlier PP stages.
Returns None if no request in the batch produces a sample.
"""
Returns None if no request in the batch produces a sample."""
old_computed = input_batch.num_computed_tokens_np
prefill_len = input_batch.prefill_len_np
# Exclude non-final prefill chunks (they don't produce a sample).
@@ -179,8 +178,7 @@ class PPHandler:
def receive(self, input_batch: InputBatch) -> bool:
"""Returns True iff sampled tokens need to be gathered from *all*
requests in the batch.
"""
requests in the batch."""
assert not self.is_last_rank
need_sampled_mask = compute_need_sampled_mask(input_batch)
if need_sampled_mask is None:
+1 -2
View File
@@ -76,8 +76,7 @@ MAX_COMPACT_SUPPORT = 2048
class SamplingMaskTensors(NamedTuple):
"""Device-side masks pending async D2H: compact ids, plus the bitmask as
the exact fallback for rows wider than ``max_num_kept``.
"""
the exact fallback for rows wider than ``max_num_kept``."""
# [num_requests, max_num_kept]
token_ids: torch.Tensor
+1 -2
View File
@@ -107,8 +107,7 @@ class Sampler:
self, idx_mapping_np: np.ndarray, include_token_ids: bool = True
) -> tuple[int, int] | None:
"""(num_logprobs, max_per_req_token_ids) for the given requests, or
None when none of them want logprobs.
"""
None when none of them want logprobs."""
max_num_logprobs = self.sampling_states.max_num_logprobs(idx_mapping_np)
max_token_ids = (
self.logprob_token_ids_state.max_num_token_ids(idx_mapping_np)
@@ -190,8 +190,7 @@ class AdaptiveVerificationManager:
"""Dummy-run kwargs whose step timings seed the cost tables.
Run these inside StepTimingCollector.collect(), then hand the block's
timings to set_initial_cost_curves.
"""
timings to set_initial_cost_curves."""
max_num_tokens = self.req_states.max_num_batched_tokens
size = self._cudagraph_limit = capture_sizes[-1] if capture_sizes else 0
# Also profile beyond the capture limit: real steps run there
@@ -261,8 +260,7 @@ class AdaptiveVerificationManager:
input_batch: "InputBatch",
) -> None:
"""Publish this step's raw confidences for the ranking kernel and start
copying them to the CPU, where a later step's budget reads them.
"""
copying them to the CPU, where a later step's budget reads them."""
num_reqs = input_batch.num_reqs
ready_idx = self._stale_idx ^ 1
with gpu_sync_allowed():
@@ -72,8 +72,7 @@ def _prepare_dflash_inputs_to_capture(
class DFlashCudaGraphManager(CudaGraphManager):
"""DFlash CudaGraphManager for the parallel-drafting query forward,
building its own attention metadata from scratch.
"""
building its own attention metadata from scratch."""
def capture(
self,
@@ -28,8 +28,7 @@ def _should_share(eagle: nn.Module, flag: str, draft, target) -> bool:
def get_target_lm_head(target_model: nn.Module, target_language_model: nn.Module):
"""The target's lm_head — from get_language_model() for
*ForConditionalGeneration targets, else the top-level module.
"""
*ForConditionalGeneration targets, else the top-level module."""
return getattr(target_language_model, "lm_head", None) or getattr(
target_model, "lm_head", None
)
+1 -2
View File
@@ -268,8 +268,7 @@ class DraftModelSpeculator(BaseSpeculator):
@property
def attn_vllm_config(self) -> VllmConfig:
"""Config for the draft's attention metadata builders. Overridden by
speculators whose attention mode differs from the target's.
"""
speculators whose attention mode differs from the target's."""
return self.vllm_config
def set_attn(
+5 -10
View File
@@ -481,8 +481,7 @@ class AsyncGPUPoolingModelRunnerOutput(AsyncModelRunnerOutput):
class ExecuteModelState(NamedTuple):
"""Ephemeral cached state transferred between execute_model() and
sample_tokens(), after execute_model() returns None.
"""
sample_tokens(), after execute_model() returns None."""
scheduler_output: "SchedulerOutput"
logits: torch.Tensor
@@ -1072,8 +1071,7 @@ class GPUModelRunner(
first scheduled token (column j is position start - 1 - j); -1 where
the position is before the prompt or already past it. Generated
positions are left to the model: under async scheduling the CPU token
table holds placeholders for them.
"""
table holds placeholders for them."""
buf = self.lookback_token_ids
assert buf is not None
buf.np.fill(-1)
@@ -3206,8 +3204,7 @@ class GPUModelRunner(
def _get_encoder_output_from_cache(self, mm_hash: str) -> torch.Tensor | None:
"""Return a cached encoder output for multimodal
embedding gather.
"""
embedding gather."""
return self.encoder_cache.get(mm_hash, None)
def _gather_mm_embeddings(
@@ -4179,8 +4176,7 @@ class GPUModelRunner(
This is true when `discard_request_mask` is set for every scheduled
request (e.g., for chunked prefill requests that are not the last
prefill chunk).
"""
prefill chunk)."""
num_reqs = self.input_batch.num_reqs
return bool(self.discard_request_mask.np[:num_reqs].all())
@@ -6573,8 +6569,7 @@ class GPUModelRunner(
def shutdown(self) -> None:
"""Release GPU tensors (model weights, KV caches, workspace) so that
memory is reclaimable when running in the same process.
"""
memory is reclaimable when running in the same process."""
from vllm.model_executor.layers.rotary_embedding import _ROPE_DICT
from vllm.v1.worker.workspace import reset_workspace_manager
+1 -2
View File
@@ -336,8 +336,7 @@ class Worker(WorkerBase):
def _scoped_allocator_max_split(self, max_split_size_mb: int):
"""Temporarily set max_split_size_mb to reduce allocator fragmentation at the
cost of more cudaMalloc calls (negligible in practice). Restores the original
value on exit.
"""
value on exit."""
if not current_platform.is_cuda():
yield
return
+3 -6
View File
@@ -77,8 +77,7 @@ def compute_plan_fingerprint(
def _plan_path(fingerprint: str) -> str:
"""Plans are regenerable derived state, so they live under the standard
vLLM cache root (like the torch.compile cache) and relocate with
``VLLM_CACHE_ROOT`` instead of needing a location knob of their own.
"""
``VLLM_CACHE_ROOT`` instead of needing a location knob of their own."""
# VLLM_CACHE_ROOT is already user-expanded by envs.py.
return os.path.join(
envs.VLLM_CACHE_ROOT, "startup_plan", f"startup_plan_{fingerprint}.json"
@@ -135,8 +134,7 @@ def _applicable_kv_cache_memory_bytes(
def maybe_apply_startup_plan(worker: "Worker") -> None:
"""If enabled and ``--kv-cache-memory`` was not set explicitly, apply a
persisted plan by setting ``worker.cache_config.kv_cache_memory_bytes``.
No-op unless ``VLLM_ENABLE_STARTUP_PLAN=1``.
"""
No-op unless ``VLLM_ENABLE_STARTUP_PLAN=1``."""
if (
not envs.VLLM_ENABLE_STARTUP_PLAN
or worker.cache_config.kv_cache_memory_bytes is not None
@@ -169,8 +167,7 @@ def maybe_apply_startup_plan(worker: "Worker") -> None:
def maybe_save_startup_plan(worker: "Worker", kv_cache_memory_bytes: int) -> None:
"""Atomically persist this boot's profiling result for future boots.
No-op unless ``VLLM_ENABLE_STARTUP_PLAN=1``; failures are logged,
never raised.
"""
never raised."""
if not envs.VLLM_ENABLE_STARTUP_PLAN:
return
fingerprint = compute_plan_fingerprint(
+1 -2
View File
@@ -128,8 +128,7 @@ class WorkerBase:
def synchronize_device(self) -> None:
"""Block until in-flight device work completes; backends outside
``torch.accelerator`` must override with their own wait.
"""
``torch.accelerator`` must override with their own wait."""
if torch.accelerator.is_available():
torch.accelerator.synchronize()