Skip to content

Conversation

@luanyundu
Copy link
Contributor

@luanyundu luanyundu commented Nov 13, 2025

Support topk -1 for low_latency on A3
Before we open the environment variable MOE_ENABLE_TOPK_NEG_ONE, the performance is
屏幕截图 2025-11-14 114219
After we open it, the performance is
屏幕截图 2025-11-14 114444
As the environment variable can cause large performance loss, we should only use it necessarily, for example, long cat model.

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @luanyundu, 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 significantly enhances the Mixture-of-Experts (MoE) low-latency dispatch and combine mechanisms on the A3 platform by introducing new operators capable of handling dropped tokens, represented by a topk_idx of -1. This feature allows for more flexible and robust MoE model configurations. The changes involve adding new kernel definitions, their corresponding tiling logic, and API interfaces, along with updates to the core dispatch/combine functions to integrate these new capabilities. The testing suite has also been updated to validate this new behavior.

Highlights

  • New MoE Operators for A3: Introduced MoeDistributeDispatchNegOne and MoeDistributeCombineNegOne operators to support topk -1 functionality in low-latency Mixture-of-Experts (MoE) operations on the A3 platform.
  • Conditional Execution via Environment Variable: The new NegOne operators are conditionally enabled in the low_latency_dispatch and low_latency_combine functions based on the MOE_ENABLE_TOPK_NEG_ONE environment variable, allowing for flexible testing and deployment.
  • Refactored Tiling Utilities: The Mc2TilingUtils class, responsible for retrieving HCCL buffer size, has been extracted into a dedicated header file (mc2_tiling_utils.h) for better code organization and reususability.
  • Enhanced Testing Framework: The test_low_latency.py script now includes a drop_percent argument and logic to simulate dropped tokens (by setting topk_idx to -1), ensuring comprehensive testing of the new functionality.
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 adds support for topk=-1 in low-latency mode on A3 hardware, which seems to be referred to as "long cat". The changes are extensive, introducing new operators (MoeDistributeDispatchNegOne, MoeDistributeCombineNegOne) with their corresponding definitions, kernel implementations, and tiling logic. Additionally, some utility code has been refactored into a shared header, and tests have been updated to cover the new functionality.

My review has identified several issues. There are a couple of high-severity bugs in csrc/deepep/deep_ep.cpp related to code duplication and the potential use of uninitialized variables, which could lead to incorrect behavior. I've also found a critical out-of-bounds memory access in an error-handling utility header (check_winsize.h) and a compilation-breaking typo in one of the new tiling files. Other findings include a typo in a test script and an unconventional use of a preprocessor directive. I've provided suggestions to address these points to improve code quality, correctness, and maintainability.

@Yael-X Yael-X merged commit 7fe4eeb into sgl-project:main Nov 26, 2025
4 checks passed
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.

2 participants