[Refactor] Enhance MHA kernel with support for different architectures and data types #41
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.
This pull request introduces several improvements to the test configuration and code organization for multi-head attention (MHA) kernels, as well as a new utility function for device architecture detection. The main changes include adding support for configurable data types in the MHA tests, refactoring imports for better modularity, and introducing an
is_hopperutility function.Test configuration improvements
--dtypeargument to the MHA test script (tests/test_mha.py), allowing selection betweenfloat16andbfloat16data types, and updated the test function to use this argument. Also adjusted defaults for--causaland--tunearguments to improve usability. [1] [2]--tuneargument in the MHA decode test script (tests/test_mha_decode.py) toFalsefor consistency with other test scripts.Code organization
top/__init__.pyandtop/kernel/__init__.pyto importMHADecodeKernelfrom its own module (mha_decode) instead ofmha, improving modularity and maintainability. [1] [2]__all__declaration totop/kernel/mla.pyto explicitly define the public API of the module.New utility function
is_hopperfunction intop/utils/utils.pyto detect if the current CUDA device is of the Hopper architecture (compute capability 9.0).