Make torchsim able to use the latest metatomic features#181
Open
HaoZeke wants to merge 13 commits intometatensor:mainfrom
Open
Make torchsim able to use the latest metatomic features#181HaoZeke wants to merge 13 commits intometatensor:mainfrom
HaoZeke wants to merge 13 commits intometatensor:mainfrom
Conversation
…al outputs Bring MetatomicModel to feature parity with the ASE calculator: - variants parameter for output variant selection via pick_output() - non_conservative flag to read forces/stress directly from model - uncertainty_threshold for per-atom energy uncertainty warnings - additional_outputs for requesting arbitrary extra model outputs Restore documentation sub-pages (getting-started, model-loading, batched, architecture) that were removed during the merge. Closes metatensor#179
- Fix NC stress quantity: "stress" -> "pressure" (matching ASE calculator) - Fix per-system net-force subtraction in batched NC mode - Validate NC output keys exist in model capabilities at construction - Validate additional_outputs entries are ModelOutput instances - Rename misleading test (test_bad_uncertainty_threshold_raises -> test_uncertainty_threshold_stored) - Fix docs API inconsistency (ts.initialize_state -> ts.io.atoms_to_state)
- Gate NC output validation on compute_forces/compute_stress flags (avoids spurious ValueError when model has NC forces but not stress) - Fix docs stress shape notation to use n_systems instead of literal 3
- Precompute evaluation options in __init__ (avoid per-call rebuilding) - Add shape assertion for uncertainty values - Strengthen additional_outputs validation (check _method_names) - Full NC test coverage: forces, stress, batched per-system subtraction, missing-output error, variant selection - Full UQ test coverage: warning emission, high-threshold no-warning, None disables, negative threshold rejection - Variant test: "doubled" gives 2x base energy - Additional outputs test: energy_ensemble stored correctly - Use lj_model_ext fixture (with_extension=True) to test missing NC error
- Default uncertainty_threshold to None (not 0.1) since pure-PyTorch LJ model always has energy_uncertainty output, causing warnings-as- errors in all tests - Gate pick_output calls for NC keys on compute_forces/compute_stress (pick_output raises before our validation if model lacks the output) - Fix test regex: "not found" matches pick_output error message - Apply ruff format
filterwarnings = ["error"] converts warnings to exceptions, so warnings.catch_warnings(record=True) never captures them. Use pytest.warns(UserWarning) which properly overrides the filter.
- Convert state.pbc (bool or array) to Tensor for System() constructor - Fix test regex to match "uncertainties are larger" (pytest.raises matches against str(exception) which wraps differently) Verified: 29 passed, 1 skipped on rg.cosmolab
Luthaf
reviewed
Mar 18, 2026
- Remove doc sub-pages (architecture already in Architecture.md, getting-started/batched belong as tutorials, model-loading goes in docstring) - Remove toctree and "output variants" / "additional outputs" bullet from torch-sim.rst (expected for all engines) - Revert ts.io.atoms_to_state back to ts.initialize_state (torchsim docs convention) - Reformulate NC docstring to match ASE calculator wording - Fix variants docstring example per suggestion - Truncate uncertainty warning atom list to first 20 Verified: 29 passed, 1 skipped on rg.cosmolab
- Remove stale CHANGELOG entry about deleted doc sub-pages - Hoist pbc bool-to-Tensor conversion above per-system loop - Convert uncertainty shape assert to ValueError (survives -O)
- Always resolve both NC keys via pick_output when non_conservative=True (match ASE behavior: validate model supports outputs at construction) - Simplify additional_outputs validation to match ASE pattern (assert isinstance ScriptObject, no internal method duck-typing) - Add test: stress-only NC mode (compute_forces=False) - Add test: NC variant doubled verifies 2x energy - Add test: invalid additional_outputs raises AssertionError Verified: 31 passed, 1 skipped on rg.cosmolab
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.
Close #179.
Contributor (creator of pull-request) checklist
Reviewer checklist