Skip to content

[PHI] non-contiguous paddle.nansum accuracy matching#78219

Merged
wanghuancoder merged 6 commits intoPaddlePaddle:developfrom
Enigmatisms:nansum
Mar 16, 2026
Merged

[PHI] non-contiguous paddle.nansum accuracy matching#78219
wanghuancoder merged 6 commits intoPaddlePaddle:developfrom
Enigmatisms:nansum

Conversation

@Enigmatisms
Copy link
Contributor

@Enigmatisms Enigmatisms commented Mar 8, 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。

大 Tensor 精度对齐测试:

image

Torch 对齐精度测试:

image

是否引起精度变化

Pcard-89620

@paddle-bot
Copy link

paddle-bot bot commented Mar 8, 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.

@Enigmatisms Enigmatisms force-pushed the nansum branch 5 times, most recently from 8110d92 to cadd8a7 Compare March 10, 2026 03:35
@codecov-commenter
Copy link

codecov-commenter commented Mar 10, 2026

Codecov Report

❌ Patch coverage is 78.00000% with 11 lines in your changes missing coverage. Please review.
⚠️ Please upload report for BASE (develop@cfd0574). 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 (78.00%) 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             @@
##             develop   #78219   +/-   ##
==========================================
  Coverage           ?   78.00%           
==========================================
  Files              ?        4           
  Lines              ?       50           
  Branches           ?        0           
==========================================
  Hits               ?       39           
  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.

@Enigmatisms Enigmatisms force-pushed the nansum branch 2 times, most recently from 6663131 to 9128b41 Compare March 11, 2026 01:23
@Enigmatisms
Copy link
Contributor Author

unary_infer_sym.cc 的 coverage 属于误报,本地实测增加log:
image

运行 legacy_test/test_nansum_phi_func.py,其中 TestNansumStaticGraph 可以测到(两个log都能打印):
image

Coverage 应该能跑到 test_nansum_phi_func,但不知为何覆盖率记录错误。

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

@Enigmatisms
Copy link
Contributor Author

本部分的 symbolic shape infer 单测 Coverage 未覆盖问题将 Open 一个新 PR 进行 double check。本地虽然能测过,但 Coverage 则不明原因未覆盖。

Copy link
Contributor

@From00 From00 left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Contributor

@lugimzzz lugimzzz left a comment

Choose a reason for hiding this comment

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

lgtm

@Enigmatisms
Copy link
Contributor Author

PR #78297 测试了CI反馈未覆盖代码如果增加必定报错的写法(evaluate 为 false 的 paddle_enforce)。发现:Coverage 实际报错了。说明实际能跑到对应的单测,但是 coverage 统计对应测试的覆盖率。

@wanghuancoder wanghuancoder merged commit 56be465 into PaddlePaddle:develop Mar 16, 2026
143 of 151 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.

8 participants