Skip to content

modify cookbook#63

Merged
meichangsu1 merged 11 commits intodevfrom
kernels_unittest_fix_ljl
Feb 13, 2026
Merged

modify cookbook#63
meichangsu1 merged 11 commits intodevfrom
kernels_unittest_fix_ljl

Conversation

@meichangsu1
Copy link
Copy Markdown
Collaborator

No description provided.

Replace calls to `_get_sp_group_from_device_mesh` with direct access to `sequence_parallel._sp_group` in sequence parallel attention tests. This simplifies the test setup by using the already initialized group stored in the module, improving code clarity and reducing redundancy.
Add additional imports and a try-except block to verify that the 'kernels-test/flattened-build' kernel can be successfully loaded in the current environment before proceeding with the test. This prevents test failures due to environment-specific loading issues and provides a more informative skip message.
- Add new entry for ep/sp FSDP MoE finetuning in README table
- Update ep_fsdp_qwen3_moe.py script to include ulysses_size parameter for enhanced parallelism configuration
@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello @meichangsu1, 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 distributed training cookbook by documenting and enabling sharded parallelism (sp) for FSDP MoE finetuning configurations. It updates the README.md to reflect this new capability and modifies the corresponding Python script to incorporate the necessary ulysses_size parameter for DeviceMesh initialization.

Highlights

  • Documentation Update: The README.md file has been updated to include a new entry for "ep/sp FSDP MoE finetuning" in the cookbook table, pointing to the existing ep_fsdp_qwen3_moe.py script.
  • Distributed Training Configuration: The ep_fsdp_qwen3_moe.py script was modified to introduce a ulysses_size variable and pass it to the DeviceMesh constructor, enabling sharded parallelism (sp) within the FSDP MoE finetuning setup.

🧠 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
  • README.md
    • Added a new row to the table for "ep/sp FSDP MoE finetuning".
  • cookbook/transformers/ep_fsdp_qwen3_moe.py
    • Declared ulysses_size = 2.
    • Passed ulysses_size as an argument to the DeviceMesh constructor.
    • Added a comment # enable sp next to the ulysses_size parameter.
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
Copy Markdown
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 updates the cookbook by adding an example for EP/SP FSDP MoE finetuning. The changes involve adding a new entry to the README.md table and modifying the corresponding script to enable sequence parallelism. My review includes a suggestion to fix the markdown table formatting and clarify the new entry to avoid confusion with an existing one. I've also recommended making the sequence parallelism size configurable via an environment variable in the example script for better flexibility.

| --------------------------------- | --------------- | ------------------------------------------------- |
| FSDP finetuning | transformers | [Script](cookbook/transformers/fsdp2.py) |
| FSDP MoE finetuning | transformers | [Script](cookbook/transformers/fsdp2_moe.py) |
| ep/sp FSDP MoE finetuning | transformers | [Script](cookbook/transformers/ep_fsdp_qwen3_moe.py) |
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

The markdown formatting for this line has incorrect padding, which misaligns the table. Please adjust the spacing to align with the other rows.

Additionally, this new entry makes the next line for EP MoE finetuning confusing, as both point to the same script. Since this script now has sequence parallelism enabled by default (ulysses_size = 2), the EP MoE finetuning entry is misleading. It would be clearer to update the existing line rather than adding a new one.

Suggested change
| ep/sp FSDP MoE finetuning | transformers | [Script](cookbook/transformers/ep_fsdp_qwen3_moe.py) |
| ep/sp FSDP MoE finetuning | transformers | [Script](cookbook/transformers/ep_fsdp_qwen3_moe.py) |

# 4 gpus, dp=2, ep=2
dp_size = 2
ep_size = 2
ulysses_size = 2
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

Hardcoding ulysses_size makes the script less flexible. It's better to make it configurable via an environment variable, similar to how NUM_LAYERS is handled in this file. This would allow users to easily enable or disable sequence parallelism without modifying the code.

Suggested change
ulysses_size = 2
ulysses_size = int(os.environ.get('ULYSSES_SIZE', 2))

@meichangsu1 meichangsu1 merged commit fc0db72 into dev Feb 13, 2026
3 of 4 checks passed
@tastelikefeet tastelikefeet deleted the kernels_unittest_fix_ljl branch February 13, 2026 09:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant