Closed
[Bug-Report|缺陷反馈]: fillpad layout不一致导致精度问题 #3387
bynshardAdd on  Sep 18Closed at  Sep 22
bynshard
bynshardCollaborators
Sep 18 Create

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

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

在 Ascend950DT 上运行 PyPTO 混合算子用例时,FillPad 对共享 UB 缓冲区中的列分块处理错误,导致有效数据被清零,并可能越过目标缓冲区边界。
该用例中,concat 结果的形状为 [16,128],vector tile 配置为 [16,80],因此 FillPad 被拆分为前 80 列和后 48 列两个分块。两个分块保留父缓冲区的物理行步长 128。
原 TFillPad 封装直接使用 layout 中的静态宽度 128 构造 PTO Tile。底层 TFILLPAD_EXPAND 会将输入有效列之外的区域补到该静态宽度,而不是限制在当前分块的 80/48 列范围内。因此:

  • 后 48 列分块在复制有效数据后,额外写入 80 列零,跨越行边界,最后一行还会越过目标缓冲区末尾 320 字节。
  • 前 80 列分块随后将本行后 48 列清零,覆盖另一分块的有效数据。
  • 错误数据参与后续矩阵乘法和减法,最终三个输出中第一个通过、后两个精度失败。

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

昇腾硬件:Ascend950DT
CANN:9.2.0

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

pypto.set_vec_tile_shapes(16, 80)

c1、input_a_view_2d 的形状均为 [16, 64]

cat_s2 = pypto.concat([c1, input_a_view_2d], dim=-1)
v3_view = pypto.view(
cat_s2, [16, 128], [0, 0],
valid_shape=[bs_valid, 128],
)
v3 = pypto.fillpad(v3_view, "constant", 0.0)

weight_s2 = pypto.full([128, 64], 0.5, dtype=pypto.DT_FP32)
c2 = pypto.matmul(v3, weight_s2, out_dtype=pypto.DT_FP32)

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

精度正确

实现运行结果:
case_idx: 148
case_name: mix_1c2v_VCV_Serial_Parallel_float32_h64_nondiv_148

result: FAILED
output_1: PASS
output_2: FAILED
output_3: FAILED
pipemix_result: PASS

原始 CCE 中的关键调用:
// 两个分块均使用 LocalLayout2Dim<16, 128>

// 后48列:地址偏移80个float,目标shape为[16,48]
TFillPadpto::PadValueCustom((float)0.f)(ubTensor_65, ubTensor_66);

// 前80列:目标shape为[16,80]
TFillPadpto::PadValueCustom((float)0.f)(ubTensor_67, ubTensor_68);

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

likedislike
bynshardbynshardCollaborators
Sep 18 Associated pull request
Jie Yin
Jie YinCollaborators
Sep 19 Comments:

已关联PR

likedislike
Jie YinJie YinCollaborators
Sep 19 Assign bynshard as responsible person
Jie YinJie YinCollaborators
Sep 19 Added label: Operations
bynshardbynshardCollaborators
Sep 20 Associated pull request
liuyu205liuyu205
Sep 20 Associated pull request
liuyu205liuyu205
Sep 20 Associated pull request
bynshardbynshardCollaborators
Sep 22 changed custom state from 进行中 to 已完成
bynshardbynshardCollaborators
Sep 22 Close issue
CANN-robotCANN-robotCollaborators
Sep 22 Added label: resolved