Conversation
Summary of ChangesHello @kevssim, 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 implements support for a combined Expert Parallelism and Fully Sharded Data Parallel (EP+FSDP) strategy, specifically targeting Mixture-of-Experts (MoE) models. The changes enable more efficient distributed training by allowing experts to be sharded across a dedicated FSDP mesh while maintaining existing expert parallelism. This involves updates to expert sharding, integration into the FSDP wrapping mechanism, and improvements to gradient clipping for complex distributed tensor configurations. Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Changelog
Using Gemini Code AssistThe 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
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 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
|
There was a problem hiding this comment.
Code Review
This pull request introduces support for EP+FSDP, a combination of expert parallelism and fully sharded data parallelism. The changes are spread across model parallelism logic, strategy definitions, and utilities for device mesh and gradient clipping. The implementation provides a new method for sharding and executing experts under this combined parallelism scheme. My review highlights two main concerns: a potential dead code path in the expert execution logic which could lead to confusion, and a restrictive assumption in a device mesh utility function that might limit its use with more complex distributed configurations.
| def is_implicit_ep_fsdp_enabled(self) -> bool: | ||
| ep_world_size = self.ep_world_size or 1 | ||
| dp_world_size = self.dp_world_size or 1 | ||
| if ep_world_size <= 1 or dp_world_size <= 1: | ||
| return False | ||
|
|
||
| world_size = self.world_size or 1 | ||
| if world_size % ep_world_size != 0: | ||
| raise ValueError(f'world_size ({world_size}) must be divisible by ep_world_size ({ep_world_size}) ' | ||
| 'to infer implicit EP_FSDP from dp.') | ||
| expected_dp_size = world_size // ep_world_size | ||
| if dp_world_size != expected_dp_size: | ||
| raise ValueError(f'Implicit EP_FSDP requires dp_world_size == world_size // ep_world_size, ' | ||
| f'but got dp_world_size={dp_world_size}, world_size={world_size}, ' | ||
| f'ep_world_size={ep_world_size}.') | ||
| return True |
There was a problem hiding this comment.
The logic in is_implicit_ep_fsdp_enabled seems to assume that the device mesh consists only of dp and ep dimensions. The check dp_world_size != world_size // ep_world_size will likely fail for more complex meshes that also include other parallelism dimensions like tensor parallelism (tp) or pipeline parallelism (pp), as it would incorrectly require tp_size * pp_size == 1. This could be a potential limitation or bug. Please consider making the logic more robust to handle arbitrary mesh dimensions or clearly documenting this limitation.
PR type
PR information
support ep_fsdp.
Experiment results
Paste your experiment result here(if needed).