Skip to content

Add rrattn estimate func and interface#117

Open
LLSGYN wants to merge 1 commit intoPaddlePaddle:mainfrom
LLSGYN:feat/rr_attn
Open

Add rrattn estimate func and interface#117
LLSGYN wants to merge 1 commit intoPaddlePaddle:mainfrom
LLSGYN:feat/rr_attn

Conversation

@LLSGYN
Copy link
Copy Markdown

@LLSGYN LLSGYN commented Mar 13, 2026

Summary

This PR adds a new Python-only utility package under flashmask/flash_mask/utils for RRAttention support on top of existing Paddle FlashMask ops.

Added files

  • flashmask/flash_mask/utils/__init__.py
  • flashmask/flash_mask/utils/rr_attn_interface.py
  • flashmask/flash_mask/utils/rr_attn_estimate_triton_op.py
  • flashmask/flash_mask/utils/block_mask_utils.py
  • flashmask/flash_mask/utils/index_utils.py

What’s included

  • A high-level RR attention interface (rr_attention) that calls paddle.nn.functional.flashmask_attention.
  • Triton-based sparse/block mask estimation utilities.
  • Block-mask helper functions.
  • Index max/min preparation utilities used by the mask estimation path.

)


# if __name__ == '__main__':
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这些注释要去掉

keep_sink: bool = True,
keep_last: bool = True,
return_softmax_lse: bool = False,
return_seed_offset: bool = False,
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dropout, training, return_seed_offset这几个参数对rr_attention来说有必要加上吗?

prepare_maxmin,
)

LOG2E = 1.4426950408889634 # 1 / ln(2)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这能不能用一个symbol代替,不要hardcode


import paddle

# paddle.compat.enable_torch_proxy()
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个开关现在是不需要了吗

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants