Skip to content

Batched MD with SevenNet+D3 can produce NaN trajectories while ASE remains finite #579

Description

@sek1ro-yuzzz

Summary

I am seeing reproducible NaNs during TorchSim batched MD with SevenNet v0.13.0 + D3(BJ)-PBE. The same structures and MD settings remain finite when run through the ASE SevenNet+D3 path.

The TorchSim call follows the documented batched-MD style:

ts.integrate(system=list_of_atoms, ...)

where list_of_atoms contains 16 independent ASE Atoms objects.

System

  • 16 independent amorphous Na16Ta16Cl96 structures
  • 128 atoms per structure
  • Initial structures look reasonable; initial nearest-neighbor distances are about 2.26 Angstrom
  • SevenNet OMNI checkpoint with modal="omat24"
  • D3(BJ)-PBE enabled

MD settings

  • Ensemble: fixed-cell NVT
  • Integrator: Nose-Hoover chain
  • Temperature: 300 K
  • Timestep: 2 fs
  • Thermostat damping: 200 fs
  • Warmup: 200 steps
  • Measured segment: 1000 steps

Environment

Primary test:

  • GPU: NVIDIA RTX 5090
  • sevenn 0.13.0
  • torch 2.11.0+cu128
  • torch-sim-atomistic 0.6.0
  • ase 3.28.0

Repeat test:

  • GPU: NVIDIA RTX 4090
  • Same package versions: sevenn 0.13.0, torch 2.11.0+cu128, torch-sim-atomistic 0.6.0, ase 3.28.0

Observed behavior

On the RTX 5090 machine, for the same batch of 16 structures:

  • TorchSim + cueq: MD completes, but some batch elements end with NaN energy/temperature.
  • TorchSim + flash: MD completes, but some batch elements end with NaN energy/temperature.
  • ASE + SevenNet+D3 + flash: all 16 structures remain finite under the same structures, potential, and MD settings.

On the RTX 4090 machine, repeating TorchSim + cueq also produces NaN energy/temperature in some batch elements. This suggests the issue is not specific to a single RTX 5090/Blackwell machine.

Static single-point comparison

For the same structure, TorchSim SevenNet+D3 and ASE SevenNet+D3 agree closely in static single-point calculations:

  • Energy difference: about 0.000679 meV/atom
  • Max force-component difference: about 1.62e-5 eV/Angstrom
  • Max stress-component difference: about 1.13e-8 eV/Angstrom^3

So the problem appears more likely to be in the TorchSim MD state update / batched integration path than in the static SevenNet+D3 energy/force evaluation itself.

Expected behavior

With the same initial structures, potential, and fixed-cell NVT settings, TorchSim batched MD should keep energy, temperature, and coordinates finite. If one batch element becomes numerically unstable, it would also be helpful to have a diagnostic exception or warning rather than silently returning a final state with partial-batch NaNs.

Actual behavior

TorchSim batched MD completes and returns results, but some batch elements end with NaN energy/temperature. The ASE MD control remains finite under the same conditions.

I can provide the benchmark config, structures, or a smaller reproducer if that would be useful.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No 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