Skip to content

fix causal_softmax op to adapt with ascend#1280

Merged
wooway777 merged 2 commits into
InfiniTensor:mainfrom
ShaneWoof:fix/causal_softmax_ascend
Jun 13, 2026
Merged

fix causal_softmax op to adapt with ascend#1280
wooway777 merged 2 commits into
InfiniTensor:mainfrom
ShaneWoof:fix/causal_softmax_ascend

Conversation

@ShaneWoof

Copy link
Copy Markdown
Contributor

修改 causal_softmax 算子在昇腾 Ascend 上对 x tensor 非默认 batch stride 和 BF16 dtype 进行适配。

修改内容:修改 Infinicore/src/infiniop/ops/causal_softmax/ascend/causal_softmax_ascend.cc
1、新增 BF16 值张量支持;
2、引入连续 temp 缓冲(batch×seq×total_seq_len),每条 calculate 将 x 逐行拷贝到 temp 后在 temp 上完成 masked_fill 和 softmax,最终写入 y,绕过 aclnnInplaceMaskedFillTensor 无法处理 x_tensor 非默认 batch stride 的限制。

现状: infiniop算子测试全部通过;infinicore算子接口测试跑通,53/63 Passed
(1)infiniop
测试样例:
image
测试结果:
d3bc29c5d954d09e18f2f0f35467ab18

(2)infinicore
测试样例:
image
测试结果:
13074855d39b3f3c04c961369fc720e1

修改 causal_softmax 算子在昇腾 Ascend 上对 x tensor 非默认 batch stride 和 BF16 dtype 进行适配。

修改内容:修改 Infinicore/src/infiniop/ops/causal_softmax/ascend/causal_softmax_ascend.cc
1、新增 BF16 值张量支持;
2、引入连续 temp 缓冲(batch×seq×total_seq_len),每条 calculate 将 x 逐行拷贝到 temp 后在 temp 上完成 masked_fill 和 softmax,最终写入 y,绕过 aclnnInplaceMaskedFillTensor 无法处理 x_tensor 非默认 batch stride 的限制

现状: infiniop算子测试全部通过;infinicore算子接口测试跑通,53/63 Passed
@ShaneWoof ShaneWoof requested a review from a team June 13, 2026 07:46
@wooway777 wooway777 merged commit 4a177ab into InfiniTensor:main Jun 13, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants