Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
QQ: Will these changes launch the type conversion kernel?
Uh 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.
Yes. The current version is a quick and minimal correctness fix, and it may launch CUDA type conversion kernels when the dtypes do not match. If we want to avoid that entirely, the more complete solution would be to change the CUDA op / kernel contract so that
topk_indicesand the hash routing metadata (input_ids/tid2eid) do not have to use the same dtype. That should avoid the conversion kernels, but it is a larger kernel/dispatch change.Without changing the CUDA kernel, a better way would be to move the dtype alignment upstream, so the static
hash_indices_tableis aligned once when the MoE backend determines the requiredtopk_indices_dtype, instead of casting it before every custom op call.Which way do you think is better? I can work on either direction next to fix this bug. @jeejeelee
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.
Sorry for missing this PR. It looks like #41183 has fixed this bug
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.
Oh, I see. Thanks anyway!