vllm.distributed.eplb.policy.default
¶
Expert parallelism load balancer (EPLB) for vLLM.
This module implements the core rearrangement algorithm.
The rearrangement algorithm is adapted from DeepSeek EPLB.
Please find at #12 an example on how the EPLB algorithm works.
Classes:
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: