Skip to content

feat: add NVE energy-conservation benchmark#146

Open
maxbortone wants to merge 1 commit into
developfrom
feat/nve-energy-conservation
Open

feat: add NVE energy-conservation benchmark#146
maxbortone wants to merge 1 commit into
developfrom
feat/nve-energy-conservation

Conversation

@maxbortone

Copy link
Copy Markdown
Collaborator

Summary

Ports the NVE energy-conservation benchmark from the internal repo to the OSS library. It runs short microcanonical (NVE, velocity-Verlet, no thermostat) MD trajectories for four representative systems — a vacuum HCNO molecule, bulk water (500 molecules), and two solvated peptides — and scores how well the model conserves total mechanical energy E(t) = PE(t) + KE(t).

The headline metric is the magnitude of the fitted total-energy drift over the run divided by the standard deviation of the kinetic energy, mapped through the standard soft-threshold scorer. A flat total energy → score ≈ 1.0; a strong drift → score → 0.0.

What's included

  • Benchmark (src/mlipaudit/benchmarks/nve_energy_conservation/): NVEEnergyConservationBenchmark + its ModelOutput/Result classes, registered via Benchmark.__subclasses__(). Elements are gated per-system (skip_if_elements_missing = False) so a model missing one element only skips the affected systems.
  • UI page (src/mlipaudit/ui/nve_energy_conservation.py): summary score table + per-system total-energy drift curves with their linear fits.
  • Beta: added to BENCHMARKS_TO_SKIP_FOR_PUBLIC_LEADERBOARD (like the NEB benchmark) — it runs and scores but is hidden from the public leaderboard.
  • Tests: unit tests (mocked simulation) covering run/analyze, the scoring metric, element skipping, and failure handling, plus the generic UI-page test; checked-in test structures under tests/data/.
  • Docs: user-facing and API-reference pages under the General category.

Dependency note ⚠️

The NVE velocity-Verlet integrator (MDIntegrator.NVE_VELOCITY_VERLET) and SimulationState.potential_energy are only on mlip's develop branch — not in any published PyPI release (PyPI 0.2.1 has neither). This PR therefore pins mlip to git develop via [tool.uv.sources], matching the internal repo. This is temporary: once a mlip release ships NVE support, drop the [tool.uv.sources] entry to use the PyPI build.

Data

The benchmark data (4 structure files) is added separately to the InstaDeepAI/MLIPAudit-data HF dataset as nve_energy_conservation.zip (top-level nve_energy_conservation/ directory) — handled via the data-repo PR. Tests run offline using the checked-in tests/data/ copies.

Verification

  • uv run pytest → 139 passed
  • uv run pre-commit run --all-files → ruff + mypy + checks all pass
  • uv run sphinx-build -W -b html docs/source docs/build/html → build succeeded

🤖 Generated with Claude Code

Port the NVE energy-conservation benchmark from the internal repo. It runs
short microcanonical (NVE, velocity-Verlet, no thermostat) MD trajectories
for four representative systems (vacuum molecule, bulk water, two solvated
peptides) and scores how well the model conserves total mechanical energy
E(t) = PE(t) + KE(t). The metric is the fitted total-energy drift over the
run divided by the kinetic-energy standard deviation, mapped through the
standard soft-threshold scorer.

- Add the benchmark module, registered and gated per-system on elements.
- Add the Streamlit UI page (per-system drift curves + linear fits) and wire
  it into the GUI.
- Mark it beta (BENCHMARKS_TO_SKIP_FOR_PUBLIC_LEADERBOARD), like the NEB
  benchmark.
- Add unit tests and checked-in test structures, plus the generic UI-page test.
- Add user-facing and API-reference docs under the General category.

The NVE velocity-Verlet integrator and SimulationState.potential_energy are
only on mlip's `develop` branch, not yet in a PyPI release, so pin mlip to git
`develop` via [tool.uv.sources] until a release ships them.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@lwalew lwalew self-requested a review June 26, 2026 14:01
Comment thread pyproject.toml
Comment on lines +34 to 41
# Temporary: the NVE energy-conservation benchmark needs the NVE velocity-Verlet
# integrator (MDIntegrator.NVE_VELOCITY_VERLET) and SimulationState.potential_energy,
# which are on mlip's `develop` branch but not yet in a published PyPI release. Pin to
# git `develop` until a release ships these, then drop this source to use the PyPI build.
[tool.uv.sources]
mlip = { git = "https://github.com/instadeepai/mlip-jax.git", branch = "develop" }

[dependency-groups]

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reminder: To remove these lines since it's now merged upstream

Comment on lines +106 to 111
BENCHMARKS_TO_SKIP_FOR_PUBLIC_LEADERBOARD = [
NudgedElasticBandBenchmark,
NVEEnergyConservationBenchmark,
]


Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remark: This is temporary right? We have a scoring which we'd like to display? Or not?


# Scoring threshold on the energy-drift / kinetic-energy-fluctuation ratio
# computed in `_analyze_structure`.
ENERGY_DRIFT_RATIO_THRESHOLD = 1.0

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So I think from the PR open on mlipaudit-internal, tweaking this value is the only open question in this file


NVE energy conservation
=======================

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Docs looking good :raised_hands. Maybe @Silvia can also double-check

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.

3 participants