Skip to content

fix(loss): clarify intensive normalization docs and add test coverage#5

Merged
anyangml merged 1 commit into
fix/rmse-loss-normalizationfrom
copilot/update-code-based-on-review-comments
Apr 19, 2026
Merged

fix(loss): clarify intensive normalization docs and add test coverage#5
anyangml merged 1 commit into
fix/rmse-loss-normalizationfrom
copilot/update-code-based-on-review-comments

Conversation

Copilot AI commented Apr 19, 2026

Copy link
Copy Markdown

Review feedback identified that intensive parameter documentation overstated its scope—implying 1/N² vs 1/N applies universally when it only affects non-Huber MSE energy/virial terms.

Documentation Updates

Updated docstrings across all backends to accurately describe behavior:

  • MSE energy/virial: 1/N² when intensive=True, 1/N otherwise
  • MAE: remains 1/N regardless of intensive
  • Huber: residuals already normalized by 1/N before Huber formula, so flag has limited effect

Files: deepmd/{utils/argcheck.py, tf/loss/ener.py, pd/loss/ener.py, dpmodel/loss/ener.py, pt/loss/ener.py, pt/loss/ener_spin.py, dpmodel/loss/ener_spin.py}

Comment Fix

Changed misleading "RMSE normalization exponent" → "loss normalization exponent" in TF backend.

Test Coverage

  • Added intensive parameter to cross-backend consistency test parameterization
  • Added TestIntensiveNatomsScaling regression tests verifying:
    • MSE loss doesn't scale linearly with N when intensive=True
    • intensive=True vs False produces expected 1/N ratio difference

@anyangml anyangml marked this pull request as ready for review April 19, 2026 14:08
@anyangml anyangml merged commit 45cffad into fix/rmse-loss-normalization Apr 19, 2026
@anyangml anyangml deleted the copilot/update-code-based-on-review-comments branch April 19, 2026 14:08
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