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
+15 -15
View File
@@ -1,7 +1,6 @@
# SPDX-License-Identifier: Apache-2.0
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
"""
Expert parallelism load balancer (EPLB) for vLLM.
"""Expert parallelism load balancer (EPLB) for vLLM.
This module implements the core rearrangement algorithm.
@@ -23,17 +22,17 @@ class DefaultEplbPolicy(AbstractEplbPolicy):
def balanced_packing(
cls, weight: np.ndarray, num_packs: int
) -> tuple[np.ndarray, np.ndarray]:
"""
Pack n weighted objects to m packs, such that each bin contains exactly
"""Pack n weighted objects to m packs, such that each bin contains exactly
n/m objects and the weights of all packs are as balanced as possible.
Parameters:
Args:
weight: [X, n], the weight of each item
num_packs: number of packs
Returns:
pack_index: [X, n], the pack index of each item
rank_in_pack: [X, n], the rank of the item in the pack
"""
num_layers, num_groups = weight.shape
assert num_groups % num_packs == 0
@@ -76,17 +75,17 @@ class DefaultEplbPolicy(AbstractEplbPolicy):
def replicate_experts(
cls, weight: np.ndarray, num_phy: int
) -> tuple[np.ndarray, np.ndarray]:
"""
Replicate `num_log` experts to `num_phy` replicas, such that the maximum
"""Replicate `num_log` experts to `num_phy` replicas, such that the maximum
load of all replicas is minimized.
Parameters:
Args:
weight: [X, num_log]
num_phy: total number of experts after replication
Returns:
phy2log: [X, num_phy], logical expert id of each physical expert
logcnt: [X, num_log], number of replicas for each logical expert
"""
n, num_log = weight.shape
num_redundant = num_phy - num_log
@@ -109,8 +108,7 @@ class DefaultEplbPolicy(AbstractEplbPolicy):
num_nodes: int,
num_gpus: int,
) -> np.ndarray:
"""
Parameters:
"""Parameters
weight: [num_moe_layers, num_logical_experts]
num_physical_experts: number of physical experts after replication
num_groups: number of expert groups
@@ -121,6 +119,7 @@ class DefaultEplbPolicy(AbstractEplbPolicy):
Returns:
phy2log: [layers, num_replicas], the expert
index of each replica
"""
num_layers, num_logical_experts = weight.shape
assert num_logical_experts % num_groups == 0
@@ -195,8 +194,7 @@ class DefaultEplbPolicy(AbstractEplbPolicy):
num_ranks: int,
old_phy2log: np.ndarray,
) -> np.ndarray:
"""
Reorder the new mapping per GPU so that experts that remain on the same GPU
"""Reorder the new mapping per GPU so that experts that remain on the same GPU
keep their previous slot positions when possible. Incoming experts to that GPU
fill any remaining available slots. This is applied only when the number of GPUs
is unchanged and the slots per GPU remain the same between
@@ -281,10 +279,9 @@ class DefaultEplbPolicy(AbstractEplbPolicy):
num_ranks: int,
old_global_expert_indices: torch.Tensor | None = None,
) -> torch.Tensor:
"""
Entry point for expert-parallelism load balancer.
"""Entry point for expert-parallelism load balancer.
Parameters:
Args:
weight: [layers, num_logical_experts], the load statistics for all
logical experts
num_replicas: number of physical experts, must be a multiple of
@@ -296,9 +293,12 @@ class DefaultEplbPolicy(AbstractEplbPolicy):
old_global_expert_indices: [layers, num_logical_experts], the old global
expert indices. Used to avoid unnecessary weight copying
for experts moving within one rank.
Returns:
-------
phy2log: [layers, num_replicas], the expert
index of each replica
"""
weight_np = weight.float().cpu().numpy()
old_phy2log_np = (