vllm.distributed.eplb.policy
¶
Modules:
Classes:
-
AbstractEplbPolicy– -
DefaultEplbPolicy– -
EplbStats–Load and topology snapshot for one EPLB planning call.
AbstractEplbPolicy
¶
Bases: ABC
Methods:
-
rebalance_experts–Entry point for expert-parallelism load balancer.
rebalance_experts(stats, old_global_expert_indices=None)
abstractmethod
¶
Entry point for expert-parallelism load balancer.
Parameters:
-
(stats¶EplbStats) –Load/topology snapshot with a CPU load tensor. Built-in policies use
[layers, num_logical_experts]loads. Policy-specific subclasses may provide additional inputs. -
(old_global_expert_indices¶Tensor | None, default:None) –[layers, num_replicas], the old global expert indices. Used to avoid unnecessary weight copying for experts moving within one rank.
Returns:
-
physical_to_logical_map(Tensor) –[layers, num_replicas], the expert index of each replica, on CPU.
DefaultEplbPolicy
¶
Bases: AbstractEplbPolicy
Methods:
-
balanced_packing–Pack n weighted objects to m packs, such that each bin contains exactly
-
preserve_intragpu_slots–Reorder the new mapping per GPU so that experts that remain on the same GPU
-
rebalance_experts–Balance aggregate logical-expert loads and preserve local slots.
-
rebalance_experts_hierarchical–Parameters
-
replicate_experts–Replicate
num_logexperts tonum_phyreplicas, such that the maximum
balanced_packing(weight, num_packs)
classmethod
¶
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:
Returns:
preserve_intragpu_slots(phy2log, num_ranks, old_phy2log)
classmethod
¶
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 the old and new mappings.
rebalance_experts(stats, old_global_expert_indices=None)
¶
Balance aggregate logical-expert loads and preserve local slots.
rebalance_experts_hierarchical(weight, num_physical_experts, num_groups, num_nodes, num_gpus)
classmethod
¶
Parameters
weight: [num_moe_layers, num_logical_experts]
num_physical_experts: number of physical experts after replication
num_groups: number of expert groups
num_nodes: number of server nodes, where the intra-node network
(e.g, NVLink) is faster
num_gpus: number of GPUs, must be a multiple of num_nodes
Returns:
-
phy2log(ndarray) –[layers, num_replicas], the expert index of each replica
replicate_experts(weight, num_phy)
classmethod
¶
Replicate num_log experts to num_phy replicas, such that the maximum
load of all replicas is minimized.
Parameters:
Returns:
EplbStats
dataclass
¶
Load and topology snapshot for one EPLB planning call.
Policies may accept subclasses with additional planning inputs.
Attributes:
-
global_expert_load_window(Tensor) –Expert load window, converted to CPU before policy invocation.
-
num_gpus(int) –Number of GPUs.
-
num_groups(int) –Number of expert groups.
-
num_nodes(int) –Number of nodes.
-
num_replicas(int) –Number of physical experts.
global_expert_load_window
instance-attribute
¶
Expert load window, converted to CPU before policy invocation. Built-in policies use shape (num_moe_layers, num_logical_experts).
num_gpus
instance-attribute
¶
Number of GPUs.
num_groups
instance-attribute
¶
Number of expert groups.
num_nodes
instance-attribute
¶
Number of nodes.
num_replicas
instance-attribute
¶
Number of physical experts.