deepmodeling / deepmodeling/deepmd-kit

pt losses dens/population/denoise: not covered by mixed_type padding fix

Open
#5,761 0 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
Python
Stars
2k
Forks
649
Avg merge
6d 18h
Merged PRs (30d)
15

Description

Follow-up to #5738.

PR #5738 applied per-frame, mask-aware loss normalization (excluding `type<0` ghost padding atoms in `mixed_type` batches) to five shared loss types — `ener`, `ener_spin`, `dos`, `tensor`, `property` — across the dpmodel and pt backends. The **pt-only losses `dens`, `population`, and `denoise`** were out of scope and were not audited or fixed.

Scope: audit `deepmd/pt/loss/{dens,population,denoise}.py` for the same mixed_type padding artifact (denominators / means diluted by ghost atoms), apply the per-frame masked normalization where needed under the existing `model_dict["mask"]` convention, and add grad-accumulation-invariant + all-ones-mask no-op tests mirroring `source/tests/pt/test_loss_padding.py`. If a given loss is already frame-decomposable, document that instead.

Contributor guide

Open the contributing guide

Research direction

Read deepmd/pt/loss/dens.py, population.py, and denoise.py, then compare their normalization with the existing mixed_type handling and source/tests/pt/test_loss_padding.py. Audit the model_dict["mask"] behavior for ghost padding, add the requested grad-accumulation-invariant and all-ones-mask no-op coverage where needed, and document any loss that is already frame-decomposable.

Written by the indexing model from the issue text.

Assessment

Tech stack
python, pytorch
Domain
machine-learning, testing-qa
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
68/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.