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 significant enhancements to the Flash Attention forward pass implementation, focusing on kernel definitions, architecture-specific optimizations, and memory layout improvements. The changes aim to improve code maintainability, support for dynamic masks, and performance across different GPU architectures.
Kernel and Architecture Enhancements:
flash_fwd_launch_template.h. This includes definingDEFINE_FLASH_FORWARD_KERNELfor cleaner kernel declarations andFLASH_UNSUPPORTED_ARCHfor centralized error messaging.Dynamic Mask Support:
Flash_fwd_kernel_traitsby splittingkDynamicMaskBufferPerQueryinto separate components (kMaskValuesSize,kNonZeroIndicesSize, etc.) for better modularity and clarity.SmemLayoutDynamicMaskValues,SmemLayoutNonZeroIndices, etc.) to support dynamic masks with improved memory organization.Performance Improvements:
flash_fwd_launch_template.h, ensuring efficient memory and thread usage based on GPU architecture and workload characteristics.