已合并
Support block sparse attention grad TND GQA #4945
fgd_dragon创建于 5月14日
Support block sparse attention grad TND GQA #4945
已合并
Pull Request已成功合入, 合并人@ascend-robot
(感谢 fgd_dragon 的贡献)5月14日 创建了 pull request,commit df036ab3
ascend-robot
5月14日 评论:
5月14日 评论:
ascend-robot
5月14日 评论:
5月14日 评论:
Thanks for your pull-request.
The full list of commands accepted by me can be found at here。
You can get sig-info at here
PR Approval Progress
✅ Congratulations! All modules have met the lgtm and approve requirements.
Module Approval Details
| module | lgtm status | approve status |
|---|---|---|
| docs | ✅ htchu, lyx324521 (2/2) | ✅ htchu (1/1) |
| repo-Ascend/op-plugin | ✅ htchu, culechan (2/2) | ✅ htchu (1/1) |
💡 Tip:
- Committer can comment
/approveor/lgtm- Commenting
/approveimplies both code review (lgtm) and intent to merge (approve)
CLA Signature Pass
wang-ziqi-code, thanks for your pull request. All authors of the commits have signed the CLA. 👍


5月14日 添加了label:ascend-cla/yes
ascend-robot
5月14日 评论:
5月14日 评论:
Ascend docs pipeline is running...


此处折叠了93条消息 查看更多
5月26日 添加了label:approvedlgtm
ascend-robot
5月26日 评论:
5月26日 评论:
5月26日 关闭了关联的issue
5月26日 合入了pull request
【合入来源】
【修改方案】
适配
npu_block_sparse_attention_backwardTND 场景:BlockSparseAttentionBackwardKernelNpuOpApi.cpp中补充 TND 格式必要参数校验。q_input_layout == "TND"时,校验actual_seq_lengths必传且非空。kv_input_layout == "TND"时,校验actual_seq_lengths_kv必传且非空。适配并验证 TND/GQA 反向计算:
npu_block_sparse_attention(...).backward()路径,并与 CPU golden 对比。actual_seq_lengths/actual_seq_lengths_kv的本地校验负例。更新文档及文档生成模板:
npu_block_sparse_attention文档中的反向能力描述。BNSD/TND同 layout 场景,并支持 MHA/GQA。actual_seq_lengths与actual_seq_lengths_kv配置约束。_op_plugin_docs.py,避免后续文档生成覆盖手工修改。【资料变更】
涉及资料变更。
修改文件:
docs/zh/custom_APIs/torch_npu/torch_npu-npu_block_sparse_attention.mdcodegen/templates/_op_plugin_docs.py主要内容:
BNSD/TND、MHA/GQA、headDim、actual_seq_lengths/actual_seq_lengths_kv的约束说明。【接口变更】
不涉及 public API schema 变更。
说明:
op_plugin_functions.yaml。npu_block_sparse_attention_backward对外公开文档。【功能验证】
新增/适配 UT:
test_npu_block_sparse_attention_backward_tnd_gqa_full_mask_cpu_comparetest_npu_block_sparse_attention_backward_tnd_gqa_sparse_mask_cpu_comparetest_npu_block_sparse_attention_backward_tnd_gqa_single_batch_cpu_comparetest_npu_block_sparse_attention_backward_tnd_gqa_uneven_seq_lengths_cpu_comparetest_npu_block_sparse_attention_backward_tnd_gqa_group_size_4_cpu_comparetest_npu_block_sparse_attention_backward_tnd_mqa_cpu_comparetest_npu_block_sparse_attention_backward_tnd_gqa_non_128_tail_block_cpu_comparetest_npu_block_sparse_attention_backward_tnd_actual_seq_lengths_requiredtest_npu_block_sparse_attention_backward_tnd_gqa_autograd_cpu_compare验证方式:
python test/test_custom_ops/test_npu_block_sparse_attention_backward.py。dq/dk/dv与 CPU golden。query.grad/key.grad/value.grad与 CPU golden。TORCH_CHECK报错。【CheckList】