Repository navigation
Conversation
lil-lon
reviewed
Nov 9, 2026
Comment on lines
+359
to
+361
| @pytest.mark.parametrize("neighbor_list_fn", [torch_nl_n2, torchsim_nl]) | ||
| @pytest.mark.parametrize("reduce_to_half_list", [False, True]) | ||
| def test_isolated_pair_atom_energies( |
Collaborator
There was a problem hiding this comment.
This path is covered by test_batched_atom_energies_unequal_system_sizes, whose second system is the same isolated pair, so I think you can delete this test.
| torch.testing.assert_close(out["energies"].sum(), out["energy"].sum()) | ||
|
|
||
|
|
||
| @pytest.mark.parametrize("neighbor_list_fn", [torch_nl_n2, torchsim_nl]) |
Collaborator
There was a problem hiding this comment.
The neighbor-list backend parametrization is unnecessary, since the neighbor-list backends are tested separately.
Keeping this test parametrized only over reduce_to_half_list should be enough.
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.
Summary
PairPotentialModeladds each weighted pair energy to the system once and to each endpoint in full. As a result, the sum ofenergiesis twice the returned systemenergy, for both full and half neighbor lists.For two isolated soft-sphere atoms at distance 0.5, with epsilon=sigma=1 and alpha=2, the system energy is 0.125 but the atom energies are
[0.125, 0.125]. Allocate half of the weighted pair energy to each endpoint, giving[0.0625, 0.0625]and preserving the system total of 0.125.Reproduction
python -m pytest -q tests/models/test_pair_potential.py -k 'isolated_pair_atom_energies or batched_atom_energies_unequal_system_sizes'The four isolated-pair cases and four unequal-batch cases fail at the expected per-atom energy assertion with baseline accumulation and pass with the fix. Both fixtures cover full and half lists with
torch_nl_n2and the defaulttorchsim_nlbackend on CPU float64. The unequal batch has three atoms in one system and two in the other; its expected atom energies are[0.0625, 0.125, 0.0625, 0.0625, 0.0625]and its system totals are[0.25, 0.125]. Each system's atom energies must sum to its own returned total.Validation
python -m pytest -q tests/models/test_pair_potential.py tests/models/test_soft_sphere.py tests/models/test_lennard_jones.py: 59 passed after adding the unequal-batch regression.python -m pytest --cov=torch_sim --cov-report=xml: exited before collection because the prepared environment does not havepytest-cov(--covarguments were unrecognized).python -m pytest: 1011 passed, 208 skipped, exit 0. Each final run includes all regression additions. Three PyTablesUnclosedFileWarningmessages followed the summary during trajectory-file cleanup.git diff --check: clean.Scope and evidence
This change is limited to per-atom energy allocation and regressions. It leaves the system energy, force accumulation, stress accumulation, and neighbor-list construction unchanged. GPU and long-running simulation validation were not performed.
The F002 evidence and native ASE control documents the original invariant failure.
Checklist