-
-
Notifications
You must be signed in to change notification settings - Fork 20.2k
[ROCM] Optmize redudent d2d copy of moe. #38597
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -437,4 +437,4 @@ def apply( | |
| num_local_tokens=num_local_tokens, | ||
| output_dtype=output.dtype, | ||
| ) | ||
| output.copy_(result) | ||
| output.data = result | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Using
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Aiter will use |
||
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.
Reassigning
output = fused_outis highly dangerous becausefused_outis a view into the transient workspace memory (allocated viacurrent_workspace_manager). Returning this tensor means the MoE layer's output can be silently overwritten by any subsequent operation that requests workspace buffers, leading to data corruption or non-deterministic results. The copy from the workspace buffer to the persistentoutputtensor (allocated at line 1350) is mandatory to ensure the result persists correctly throughout the model's execution.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.
Reusing
fused_outforoutputis dangerous beyond the fact that it might point to the temporary buffers. Doing this basically forces all thefinalizemethods to operate inplace which may or may not be supported.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.
Added
platform.is_rocm(), only effect in rocm'sfinalizeUh oh!
There was an error while loading. Please reload this page.
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.
I think this check should be
rocm_aiter_ops.is_fused_moe_enabled(). For other MOE backends, ROCm devices that don't support AITER, AITER fused_moe explicitly disabled, etc. we still want to keep the default behavior.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.
Yeah thanks. Should work only when AITER enabled.