已合并
[sync] PR-40262: bugfix for profiler FLOPs when actual seq len can be zero #40379
ascend-robot创建于 7月7日
[sync] PR-40262: bugfix for profiler FLOPs when actual seq len can be zero #40379
已合并
Pull Request已成功合入, 合并人@ascend-robot
(感谢 ascend-robot 的贡献)7月7日 创建了 pull request,commit 8303ff38
7月7日 关联了issue:[Bug]: profiling计算attention算子FLOPs时需要考虑实际序列长度可能为0,head_num不一致的情况
atomgit-bot
7月7日 评论:
7月7日 评论:
变更摘要
此PR修复了profiler FLOPs计算中一个边界条件判断问题:在 _calculate_tnd_layout_flops 函数中,原先对 actual_seq_qlen / actual_seq_kvlen 的校验将长度为0的情况也视为非法输入并抛出异常,但实际上序列长度可以合法地为零。修复后将校验条件从 <= 0 放宽为 < 0,仅拒绝负数长度,允许零长度通过,从而避免在实际段落长度为零时错误抛出异常。
主要改动
- 放宽序列长度校验条件:在
torch_npu/profiler/_flops_formulas.py的_calculate_tnd_layout_flops函数中,将any(length <= 0 for length in q_lens + kv_lens)改为any(length < 0 for length in q_lens + kv_lens),使零长度序列不再被拒绝,仅真正无效的负数长度触发ValueError。


ascend-robot
7月7日 评论:
7月7日 评论:
atomgit-bot
7月7日 评论:
7月7日 评论:
7月7日 添加了label:ascend-cla/yes
ascend-robot
7月7日 评论:
7月7日 评论:
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 |
|---|---|---|
| torch_npu/profiler | ✅ 陈豪, 王朝 (2/2) | ✅ 王朝, 陈豪 (2/1) |
💡 Tip:
- Committer can comment
/approveor/lgtm- Commenting
/approveimplies both code review (lgtm) and intent to merge (approve)
CLA Signature Pass
ascend-ds-bot, thanks for your pull request. All authors of the commits have signed the CLA. 👍


7月7日 添加了label:ci-pipeline-running
ascend-robot
7月7日 评论:
7月7日 评论:
ascend docs pipeline is running...


7月7日 添加了label:docs-ci-pipeline-running
ascend-robot
7月7日 评论:
7月7日 评论:
✅ 跳过 docs ci 检查,没有需要检查的文档文件


7月7日 删除了label:docs-ci-pipeline-running
7月7日 添加了label:docs-ci-pipeline-success
7月7日 删除了label:ci-pipeline-running
7月7日 添加了label:ci-pipeline-passed
ascend-robot
7月7日 评论:
7月7日 评论:
流水线 PR-pipeline_pytorch#42092 [ commitID:23a4b8aa ] 已完成
>>>代码风格自动修复执行成功(无修复内容)
| 阶段 | 任务名 | 状态 | 详情 |
|---|---|---|---|
| 编译构建 | Build_X86 | ✅ | >>> |
| Build_ARM | ✅ | >>> | |
| Build_LibTorch_x86 | ✅ | >>> | |
| Build_LibTorch_ARM | ✅ | >>> | |
| Build_X86_torchair | 🛑 | >>> | |
| Build_ARM_torchair | 🛑 | >>> | |
| patch_test | 🛑 | >>> | |
| 恶意代码检查 | Antipoison | ✅ | >>> |
| 编码安全与规范检查 | CodeCheck | ✅ | >>> |
| check_error | ✅ | >>> | |
| CodeCheck_lintrunner | ✅ | >>> | |
| 开源片段检查 | SCA | ✅ | >>> |
| 开发者测试 | UT_X86_Part_01 | 🛑 | >>> |
| UT_X86_Part_02 | 🛑 | >>> | |
| UT_ARM_A3_Part_01 | 🛑 | >>> | |
| UT_ARM_A3_Part_02 | 🛑 | >>> | |
| UT_ARM_A2_Part_01 | ✅ | >>> | |
| UT_ARM_A2_Part_02 | ✅ | >>> | |
| UT_ARM_A2_Part_03 | ✅ | >>> | |
| UT_inductor_Part_01 | 🛑 | >>> | |
| UT_inductor_Part_02 | 🛑 | >>> | |
| UT_inductor_Part_03 | 🛑 | >>> | |
| UT_inductor_Part_04 | 🛑 | >>> | |
| UT_DIST_ARM_Part_01 | 🛑 | >>> | |
| UT_DIST_ARM_Part_02 | 🛑 | >>> | |
| UT_DIST_ARM_Part_03 | 🛑 | >>> | |
| UT_DIST_ARM_Part_04 | 🛑 | >>> | |
| UT_ARM_A2_Select_Part_01 | ✅ | >>> | |
| UT_ARM_A2_Select_Part_02 | ✅ | >>> | |
| 流水线 | PR-pipeline_pytorch | ✅ | >>> |
- compile、compile_inductor、compile_torchair : 运行流水线
- retry : 重试流水线所有失败子任务
- retry <任务名> : 仅重试指定失败子任务
- stop : 停止流水线


chenhao_1209
7月8日 评论:
7月8日 评论:
/approve


7月8日 添加了label:approved
wangchao285
7月8日 评论:
7月8日 评论:
/approve


7月8日 添加了label:lgtm
7月8日 合入了pull request
1. Origin pull request:
https://gitcode.com/Ascend/pytorch/merge_requests/40262
2. Original pull request related issue(s):
https://gitcode.com/Ascend/pytorch/issues/2608
3. Original pull request related commit(s):