Add pydocstyle to the ruff rules (#52136)
Signed-off-by: Harry Mellor <19981378+hmellor@users.noreply.github.com> Signed-off-by: Harry Mellor <hej.mellor@gmail.com> Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5
parent
804e5377aa
commit
8c1557a79c
+19
-28
@@ -153,8 +153,8 @@ IS_DENSE = False
|
||||
|
||||
def enable_norm_fusion(cfg: "VllmConfig") -> bool:
|
||||
"""Enable if either RMS norm or quant FP8 custom op is active;
|
||||
otherwise Inductor handles fusion."""
|
||||
|
||||
otherwise Inductor handles fusion.
|
||||
"""
|
||||
return (
|
||||
cfg.compilation_config.is_custom_op_enabled("rms_norm")
|
||||
or cfg.compilation_config.is_custom_op_enabled("quant_fp8")
|
||||
@@ -163,8 +163,7 @@ def enable_norm_fusion(cfg: "VllmConfig") -> bool:
|
||||
|
||||
|
||||
def enable_act_fusion(cfg: "VllmConfig") -> bool:
|
||||
"""
|
||||
Enable if either SiLU+Mul or quant FP8 custom op is active;
|
||||
"""Enable if either SiLU+Mul or quant FP8 custom op is active;
|
||||
otherwise Inductor handles fusion.
|
||||
Also enable for FP4 models as FP4 quant is always custom so Inductor cannot fuse it.
|
||||
"""
|
||||
@@ -220,7 +219,6 @@ def enable_rope_kvcache_fusion(cfg: "VllmConfig") -> bool:
|
||||
|
||||
def enable_rope_kvcache_mla_fusion(cfg: "VllmConfig") -> bool:
|
||||
"""Enable if use_inductor_graph_partition is enabled."""
|
||||
|
||||
return (
|
||||
cfg.compilation_config.use_inductor_graph_partition
|
||||
or not cfg.compilation_config.splitting_ops_contain_kv_cache_update()
|
||||
@@ -229,7 +227,6 @@ def enable_rope_kvcache_mla_fusion(cfg: "VllmConfig") -> bool:
|
||||
|
||||
def enable_norm_pad_fusion(cfg: "VllmConfig") -> bool:
|
||||
"""Enable if using AITER RMSNorm and hidden size is 2880 i.e. gpt-oss."""
|
||||
|
||||
return (
|
||||
cfg.kernel_config.ir_op_priority.fused_add_rms_norm[0] == "aiter"
|
||||
and cfg.model_config is not None
|
||||
@@ -460,8 +457,7 @@ class VllmConfig:
|
||||
"""
|
||||
|
||||
def compute_hash(self, include_version: bool = True) -> str:
|
||||
"""
|
||||
WARNING: Whenever a new field is added to this config,
|
||||
"""WARNING: Whenever a new field is added to this config,
|
||||
ensure that it is included in the factors list if
|
||||
it affects the computation graph.
|
||||
|
||||
@@ -473,6 +469,7 @@ class VllmConfig:
|
||||
|
||||
Args:
|
||||
include_version: Include the vLLM version in the hash.
|
||||
|
||||
"""
|
||||
factors: list[Any] = []
|
||||
|
||||
@@ -747,7 +744,8 @@ class VllmConfig:
|
||||
|
||||
def _is_dflash2_draft(self) -> bool:
|
||||
"""Whether the DFlash draft is a DFlash2 one, by the architecture the
|
||||
speculator selects on (v1/worker/gpu/spec_decode/__init__.py)."""
|
||||
speculator selects on (v1/worker/gpu/spec_decode/__init__.py).
|
||||
"""
|
||||
spec = self.speculative_config
|
||||
if spec is None or spec.method != "dflash":
|
||||
return False
|
||||
@@ -798,8 +796,7 @@ class VllmConfig:
|
||||
|
||||
@property
|
||||
def needs_dp_coordinator(self) -> bool:
|
||||
"""
|
||||
Determine if the DPCoordinator process is needed.
|
||||
"""Determine if the DPCoordinator process is needed.
|
||||
|
||||
The DPCoordinator is needed in two cases:
|
||||
1. For MoE models with DP > 1: to handle wave coordination
|
||||
@@ -809,8 +806,8 @@ class VllmConfig:
|
||||
|
||||
Returns:
|
||||
True if DPCoordinator process is needed, False otherwise.
|
||||
"""
|
||||
|
||||
"""
|
||||
# For non-MoE models, only need coordinator in internal/hybrid LB mode
|
||||
# (for stats collection).
|
||||
return self.parallel_config.data_parallel_size > 1 and (
|
||||
@@ -820,8 +817,7 @@ class VllmConfig:
|
||||
)
|
||||
|
||||
def enable_trace_function_call_for_thread(self) -> None:
|
||||
"""
|
||||
Set up function tracing for the current thread,
|
||||
"""Set up function tracing for the current thread,
|
||||
if enabled via the `VLLM_TRACE_FUNCTION` environment variable.
|
||||
"""
|
||||
if envs.VLLM_TRACE_FUNCTION:
|
||||
@@ -955,6 +951,7 @@ class VllmConfig:
|
||||
config_obj: Configuration object to update.
|
||||
key: Attribute name.
|
||||
value: Default value (static or callable).
|
||||
|
||||
"""
|
||||
if getattr(config_obj, key) is None:
|
||||
# Some config values are known before initialization and are
|
||||
@@ -976,6 +973,7 @@ class VllmConfig:
|
||||
|
||||
Args:
|
||||
defaults: Dictionary of default values to apply.
|
||||
|
||||
"""
|
||||
|
||||
def apply_recursive(config_obj: Any, config_defaults: dict[str, Any]) -> None:
|
||||
@@ -1276,7 +1274,6 @@ class VllmConfig:
|
||||
|
||||
def __post_init__(self):
|
||||
"""Verify configs are valid & consistent with each other."""
|
||||
|
||||
# To give each torch profile run a unique instance name.
|
||||
self.instance_id = f"{time.time_ns()}"
|
||||
|
||||
@@ -2133,8 +2130,7 @@ class VllmConfig:
|
||||
]
|
||||
|
||||
def _set_max_num_scheduled_tokens(self):
|
||||
"""
|
||||
In most cases, the scheduler may schedule a batch with as many tokens as the
|
||||
"""In most cases, the scheduler may schedule a batch with as many tokens as the
|
||||
worker is configured to handle.
|
||||
"""
|
||||
if self.speculative_config is not None:
|
||||
@@ -2172,8 +2168,7 @@ class VllmConfig:
|
||||
)
|
||||
|
||||
def _set_cudagraph_sizes(self):
|
||||
"""
|
||||
vLLM defines the default candidate list of batch sizes for CUDA graph
|
||||
"""VLLM defines the default candidate list of batch sizes for CUDA graph
|
||||
capture as:
|
||||
|
||||
```python
|
||||
@@ -2219,8 +2214,8 @@ class VllmConfig:
|
||||
padded CUDA graph will be used.
|
||||
- If batch size > largest `cudagraph_capture_sizes`, cudagraph will
|
||||
not be used.
|
||||
"""
|
||||
|
||||
"""
|
||||
if (
|
||||
self.model_config is not None
|
||||
and not self.model_config.enforce_eager
|
||||
@@ -2441,9 +2436,7 @@ class VllmConfig:
|
||||
self.compilation_config.post_init_cudagraph_sizes()
|
||||
|
||||
def _set_compile_ranges(self):
|
||||
"""
|
||||
Set the compile ranges for the compilation config.
|
||||
"""
|
||||
"""Set the compile ranges for the compilation config."""
|
||||
compilation_config = self.compilation_config
|
||||
computed_compile_ranges_endpoints = []
|
||||
|
||||
@@ -3310,8 +3303,7 @@ _current_prefix: str | None = None
|
||||
def set_current_vllm_config(
|
||||
vllm_config: VllmConfig, check_compile=False, prefix: str | None = None
|
||||
):
|
||||
"""
|
||||
Temporarily set the current vLLM config.
|
||||
"""Temporarily set the current vLLM config.
|
||||
Used during model initialization.
|
||||
We save the current vLLM config in a global variable,
|
||||
so that all modules can access it, e.g. custom ops
|
||||
@@ -3392,15 +3384,14 @@ def get_layers_from_vllm_config(
|
||||
layer_type: type[T],
|
||||
layer_names: Iterable[str] | None = None,
|
||||
) -> dict[str, T]:
|
||||
"""
|
||||
Get layers from the vLLM config.
|
||||
"""Get layers from the vLLM config.
|
||||
|
||||
Args:
|
||||
vllm_config: The vLLM config.
|
||||
layer_type: The type of the layer to get.
|
||||
layer_names: The names of the layers to get. If None, return all layers.
|
||||
"""
|
||||
|
||||
"""
|
||||
forward_context = vllm_config.compilation_config.static_forward_context
|
||||
if layer_names is None:
|
||||
layer_names = forward_context.keys()
|
||||
|
||||
Reference in New Issue
Block a user