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 refines the handling of causal masks and predicates in the
compute_attn_1rowblockfunction within theflash_attention_fwd_kernel.hfile. The changes improve code clarity, maintainability, and correctness by introducing more descriptive comments, ensuring consistent handling of optional causal masks, and streamlining predicate allocation.Improvements to causal mask handling:
causal_mask_smem_ptrby reformatting the ternary operation for better readability. ([csrc/src/flash_attention_fwd_kernel.hL238-R240](https://github.com/flash-algo/flash-sparse-attention/pull/8/files#diff-f28f785166139b70460fd44ef7644554c0b332c25122b50ef571322572e86237L238-R240))cCausalMask) to use dummy 1×1 dimensions when no causal mask is provided, ensuring consistent tensor allocation. ([csrc/src/flash_attention_fwd_kernel.hL334-R356](https://github.com/flash-algo/flash-sparse-attention/pull/8/files#diff-f28f785166139b70460fd44ef7644554c0b332c25122b50ef571322572e86237L334-R356))Predicate allocation and comments:
cQ,cKV, andcZeroHold, improving code readability. ([csrc/src/flash_attention_fwd_kernel.hL334-R356](https://github.com/flash-algo/flash-sparse-attention/pull/8/files#diff-f28f785166139b70460fd44ef7644554c0b332c25122b50ef571322572e86237L334-R356))tCausalMaskpCausalMaskare always allocated, even when not used, to simplify the logic and avoid conditional tensor creation. ([csrc/src/flash_attention_fwd_kernel.hL334-R356](https://github.com/flash-algo/flash-sparse-attention/pull/8/files#diff-f28f785166139b70460fd44ef7644554c0b332c25122b50ef571322572e86237L334-R356))