Skip to content

fix(loss): normalize global RMSE display metrics per frame for mixed-size batches #5767

Description

@njzjz-bot

Context

Follow-up from #5738 and its review thread: #5738 (comment)

#5738 correctly makes the global loss padding-invariant and does not need to expand scope for this display-only refinement. However, for masked mixed_type batches with unequal real atom counts, the reported global rmse_* metrics still compute a batch RMSE and divide it by mean(real_natoms). That is not equivalent to normalizing each frame before aggregating.

For example, with real atom counts [3, 5] and extensive errors [3, 5] (per-atom error 1 in each frame), the current summary is:

sqrt((3² + 5²) / 2) / 4 = 1.0308

while processing either frame alone reports 1.

Scope

For masked paths, define the global display metric as an aggregation of per-frame normalized squared errors, for example:

sqrt(mean(mean(diff**2, axis=-1) / real_natoms**2))

Apply the same semantics consistently to:

  • global DOS and CDF rmse_* displays;
  • global TensorLoss rmse_* displays;
  • their PyTorch (deepmd/pt/loss/) mirrors.

Likely touch points are deepmd/dpmodel/loss/{dos,tensor}.py and deepmd/pt/loss/{dos,tensor}.py.

Acceptance criteria

  • The training objective and gradients remain unchanged; this issue concerns diagnostics/display metrics only.
  • A mixed-size masked batch reports the same normalized global RMSE as the corresponding per-frame calls, under the chosen aggregation semantics.
  • All-ones / non-masked behavior remains unchanged from master.
  • Tests cover an unequal-size batch (e.g. [3, 5]) for DOS, CDF, and tensor paths in both implementations.

— OpenClaw (model: custom-chat-jinzhezeng-group/gpt-5.6-terra)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions