Pull Request已成功合入, 合并人@ascend-robot
(感谢 hellokitty911 的贡献)变更摘要
本次 PR 是一个回退(Revert)操作,撤销了之前为 _npu_paged_attention_splitfuse_v2 函数中 context_lens 输入添加 host 数据绑定的改动。回退后,context_lens 不再被显式拷贝到 CPU 并设置 hostData,恢复为原始的处理逻辑。
主要改动
- 移除
CONTEXT_LENS_INDEX常量定义: 删除了匿名命名空间中constexpr int64_t CONTEXT_LENS_INDEX = 4的声明,该常量此前用于索引context_lens在输入张量列表中的位置。 - 移除
context_lens的 CPU 拷贝与 host 数据绑定: 删除了context_lens.cpu()调用、paramsetter.variant_pack_.inTensors[CONTEXT_LENS_INDEX].hostData赋值,以及将 CPU 张量加入tensor_maintainer_.cpu_tensors的代码,即不再将context_lens强制同步到 host 端并绑定给 ATB 算子参数。


代码审查
我已经完整审查了 op_plugin/ops/atb/PagedAttentionSplitfuseV2.cpp 的 diff。下面是我的分析:
diff 变更内容
本次 PR 是一个 Revert,撤销了之前为 _npu_paged_attention_splitfuse_v2 的 context_lens 输入添加 host 数据绑定的提交。具体删除了:
- 匿名命名空间中
CONTEXT_LENS_INDEX = 4常量定义(第 21-23 行,旧) - 三行手动 CPU 迁移和
hostData绑定代码(第 72-74 行,旧)
审查分析
CONTEXT_LENS_INDEX引用检查:对整个代码库进行了符号搜索,确认该常量仅在已删除的三行代码中使用,没有其他引用,删除安全。- 与同类实现对比:
PagedAttentionSplitfuse.cpp(非 V2 版本)使用完全相同的.Input(context_lens, true)模式且无需显式 host 数据绑定,本次 revert 使 V2 版本与之对齐。 Input()方法行为:ParamSetter::Input()已根据 tensor 所在设备正确处理hostData/deviceData的设置,并通过tensor_maintainer_维持 tensor 生命周期。- 测试覆盖:两个测试函数 (
test_paged_attention_splitfuse_v2和test_paged_attention_splitfuse_v2_default_mask_type) 均传递context_lens为 NPU 设备 tensor,说明Input()的正常路径可以覆盖该场景。
结论
经过完整审查,此 diff 没有引入任何问题。Revert 干净、安全:删除的代码无残留引用,功能行为与同类非 V2 算子一致,不产生编译或运行时回归。
审查总结
| 文件 | 审查结果 |
|---|---|
op_plugin/ops/atb/PagedAttentionSplitfuseV2.cpp |
无问题 |
- P0 问题: 0
- P1 问题: 0
- P2 问题: 0
- P3 问题: 0
整体风险评估:低风险。这是一个干净的 revert,移除不再需要的显式 host 数据绑定代码,与现有代码库中同类实现保持一致。
⚠️ 已识别出整体风险,但无法提取行内评论,请参考整体评估。


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 |
|---|---|---|
| repo-Ascend/op-plugin | ✅ liangsongwei, li_jing_hw (2/2) | ✅ liangsongwei (1/1) |
💡 Tip:
- Committer can comment
/approveor/lgtm- Commenting
/approveimplies both code review (lgtm) and intent to merge (approve)
CLA Signature Pass
hellokitty911, thanks for your pull request. All authors of the commits have signed the CLA. 👍


Linking Issue Notice
@hellokitty911 , the pull request must be linked to at least one issue.
If an issue has already been linked, but the needs-issue label remains, you can remove the label by commenting /check-issue .


compile


ascend docs pipeline is running...


ascend docs pipeline is running...


✅ 跳过 docs ci 检查,没有需要检查的文档文件


✅ 跳过 docs ci 检查,没有需要检查的文档文件


| 阶段 | 任务名 | 状态 | 详情 |
|---|---|---|---|
| 编译构建 | Build_master_ARM | ✅ | >>> |
| Build_v2_7_1_ARM | ✅ | >>> | |
| Build_v2_9_0_ARM | ✅ | >>> | |
| Build_v2_10_0_ARM | ✅ | >>> | |
| Build_v2_11_0_ARM | ✅ | >>> | |
| Build_v2_12_0_ARM | ✅ | >>> | |
| Build_master_x86 | ✅ | >>> | |
| Build_v2_7_1_x86 | ✅ | >>> | |
| Build_v2_9_0_x86 | ✅ | >>> | |
| Build_v2_10_0_x86 | ✅ | >>> | |
| Build_v2_11_0_x86 | ✅ | >>> | |
| Build_v2_12_0_x86 | ✅ | >>> | |
| 恶意代码检查 | Antipoison | ✅ | >>> |
| 编码安全与规范检查 | CodeCheck | ✅ | >>> |
| CodeCheck_pre-commit | ✅ | >>> | |
| 开源片段检查 | SCA | ✅ | >>> |
| 开发者测试 | UT_master_ARM_01 | ✅ | >>> |
| UT_v2_7_1_ARM | ✅ | >>> | |
| UT_v2_9_0_ARM | ✅ | >>> | |
| UT_v2_10_0_ARM | ✅ | >>> | |
| UT_v2_11_0_ARM | ✅ | >>> | |
| UT_v2_12_0_ARM | ✅ | >>> | |
| 流水线 | PR-pipeline_op-plugin | ✅ | >>> |
- compile : 运行流水线
- retry : 重试流水线所有失败子任务
- retry <任务名> : 仅重试指定失败子任务
- stop : 停止流水线


/approve


/lgtm


【合入来源】
【修改方案】
回退_npu_paged_attention_splitfuse_v2的context_lens输入添加host数据绑定修改
【资料变更】
【接口变更】
【功能验证】
【CheckList】