[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:
co-authored by
Claude Opus 5
parent
1085b64425
commit
651a88c09a
@@ -36,8 +36,7 @@ class BaseModelLoader(ABC):
|
||||
@abstractmethod
|
||||
def load_weights(self, model: nn.Module, model_config: ModelConfig) -> None:
|
||||
"""Load weights into a model. This standalone API allows
|
||||
inplace weights loading for an already-initialized model
|
||||
"""
|
||||
inplace weights loading for an already-initialized model"""
|
||||
raise NotImplementedError
|
||||
|
||||
def create_model(
|
||||
|
||||
@@ -135,8 +135,7 @@ class DefaultModelLoader(BaseModelLoader):
|
||||
) -> tuple[str, list[str], bool]:
|
||||
"""Prepare weights for the model.
|
||||
|
||||
If the model is not local, it will be downloaded.
|
||||
"""
|
||||
If the model is not local, it will be downloaded."""
|
||||
model_name_or_path = (
|
||||
maybe_download_from_modelscope(model_name_or_path, revision)
|
||||
or model_name_or_path
|
||||
|
||||
@@ -23,8 +23,7 @@ def parse_expert_id(weight_name: str) -> int | None:
|
||||
|
||||
Returns ``None`` for dense weights (attention, layernorm, embedding),
|
||||
shared experts, and 3D fused-expert tensors where all experts are stored
|
||||
in a single tensor without a numeric expert id in the name.
|
||||
"""
|
||||
in a single tensor without a numeric expert id in the name."""
|
||||
m = _EXPERT_ID_RE.search(weight_name)
|
||||
return int(m.group(1)) if m else None
|
||||
|
||||
@@ -71,8 +70,7 @@ def should_skip_weight(
|
||||
local_expert_ids: set[int] | None,
|
||||
) -> bool:
|
||||
"""Return ``True`` if *weight_name* is an expert weight that does not
|
||||
belong to the local rank and should be skipped during loading.
|
||||
"""
|
||||
belong to the local rank and should be skipped during loading."""
|
||||
if local_expert_ids is None:
|
||||
return False
|
||||
eid = parse_expert_id(weight_name)
|
||||
|
||||
@@ -308,8 +308,7 @@ def _reload_attention_scales(layer: torch.nn.Module, info: LayerReloadingInfo) -
|
||||
|
||||
Assumes dtype/shapes of attention tensors do not change during
|
||||
processing, since we use .data.copy_() to preserve kernel tensor
|
||||
references.
|
||||
"""
|
||||
references."""
|
||||
quant_method = getattr(layer, "quant_method", None)
|
||||
if quant_method is not None:
|
||||
# Re-create scale Parameters with sentinel values so unloaded scales
|
||||
@@ -388,8 +387,7 @@ def _get_weight_loader(tensor: torch.Tensor):
|
||||
|
||||
def _copy_and_restore_kernel_tensors(layer: torch.nn.Module, info: LayerReloadingInfo):
|
||||
"""Copy processed values into original kernel tensor storage and restore
|
||||
kernel tensor references on the layer. Preserves cudagraph references.
|
||||
"""
|
||||
kernel tensor references on the layer. Preserves cudagraph references."""
|
||||
assert info.kernel_tensors is not None
|
||||
parameters, buffers = info.kernel_tensors
|
||||
non_persistent = info.kernel_non_persistent_buffers
|
||||
|
||||
@@ -81,8 +81,7 @@ class RunaiModelStreamerLoader(BaseModelLoader):
|
||||
) -> list[str]:
|
||||
"""Prepare weights for the model.
|
||||
|
||||
If the model is not local, it will be downloaded.
|
||||
"""
|
||||
If the model is not local, it will be downloaded."""
|
||||
is_object_storage_path = is_runai_obj_uri(model_name_or_path)
|
||||
is_local = os.path.isdir(model_name_or_path)
|
||||
safetensors_pattern = "*.safetensors"
|
||||
|
||||
@@ -497,8 +497,7 @@ def _check_tensors_on_meta_device(model: nn.Module) -> None:
|
||||
|
||||
def _resize_lora_embeddings(model: nn.Module):
|
||||
"""Modify LoRA embedding layers to use bigger tensors
|
||||
to allow for adapter added tokens.
|
||||
"""
|
||||
to allow for adapter added tokens."""
|
||||
for child in model.modules():
|
||||
if (
|
||||
isinstance(child, VocabParallelEmbedding)
|
||||
|
||||
@@ -105,8 +105,7 @@ class TensorizerLoader(BaseModelLoader):
|
||||
|
||||
Expects a vLLM-tensorized model. See the
|
||||
examples/features/tensorize_vllm_model.py example script
|
||||
for serializing vLLM models.
|
||||
"""
|
||||
for serializing vLLM models."""
|
||||
if is_vllm_tensorized(self.tensorizer_config):
|
||||
tensorizer_config = self._patch_tensorizer_config(model_config)
|
||||
deserialize_tensorizer_model(model, tensorizer_config)
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
|
||||
"""IPC model loader: maps post-quantized weights from a local weight cache
|
||||
daemon via CUDA IPC instead of loading from disk.
|
||||
"""
|
||||
daemon via CUDA IPC instead of loading from disk."""
|
||||
|
||||
import dataclasses
|
||||
import socket
|
||||
|
||||
@@ -78,8 +78,7 @@ def maybe_retie_word_embeddings(model: nn.Module, model_config: ModelConfig) ->
|
||||
|
||||
Checkpoints produced by quantization or fine-tuning tooling often keep a redundant
|
||||
copy of the tied `lm_head`. Sharing the storage again reclaims the memory it would
|
||||
otherwise cost.
|
||||
"""
|
||||
otherwise cost."""
|
||||
if not model_config.word_embeddings_untied_by_checkpoint:
|
||||
return
|
||||
if (untied := _get_untied_lm_head(model)) is None:
|
||||
|
||||
@@ -144,8 +144,7 @@ def atomic_writer(
|
||||
|
||||
def _natural_sort_key(filepath: str) -> list:
|
||||
"""Natural sort key for filenames with numeric components, such as
|
||||
model-00001-of-00005.safetensors -> ['model-', 1, '-of-', 5, '.safetensors']
|
||||
"""
|
||||
model-00001-of-00005.safetensors -> ['model-', 1, '-of-', 5, '.safetensors']"""
|
||||
return [
|
||||
int(s) if s.isdigit() else s
|
||||
for s in re.split(r"(\d+)", os.path.basename(filepath))
|
||||
@@ -162,8 +161,7 @@ def maybe_download_from_modelscope(
|
||||
"""Download model from ModelScope hub if VLLM_USE_MODELSCOPE is True.
|
||||
|
||||
Returns the path to the downloaded model, or None if the model is not
|
||||
downloaded from ModelScope.
|
||||
"""
|
||||
downloaded from ModelScope."""
|
||||
if envs.VLLM_USE_MODELSCOPE:
|
||||
# download model from ModelScope hub,
|
||||
# lazy import so that modelscope is not required for normal use.
|
||||
@@ -1148,8 +1146,7 @@ def instanttensor_weights_iterator(
|
||||
use_tqdm_on_load: bool,
|
||||
) -> Generator[tuple[str, torch.Tensor], None, None]:
|
||||
"""Iterate over the weights in the model safetensor files
|
||||
using instanttensor library.
|
||||
"""
|
||||
using instanttensor library."""
|
||||
try:
|
||||
import instanttensor
|
||||
except ImportError as e:
|
||||
|
||||
Reference in New Issue
Block a user