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
@@ -193,8 +193,7 @@ class Base(
|
||||
)
|
||||
|
||||
def _patch_config(self):
|
||||
"""
|
||||
Patch the config to ensure that the model is created correctly:
|
||||
"""Patch the config to ensure that the model is created correctly:
|
||||
|
||||
- Sets the attention implementation to "vllm" so the attention instances from
|
||||
`_create_attention_instances` are used
|
||||
@@ -208,7 +207,8 @@ class Base(
|
||||
def _mark_model_components(self, vllm_config: "VllmConfig"):
|
||||
"""Mark language model and tower submodules as `self.model` is created.
|
||||
|
||||
Nothing to do in `Base`, `MultiModalMixin` will override."""
|
||||
Nothing to do in `Base`, `MultiModalMixin` will override.
|
||||
"""
|
||||
yield
|
||||
|
||||
@cached_property
|
||||
@@ -253,8 +253,7 @@ class Base(
|
||||
enable_if: Callable[["VllmConfig"], bool],
|
||||
is_encoder: bool,
|
||||
):
|
||||
"""
|
||||
Decorate `cls` to indicate to vLLM that it supports torch compile.
|
||||
"""Decorate `cls` to indicate to vLLM that it supports torch compile.
|
||||
|
||||
Args:
|
||||
cls: The PreTrainedModel class to decorate.
|
||||
@@ -265,6 +264,7 @@ class Base(
|
||||
enable_if: A function which takes in the vLLM config and returns whether
|
||||
torch compile should be enabled for this class.
|
||||
is_encoder: Whether the class being decorated is an encoder.
|
||||
|
||||
"""
|
||||
logger.debug(
|
||||
"Decorating `%s` as %s for torch compile with dynamic_arg_dims of %s",
|
||||
@@ -281,7 +281,8 @@ class Base(
|
||||
|
||||
def _decorate_for_torch_compile(self):
|
||||
"""Decorate the model's decoder class to indicate to vLLM that it
|
||||
supports torch compile if `can_enable_torch_compile` is True."""
|
||||
supports torch compile if `can_enable_torch_compile` is True.
|
||||
"""
|
||||
self._decorate_cls_for_torch_compile(
|
||||
cls=self._pre_trained_model_classes.decoder,
|
||||
# Applied to a PreTrainedModel so the batch dimension will exist
|
||||
@@ -295,8 +296,7 @@ class Base(
|
||||
)
|
||||
|
||||
def _create_hf_to_vllm_mapper(self):
|
||||
"""
|
||||
Create a WeightsMapper to map checkpoint weight names to module qualnames.
|
||||
"""Create a WeightsMapper to map checkpoint weight names to module qualnames.
|
||||
|
||||
This handles:
|
||||
|
||||
@@ -347,18 +347,14 @@ class Base(
|
||||
self._maybe_apply_model_mapping()
|
||||
|
||||
def _get_tie_word_embeddings(self):
|
||||
"""
|
||||
Check if the model has tied word embeddings.
|
||||
"""
|
||||
"""Check if the model has tied word embeddings."""
|
||||
# Models created with Transformers v4 and v5 will store this in different places
|
||||
tie_word_embeddings_v4 = getattr(self.text_config, "tie_word_embeddings", False)
|
||||
tie_word_embeddings_v5 = getattr(self.config, "tie_word_embeddings", False)
|
||||
return tie_word_embeddings_v4 or tie_word_embeddings_v5
|
||||
|
||||
def pipeline_parallel(self):
|
||||
"""
|
||||
Apply the model's pipeline parallelization plan.
|
||||
"""
|
||||
"""Apply the model's pipeline parallelization plan."""
|
||||
if self.pp_group.world_size <= 1:
|
||||
return
|
||||
|
||||
@@ -697,8 +693,7 @@ class Base(
|
||||
return Attention
|
||||
|
||||
def init_parameters(self, module: nn.Module, dtype: torch.dtype | None = None):
|
||||
"""
|
||||
If a `parameter` is on the `meta` device, then its parent
|
||||
"""If a `parameter` is on the `meta` device, then its parent
|
||||
`module` is the original module created by:
|
||||
|
||||
```python
|
||||
|
||||
Reference in New Issue
Block a user