Skip to content

Conversation

@ifromeast
Copy link

@ifromeast ifromeast commented Mar 10, 2025

This PR is to integrate EPLB into vllm, not just map experts according to ranks.
we can get prior expert map as following:

  1. Select a dataset to the model for inference, and count the frequency of all layers and all experts being selected, and get weight of shape [layers, experts].
  2. use EPLB to got the global optimal expert map according to weight and GPUs, and get prior expert map of shape [layers, ranks, experts] by
phy2log, log2phy, logcnt = eplb.rebalance_experts(weight_matrix, num_replicas, num_groups, num_nodes, num_gpus)
phy2log = phy2log.view(layers, num_gpus, -1)  # [layers, gpu_ranks, expert_per_gpu]
e_maps = torch.full((layers, num_gpus, num_replicas), -1, dtype=torch.int32)
for l in range(layers):
    for r in range(num_gpus):
        e_ids = phy2log[l,r]
        e_maps[l, r, e_ids] = torch.arange(num_replicas // num_gpus, dtype=torch.int32)
torch.save(e_maps, 'expert_map.pth')
  1. using the prior expert map to load MoE model by
vllm serve deepseek-ai/DeepSeek-V2-Lite-Chat -tp 8 --enable-expert-parallel --trust-remote-code --expert-map-path /path/to/expert_map.pth

@github-actions
Copy link

👋 Hi! Thank you for contributing to the vLLM project.

💬 Join our developer Slack at https://slack.vllm.ai to discuss your PR in #pr-reviews, coordinate on features in #feat- channels, or join special interest groups in #sig- channels.

Just a reminder: PRs would not trigger full CI run by default. Instead, it would only run fastcheck CI which starts running only a small and essential subset of CI tests to quickly catch errors. You can run other CI tests on top of those by going to your fastcheck build on Buildkite UI (linked in the PR checks section) and unblock them. If you do not have permission to unblock, ping simon-mo or khluu to add you in our Buildkite org.

Once the PR is approved and ready to go, your PR reviewer(s) can run CI to test the changes comprehensively before merging.

To run CI, PR reviewers can either: Add ready label to the PR or enable auto-merge.

🚀

Signed-off-by: ifromeast <[email protected]>
Signed-off-by: ifromeast <[email protected]>
Signed-off-by: ifromeast <[email protected]>
Signed-off-by: ifromeast <[email protected]>
Signed-off-by: ifromeast <[email protected]>
Signed-off-by: ifromeast <[email protected]>
code format

Signed-off-by: ifromeast <[email protected]>
Signed-off-by: ifromeast <[email protected]>
Signed-off-by: ifromeast <[email protected]>
@liweiqing1997
Copy link

Why did this job stop? Will it be restarted?

@abmfy
Copy link
Member

abmfy commented May 19, 2025

Hi @liweiqing1997, I’m currently working on EPLB, please take a look at #18343

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci/build documentation Improvements or additions to documentation v1

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants