Skip to content

EPLB: prefer to use physical experts in the same gpu or node#10874

Merged
zhyncs merged 6 commits intosgl-project:mainfrom
acelyc111:prefer_local_expert_in_dynamic_dispatch
Oct 29, 2025
Merged

EPLB: prefer to use physical experts in the same gpu or node#10874
zhyncs merged 6 commits intosgl-project:mainfrom
acelyc111:prefer_local_expert_in_dynamic_dispatch

Conversation

@acelyc111
Copy link
Collaborator

@acelyc111 acelyc111 commented Sep 24, 2025

Motivation

Similar to #9849, when it's possible to use physical experts on the same node, we'd prefer to route to these GPU ranks in dynamic mode.

Modifications

When setting --ep-dispatch-algorithm dynamic, select the experts on the same GPU at first if possible, then select experts on the same node if possible, at last, select the experts randomly as a fall back method.

Accuracy Tests

Benchmarking and Profiling

Checklist

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @acelyc111, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request enhances the Expert Parallel Load Balancing (EPLB) mechanism by introducing a preference for assigning physical experts to the same GPU or compute node as the requesting process. This optimization aims to reduce communication overhead and improve performance by keeping expert computations local whenever possible. The changes involve modifying expert mapping functions to consider GPU and node IDs and refactoring the expert assignment logic for better modularity.

Highlights

  • Expert Locality Preference: Implemented logic to prioritize the selection of physical experts located on the same GPU or compute node during Expert Parallel Load Balancing (EPLB) initialization, aiming to reduce communication overhead.
  • Refactored Expert Assignment Logic: Introduced a new helper function _find_nearest_expert to centralize the logic for determining the closest physical expert based on GPU and node affinity, improving code clarity and reusability.
  • GPU Context Integration: The current GPU's ID is now passed down to the expert location initialization functions, enabling the system to make informed decisions about expert placement based on local hardware resources.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a mechanism to prefer physically local experts (same GPU, then same node) to reduce communication overhead. This is achieved by refactoring the expert selection logic into a _find_nearest_expert function and using it to optimize the expert mapping for each GPU rank. While the refactoring is a good improvement, I have a couple of concerns. First, the new logic forces the use of a single nearest expert rather than just preferring it, which could lead to performance bottlenecks by eliminating load balancing opportunities. Second, this new optimization is not applied consistently for all initialization paths, specifically for the 'trivial' expert location case. My review includes suggestions to address these points.

@acelyc111 acelyc111 force-pushed the prefer_local_expert_in_dynamic_dispatch branch from 9c9e453 to 05f8ca4 Compare October 19, 2025 10:13
Copy link
Collaborator

@fzyzcjy fzyzcjy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM only nits

@acelyc111 acelyc111 force-pushed the prefer_local_expert_in_dynamic_dispatch branch from 05f8ca4 to 3cfe192 Compare October 28, 2025 15:59
@acelyc111 acelyc111 force-pushed the prefer_local_expert_in_dynamic_dispatch branch from aa19935 to 56c9455 Compare October 29, 2025 02:09
@zhyncs zhyncs merged commit ec92b0c into sgl-project:main Oct 29, 2025
46 of 68 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants