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:
Harry Mellor
2026-09-16 16:44:29 +00:00
committed by GitHub
co-authored by Claude Opus 5
parent 804e5377aa
commit 8c1557a79c
2002 changed files with 15024 additions and 14269 deletions
+7 -24
View File
@@ -248,7 +248,6 @@ class FusedMoEWithLoRA(BaseLayerWithLoRA):
model_config: PretrainedConfig | None = None,
) -> None:
"""Initializes lora matrices."""
self._verify_ep_fs(lora_config)
self.max_loras = lora_config.max_loras
self.fully_sharded = lora_config.fully_sharded_loras
@@ -294,9 +293,7 @@ class FusedMoEWithLoRA(BaseLayerWithLoRA):
)
def _slice_w13_a(self, w13_lora_a: torch.Tensor) -> torch.Tensor:
"""
Applies to FusedMoEWithLoRA and FusedMoE3DWithLoRA
"""
"""Applies to FusedMoEWithLoRA and FusedMoE3DWithLoRA."""
if self.tp_size == 1 or not self.fully_sharded:
return w13_lora_a
@@ -321,9 +318,7 @@ class FusedMoEWithLoRA(BaseLayerWithLoRA):
return w13_lora_b[:, start_idx:end_idx, :]
def _slice_w2_a(self, w2_lora_a: torch.Tensor) -> torch.Tensor:
"""
Applies to FusedMoEWithLoRA and FusedMoE3DWithLoRA
"""
"""Applies to FusedMoEWithLoRA and FusedMoE3DWithLoRA."""
if self.tp_size == 1:
return w2_lora_a
# w2_lora_a shape (num_experts,rank,input_size)
@@ -334,9 +329,7 @@ class FusedMoEWithLoRA(BaseLayerWithLoRA):
return w2_lora_a[:, :, start_idx:end_idx]
def _slice_w2_b(self, w2_lora_b: torch.Tensor) -> torch.Tensor:
"""
Applies to FusedMoEWithLoRA and FusedMoE3DWithLoRA
"""
"""Applies to FusedMoEWithLoRA and FusedMoE3DWithLoRA."""
if self.tp_size == 1 or not self.fully_sharded:
return w2_lora_b
# Based on S-LoRA, we slice W2 B along the hidden_size dim.
@@ -475,7 +468,6 @@ class FusedMoEWithLoRA(BaseLayerWithLoRA):
model_config: PretrainedConfig | None = None,
) -> bool:
"""Returns True if the layer can be replaced by this LoRA layer."""
# source_layer is MoERunner
moe_cls = maybe_get_oot_by_class(MoERunner)
return isinstance(source_layer, moe_cls) and len(packed_modules_list) == 2
@@ -522,7 +514,6 @@ class FusedMoE3DWithLoRA(FusedMoEWithLoRA):
model_config: PretrainedConfig | None = None,
) -> None:
"""Initializes lora matrices."""
if model_config is None:
raise ValueError("model_config must be provided for MoE LoRA.")
architectures = model_config.architectures
@@ -609,30 +600,22 @@ class FusedMoE3DWithLoRA(FusedMoEWithLoRA):
@property
def w13_input_size(self):
"""
Full size
"""
"""Full size."""
return self.w13_lora_a_stacked[0].shape[-1]
@property
def w13_output_size(self):
"""
Full size
"""
"""Full size."""
return self.w13_lora_b_stacked[0].shape[-2] * self.tp_size
@property
def w2_input_size(self):
"""
Full size
"""
"""Full size."""
return self.w2_lora_a_stacked[0].shape[-1] * self.tp_size
@property
def w2_output_size(self):
"""
Full size
"""
"""Full size."""
return self.hidden_size
@classmethod