Skip to content

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(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:

  • weight

    (ndarray) –

    [X, n], the weight of each item

  • num_packs

    (int) –

    number of packs

Returns:

  • pack_index ( ndarray ) –

    [X, n], the pack index of each item

  • rank_in_pack ( ndarray ) –

    [X, n], the rank of the item in the pack

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:

  • weight

    (ndarray) –

    [X, num_log]

  • num_phy

    (int) –

    total number of experts after replication

Returns:

  • phy2log ( ndarray ) –

    [X, num_phy], logical expert id of each physical expert

  • logcnt ( ndarray ) –

    [X, num_log], number of replicas for each logical expert