-
Notifications
You must be signed in to change notification settings - Fork 584
fix: relax atol and rtol value of padding atoms UT
#4892
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
📝 WalkthroughWalkthroughLoosened numerical tolerances in a test: increased absolute tolerance, introduced relative tolerance, and applied both in assert_allclose comparisons within a single test case. Changes
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~3 minutes Suggested labels
Suggested reviewers
Tip 🔌 Remote MCP (Model Context Protocol) integration is now available!Pro plan users can now connect to remote MCP servers from the Integrations page. Connect with popular remote MCPs such as Notion and Linear to add more context to your reviews and chats. ✨ Finishing Touches
🧪 Generate unit tests
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR/Issue comments)Type Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (3)
source/tests/pt/test_padding_atoms.py (3)
52-53: Relaxed tolerances look reasonable; add a brief rationale comment for future maintainersGiven the observed max abs≈2e-8 and rel≈6.5e-7,
atol=1e-6andrtol=1e-5provide a small, sane margin (andrtolaligns with torch.allclose defaults). Add a comment so the change isn’t “tightened back” in future refactors.Apply this diff to document the rationale:
self.rcut_smth = 0.4 - self.atol = 1e-6 - self.rtol = 1e-5 + # NOTE: Relax tolerances to deflake occasional PyTorch backend numeric drift. + # Observed maxima: abs~2e-8, rel~6.5e-7; keep a small margin suitable for float32 (see PR #4892). + self.atol = 1e-6 + self.rtol = 1e-5
79-84: Improve diagnostics: include an error message for the “intensive” checkAdding
err_msgwill make failures more actionable without changing behavior.np.testing.assert_allclose( to_numpy_array(result[var_name].cpu().detach()), np.mean(to_numpy_array(result[f"atom_{var_name}"].cpu().detach()), axis=1), atol=self.atol, - rtol=self.rtol, + rtol=self.rtol, + err_msg=f"intensive property mismatch for '{var_name}'", )
106-111: Improve diagnostics: include padding_atoms in the assertion messageWhen this assert fails, knowing which
padding_atomscaused it greatly speeds up triage.np.testing.assert_allclose( to_numpy_array(result[var_name].cpu().detach()), to_numpy_array(result_padding[var_name].cpu().detach()), atol=self.atol, - rtol=self.rtol, + rtol=self.rtol, + err_msg=f"padding invariance mismatch for '{var_name}' with padding_atoms={padding_atoms}", )
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
💡 Knowledge Base configuration:
- MCP integration is disabled by default for public repositories
- Jira integration is disabled by default for public repositories
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (1)
source/tests/pt/test_padding_atoms.py(3 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (29)
- GitHub Check: Build wheels for cp310-manylinux_aarch64
- GitHub Check: Build wheels for cp311-win_amd64
- GitHub Check: Build wheels for cp311-macosx_arm64
- GitHub Check: Build wheels for cp311-manylinux_x86_64
- GitHub Check: Test Python (5, 3.9)
- GitHub Check: Build wheels for cp311-macosx_x86_64
- GitHub Check: Build wheels for cp311-manylinux_x86_64
- GitHub Check: Test Python (6, 3.9)
- GitHub Check: Test Python (2, 3.12)
- GitHub Check: Test Python (4, 3.12)
- GitHub Check: Test Python (3, 3.9)
- GitHub Check: Test Python (5, 3.12)
- GitHub Check: Test Python (6, 3.12)
- GitHub Check: Test Python (3, 3.12)
- GitHub Check: Test Python (4, 3.9)
- GitHub Check: Test Python (1, 3.9)
- GitHub Check: Test Python (2, 3.9)
- GitHub Check: Test Python (1, 3.12)
- GitHub Check: Build C++ (cuda120, cuda)
- GitHub Check: Build C++ (clang, clang)
- GitHub Check: Build C library (2.18, libdeepmd_c.tar.gz)
- GitHub Check: Build C++ (cuda, cuda)
- GitHub Check: Build C library (2.14, >=2.5.0,<2.15, libdeepmd_c_cu11.tar.gz)
- GitHub Check: Build C++ (rocm, rocm)
- GitHub Check: Build C++ (cpu, cpu)
- GitHub Check: Analyze (python)
- GitHub Check: Analyze (c-cpp)
- GitHub Check: Test C++ (false)
- GitHub Check: Test C++ (true)
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## devel #4892 +/- ##
==========================================
- Coverage 84.29% 84.29% -0.01%
==========================================
Files 702 702
Lines 68665 68666 +1
Branches 3573 3573
==========================================
Hits 57884 57884
- Misses 9642 9643 +1
Partials 1139 1139 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
…4892) The UT of padding atoms(pytorch backend) sometimes fails like: ``` Mismatched elements: 1 / 2 (50%) Max absolute difference among violations: 1.97471693e-08 Max relative difference among violations: 6.45619919e-07 ACTUAL: array([[-0.236542], [ 0.030586]]) DESIRED: array([[-0.236542], [ 0.030586]]) = 1 failed, 15442 passed, 4135 skipped, 97877 deselected, 224 warnings in 2825.25s (0:47:05) = ``` <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **Tests** - Adjusted numerical comparison assertions to use both absolute and relative tolerances in padding-related tests. - Aligns checks between computed results and references, improving resilience to minor floating-point variation. - Reduces intermittent test failures across environments and dependency versions. - No impact on features, performance, or user workflows. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
The UT of padding atoms(pytorch backend) sometimes fails like:
Summary by CodeRabbit