Closed
[Bug-Report|缺陷反馈]: kv_rms_norm_rope_cache 只从 k_cache 取 blockSize,然后同时用于 k_cache 和 v_cache 的 scatter 偏移计算。需要加校验 #5558
王沁怡Add on  Sep 21Closed at  Sep 24
王沁怡
王沁怡
Sep 21 Create

Thanks for sending an issue! Please fill in the following template to help quickly solve your problem.

Describe the current behavior / 问题描述 (Mandatory / 必填)

npugraph_ex单流,模型内包含多原地算子覆盖手动Functionalize和自动Functionalize,算子修改的输入为中间节点场景,精度失败

Environment Information / 环境信息 (Mandatory / 必填)

Ascend910C
9.2.0
python3.9.5

Steps to reproduce the issue / 重现步骤 (Mandatory / 必填)

import os
import sys
import numpy as np
import torch
import torch_npu

torch_npu.npu.set_device(0)
np.random.seed(42)

print()
print("=" * 80)
print("实验2: abs(data3) -> split[0].sin_() -> rope_cache_v2_01(...) [关键复现]")
print(" 期望: abs(data3) 不应被 rope 算子影响")
print(" 实际: abs(data3) 被污染 (出现负数/符号反转)")
print("=" * 80)

split_01 = torch.split(data4, 8, dim=0)
square_01 = torch.square(split_01[1])
sin_cos_inplace_02 = torch.abs(data3) # 关键: 保留引用
split_01[0].sin_()
out_cos2.cos_()
_ = torch_npu.npu_kv_rmsnorm_rope_cache_v2(
kv, gamma, cos, sin, index, k_cache1, square_01,
k_rope_scale=None, c_kv_scale=None,
k_rope_offset=None, c_kv_offset=None,
epsilon=1e-5, cache_mode="PA_BNSD", is_output_kv=True,
)
torch.npu.synchronize()

Describe the expected behavior / 预期结果 (Mandatory / 必填)

精度校验成功

2026-09-21 17:04:51,824][INFO] Slog check: grep -r "[ERROR]" /home/Baize/feature/aclgraph/npugraph_ex/milanc26_torch_npugraph_ex_reinplace_support_multistreams/tc_ge_torch_npugraph_ex_reinplace_support_multistreams_0009/log/*
[2026-09-21 17:04:52,960][ERROR] Slog checked failed, key words not found.
[2026-09-21 17:04:52,960][INFO] output_num is 9
[2026-09-21 17:04:52,961][INFO] Start to compare precision between cpu and npu
[2026-09-21 17:04:52,961][INFO] data split count: 512
[2026-09-21 17:04:52,961][INFO] ---------------------------------------------------------------------------------------
[2026-09-21 17:04:52,961][INFO] Loop ExpectOut ActualOut AbsError RelateError
[2026-09-21 17:04:52,961][INFO] ---------------------------------------------------------------------------------------
[2026-09-21 17:04:52,961][INFO] 00000001 0.1782227 0.1760254 0.0021973 0.0021973
[2026-09-21 17:04:52,961][INFO] 00000002 0.4963379 0.1397705 0.3565674 0.7183965
[2026-09-21 17:04:52,961][INFO] ... ... ... ... ...
[2026-09-21 17:04:52,961][INFO] 00000511 0.5800781 -0.1320801 0.7121582 1.2276936
[2026-09-21 17:04:52,961][INFO] 00000512 0.5351562 0.3354492 0.1997070 0.3731752
[2026-09-21 17:04:52,961][INFO] ---------------------------------------------------------------------------------------
[2026-09-21 17:04:52,962][INFO] ErrorThr PctThr PctRes CompareRes
[2026-09-21 17:04:52,962][INFO] ---------------------------------------------------------------------------------------
[2026-09-21 17:04:52,962][INFO] 0.0100 99.00% 1.757812% Failed
[2026-09-21 17:04:52,962][INFO] actual maximum inaccuracy value: 1.9904305934906006
[2026-09-21 17:04:52,962][INFO] config maximum inaccuracy threshold: 0.01
[2026-09-21 17:04:52,962][INFO] Error Line-----------------------------------------------------------------------------
[2026-09-21 17:04:52,962][INFO] Loop ExpectOut ActualOut AbsError RelateError
[2026-09-21 17:04:52,962][INFO] ---------------------------------------------------------------------------------------
[2026-09-21 17:04:52,962][INFO] 00000001 0.4963379 0.1397705 0.3565674 0.7183965
[2026-09-21 17:04:52,962][INFO] 00000002 0.5791016 -0.0259399 0.6050415 1.0447934
[2026-09-21 17:04:52,962][INFO] ... ... ... ... ...
[2026-09-21 17:04:52,962][INFO] 00000510 0.5800781 -0.1320801 0.7121582 1.2276936
[2026-09-21 17:04:52,962][INFO] 00000511 0.5351562 0.3354492 0.1997070 0.3731752
[2026-09-21 17:04:52,962][INFO] ---------------------------------------------------------------------------------------
[2026-09-21 17:04:52,962][INFO] output %d check precision failed
[2026-09-21 17:04:52,967][INFO] clean old case result: [tc_ge_torch_npugraph_ex_reinplace_support_multistreams_0009].
[2026-09-21 17:04:53,192][INFO] result file : /home/Baize/result/aclgraph/milanc26_torch_npugraph_ex_reinplace_support_multistreams_result.csv
[2026-09-21 17:04:53,192][INFO] write result : case_name=[tc_ge_torch_npugraph_ex_reinplace_support_multistreams_0009], result=[Failed], err_percent=[1.757], max_threshold=[1.9904305934906006], err_msg=[]
2026-09-21 17:04:56,922 - INFO - ./xfusion_fmk.sh: slog path: /home/Baize/feature/aclgraph/npugraph_ex/milanc26_torch_npugraph_ex_reinplace_support_multistreams/tc_ge_torch_npugraph_ex_reinplace_support_multistreams_0009/log
2026-09-21 17:04:56,923 - INFO - ./xfusion_fmk.sh: [tc_ge_torch_npugraph_ex_reinplace_support_multistreams_0009]: Failed; time spend:[15]s

Special notes for this issue/备注 (Optional / 选填)

likedislike
游震
游震Collaborators
Sep 21 Comments:

/assign @luwei_1104

likedislike
CANN-robotCANN-robotCollaborators
Sep 21 Assign luwei_1104 as responsible person
Thaurissan
Thaurissan
Sep 22 Comments:

/assign

likedislike
CANN-robotCANN-robotCollaborators
Sep 22 Assign Thaurissan as responsible person
ThaurissanThaurissan
Sep 22 Associated pull request
CANN-robotCANN-robotCollaborators
Sep 24 Close issue
ThaurissanThaurissan
Sep 24 Associated pull request