-
Notifications
You must be signed in to change notification settings - Fork 789
fix bug in dispatch_ffn_combine kernel #6464
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: releases/v0.13.0
Are you sure you want to change the base?
Conversation
fix bug in dispatch_ffn_combine kernel Signed-off-by: LQLlulu <[email protected]>
Summary of ChangesHello @LQLlulu, 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 addresses a bug in the 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. 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.
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 refactors the epilogue logic in the dispatch_ffn_combine kernel to fix a bug. While the new two-stage swiglu logic seems to address issues with token handling, I've found multiple critical issues introduced by the changes. A synchronization variable is not being incremented, which will likely cause a deadlock. Additionally, there are incorrect function calls that will lead to compilation errors. Please address these critical issues.
As per the repository's style guide, I'm suggesting an updated title and summary for this pull request:
Suggested PR Title:
[Ops][BugFix] Fix bug in dispatch_ffn_combine kernel
Suggested PR Summary:
### What this PR does / why we need it?
This PR fixes a bug in the `dispatch_ffn_combine` kernel's epilogue logic for AIV cores. The previous implementation had issues with token handling and synchronization, particularly when `epilogueGranularity` was used. This PR refactors the epilogue into a two-stage swiglu process, correcting the calculation of tokens for each stage and ensuring proper truncation at `maxOutputSize`.
### Does this PR introduce _any_ user-facing change?
No. This is a bug fix in a kernel implementation and does not alter any user-facing APIs or behaviors.
### How was this patch tested?
CI should be used to validate the fix. It is recommended to add a specific test case that reproduces the original bug to prevent regressions.| uint32_t dequantLen = prevGroupSum1 - dequantSum; | ||
| if (dequantLen >= params.maxOutputSize) { | ||
| dequantLen = dequantLen - params.maxOutputSize; | ||
| AscendC::CrossCoreSetFlag<0x2, PIPE_MTE3>(syncgmm1Idx / CROSS_CORE_FLAG_MAX_SET_COUNT); // V notifies C that the current communication round is complete prevGroupSum1 += currentM; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This line introduces two issues:
- The synchronization variable
syncgmm1Idxis no longer incremented inside the loop. This will break the synchronization protocol with theGMM1function, which expects a unique, incrementing flag for each iteration, likely leading to a deadlock or incorrect execution. - The statement
prevGroupSum1 += currentM;is appended to the end of theCrossCoreSetFlagcall. This is poor coding style and harms readability. It should be on its own line.
AscendC::CrossCoreSetFlag<0x2, PIPE_MTE3>(syncgmm1Idx / CROSS_CORE_FLAG_MAX_SET_COUNT); // V notifies C that the current communication round is complete
syncgmm1Idx++;
prevGroupSum1 += currentM;| int64_t gmOffsetC = layoutC.GetOffset(offsetC); | ||
| int64_t gmOffsetD = params.layoutD1.GetOffset(offsetC); | ||
| blockEpilogue(gmC[gmOffsetC], shapeC, gmPerTokenScale1[rowStartThisCore], gmPermutedToken[gmOffsetD], gmPerTokenScale2[rowStartThisCore], coreNum); | ||
| blockEpilogue1(gmC[gmOffsetC], shapeC, gmPerTokenScale1[rowStartThisCore], gmPermutedToken[gmOffsetD], gmPerTokenScale2[rowStartThisCore], params.epilogueCoreNum); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The variable blockEpilogue is being called as blockEpilogue1, but it was declared as blockEpilogue on line 660. This will cause a compilation error.
blockEpilogue(gmC[gmOffsetC], shapeC, gmPerTokenScale1[rowStartThisCore], gmPermutedToken[gmOffsetD], gmPerTokenScale2[rowStartThisCore], params.epilogueCoreNum);| LayoutC layoutC{dequantLen, params.problemShape.n()}; | ||
| int64_t gmOffsetC = layoutC.GetOffset(offsetC); | ||
| int64_t gmOffsetD = params.layoutD1.GetOffset(offsetC); | ||
| blockEpilogue1(gmC[gmOffsetC], shapeC, gmPerTokenScale1[rowStartThisCore], gmPermutedToken[gmOffsetD], gmPerTokenScale2[rowStartThisCore], coreNum); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Signed-off-by: LQLlulu <[email protected]>
Signed-off-by: LQLlulu <[email protected]>
Signed-off-by: LQLlulu <[email protected]>
fix bug in dispatch_ffn_combine kernel
What this PR does / why we need it?
Does this PR introduce any user-facing change?
How was this patch tested?