fix(tf): preserve ghost gradients in ProdForceGrad#5848
Conversation
|
Warning Review limit reached
Next review available in: 3 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
Size upstream force gradients by all atoms and keep local and ghost slices distinct in the legacy TensorFlow ProdForce gradient. Validate atom counts and neighbor bounds before indexing. Cover a second ghost at index nloc + 1 so the regression exercises the removed modulo branch and proves its independent upstream gradient is used. Coding-Agent: Codex Codex-Version: codex-cli 0.144.4 Model: gpt-5.6-sol Reasoning-Effort: xhigh
90f032a to
86b61b1
Compare
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #5848 +/- ##
==========================================
- Coverage 78.58% 78.32% -0.27%
==========================================
Files 1050 1050
Lines 120637 120642 +5
Branches 4356 4365 +9
==========================================
- Hits 94801 94488 -313
- Misses 24278 24592 +314
- Partials 1558 1562 +4 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Summary
ProdForceGradwithProdForce's[nframes, 3 * nall]output contractnlocnloc + 1across two framesWhy existing tests missed this
The direct TensorFlow gradient test exercised the newer
ProdForceSeAhelper withnall == nloc, so it had neither ghost atoms nor the legacyProdForceGradimplementation. Higher-level loc-frame coverage did not differentiate the legacy force output with deliberately distinct local and ghost upstream gradients. The stale code also looked superficially consistent with the newer local-only helper even though the legacy forward op had been changed in 2018 to retain separate ghost-force outputs.The regression invokes
tf.gradientson the real legacyProdForceop, usesj_idx == nloc + 1so the removedj_idx > nlocmodulo branch is actually exercised, assigns distinct local and two-ghost upstream gradients, and uses two frames to lock the correctednall * 3frame stride.Validation
DP_ENABLE_PYTORCH=0 uv pip install -e .[cpu,test]pytest source/tests/tf/test_prod_force_grad.py -qusing the current editable finder (3 passed, 1 inherited TensorFlow helper skipped)ruff format .ruff check .--Werrorgit diff --checkFixes #5656
Coding agent: Codex
Codex version: codex-cli 0.144.4
Model: gpt-5.6-sol
Reasoning effort: xhigh