Skip to content

[Cherry-Pick][PHI] non-contiguous paddle.nansum accuracy matching#78296

Merged
sneaxiy merged 7 commits intoPaddlePaddle:release/3.3from
Enigmatisms:nansum_cp
Mar 16, 2026
Merged

[Cherry-Pick][PHI] non-contiguous paddle.nansum accuracy matching#78296
sneaxiy merged 7 commits intoPaddlePaddle:release/3.3from
Enigmatisms:nansum_cp

Conversation

@Enigmatisms
Copy link
Contributor

@Enigmatisms Enigmatisms commented Mar 13, 2026

PR Category

Operator Mechanism

PR Types

Improvements

Description

从主仓:

将组合算子 paddle.nansum 改造为 PHI 算子,以对 PyTorch 做精度对齐。组合算子的 paddle.where 会强制把不连续 tensor 转为连续,导致累加顺序变化 (@baoqiwen)。复用 phi::Reduce 操作以及手动实现的 NanSumOps 可修正此问题。

本 PR 需要考虑 non-contiguous layout,所以在 strided ops 里增加了 nansum。

注意! 本 PR 与 dev 分支也有一定的差别:

  • dev 分支由于有一个 commit 修改了 phi::Full 操作,这个commit修改量巨大,并没有 CP 到 release3.3,故本 PR 将 Full 操作的写法 revert 到了对应 commit 之前。只有 phi::Full 的调用方法相关代码有差别。

大 Tensor 精度对齐测试:

image

Torch 对齐精度测试:

image

是否引起精度变化

devPR:#78219

Pcard-89620

@paddle-bot
Copy link

paddle-bot bot commented Mar 13, 2026

你的PR提交成功,感谢你对开源项目的贡献!
请关注后续CI自动化测试结果,详情请参考Paddle-CI手册
Your PR has been submitted. Thanks for your contribution!
Please wait for the result of CI firstly. See Paddle CI Manual for details.

@codecov-commenter
Copy link

Codecov Report

❌ Patch coverage is 79.24528% with 11 lines in your changes missing coverage. Please review.
⚠️ Please upload report for BASE (release/3.3@de52ccb). Learn more about missing BASE report.

Files with missing lines Patch % Lines
.../interface/infer_symbolic_shape/unary_infer_sym.cc 0.00% 11 Missing ⚠️

❌ Your patch status has failed because the patch coverage (79.24%) is below the target coverage (90.00%). You can increase the patch coverage or adjust the target coverage.

Additional details and impacted files
@@              Coverage Diff               @@
##             release/3.3   #78296   +/-   ##
==============================================
  Coverage               ?   79.24%           
==============================================
  Files                  ?        4           
  Lines                  ?       53           
  Branches               ?        0           
==============================================
  Hits                   ?       42           
  Misses                 ?       11           
  Partials               ?        0           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Contributor

@risemeup1 risemeup1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM for coverage,覆盖率机制问题,实验表明测试PR #78297 可以走到这段代码,但是覆盖率统计不到,故豁免

@Enigmatisms
Copy link
Contributor Author

单个文件 Coverage 未覆盖的问题与

Copy link
Contributor

@wanghuancoder wanghuancoder left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@sneaxiy sneaxiy merged commit 3c11704 into PaddlePaddle:release/3.3 Mar 16, 2026
174 of 198 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants