Repository navigation
fix(md): reject illegal NPT requests before any output or model load (R10-F01/P2) - #111
Draft
hydrogen1222 wants to merge 2 commits into
Draft
hydrogen1222 wants to merge 2 commits into
hydrogen1222 wants to merge 2 commits into
Conversation
R10-F01. Four NPT cross-field contracts were only enforced inside ``MDRunner``, i.e. after ``results/`` and ``resolved_config.json`` had been created and after the model was loaded: * NPT with a non-Langevin thermostat, * NPT with ``--no-write-trajectory``, * NPT with ``temperature <= 0``, * NPT with ``npt_tdamp``/``npt_pdamp <= 0``. Measured on main @ fb2935c with ``mliport md --ensemble NPT`` on Cu4: all four produced ``results_dir=Y resolved=Y model_loaded=Y`` before failing. They are pure configuration facts, so they are now rejected by ``resolver._validate_resolved()`` with the *same* messages. The checks stay in ``MDRunner`` for direct API users. Verification on the same four requests after the fix: no run directory, no resolved_config.json, no model load, identical exit code (1) and message. Legal runs are unchanged: NVE, NVT-NHC and NPT ``md.csv`` files are byte-identical (md5) to the main build. Red tests first in tests/mliport/mliport/test_md_npt.py (5 parametrised cases plus one "legal default still resolves" case). Local: 2322 passed, 48 skipped; ruff check/format clean. DATA IMPACT: no scientific record invalidated or regenerated. Only the point at which invalid input is rejected changes; no valid NPT/NVT/NVE run produces different output. Residual (recorded, out of scope here): NHC + FixAtoms is still rejected after the model load (it depends on the structure, not on configuration), and a missing CUDA device still surfaces as a raw torch error.
CI runs ruff@0.5.1 format --check, which reformats the new NPT block's line wrapping. No behavioural change.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Defect (R10-F01, main @
fb2935c7)Four NPT cross-field contracts were only enforced inside
MDRunner, i.e. afterresults/,resolved_config.jsonand the model load:--no-write-trajectory,temperature <= 0,npt_tdamp/npt_pdamp <= 0.Measured with
mliport md --ensemble NPTon a Cu4 cell (mace-mh-1):--thermostat NHCresults_dir=Y resolved=Y model_loaded=Y, exit 1N/N/N, exit 1--no-write-trajectoryY/Y/YN/N/N--temp 0Y/Y/YN/N/N--npt-tdamp 0Y/Y/YN/N/NAll four are pure configuration facts, so they belong to the resolver.
Fix
resolver._validate_resolved()now checks the NPT contract before anything iscreated or loaded, with the same messages (so logs, docs and tests that
quote them keep working).
MDRunnerkeeps its checks for direct API users.No change for valid runs
NVE, NVT-NHC and NPT
md.csvfiles are byte-identical (md5) between mainand this branch for the same seed/structure/options.
Tests
Red first: five parametrised rejection cases plus one "legal NPT default still
resolves" case in
tests/mliport/mliport/test_md_npt.py.Local:
2322 passed, 48 skipped;ruff check/ruff format --checkclean.DATA IMPACT
No scientific record invalidated or regenerated: only the point at which an
invalid request is rejected changes, and no legal NPT/NVT/NVE output changes.
Residual (not fixed here, tracked in #75)
NHC + FixAtomsis still rejected after the model load — it depends on thestructure, not on configuration.
torch.loaderror.