Skip to content

Fix non-PBC fake-cell sizing in get_neighborhood#1501

Closed
keceli wants to merge 1 commit into
ACEsuit:mainfrom
Autonomous-Scientific-Agents:fix/neighborhood-fake-cell-allocation
Closed

Fix non-PBC fake-cell sizing in get_neighborhood#1501
keceli wants to merge 1 commit into
ACEsuit:mainfrom
Autonomous-Scientific-Agents:fix/neighborhood-fake-cell-allocation

Conversation

@keceli

@keceli keceli commented Jun 13, 2026

Copy link
Copy Markdown

The previous formula sized the fake cell as max(|positions|) * 5 * cutoff, which depended on where the molecule sat relative to the origin rather than its actual extent, and used a multiplicative safety margin instead of an additive one. A molecule with max|positions|=237 A and cutoff=5 produced a fake cell of ~5948 A per side. matscipy's neighbour_list then allocated a linked-cell grid of ~1.7 billion bins (~6 GiB CPU RAM) just to find a few hundred edges among ~50 atoms. In production this propagated into multi-hundred-GiB tensor allocations on accelerators and triggered uncatchable GPU page faults that took down 12 000-rank MPI runs.

Replace with cell = extent + 5 * cutoff so the cell scales with the molecular bounding box and is translation-invariant. For a 200 A molecule the cell drops from ~6000 A to ~232 A; for a typical 10 A molecule from 250 A to ~35 A. Edge counts are unchanged; matscipy allocation goes from O(GiB) to O(MiB).

PS: I had out of memory errors for some geometries and opus4.7 found the bug and helped me patch.

The previous formula sized the fake cell as max(|positions|) * 5 * cutoff,
which (a) depended on where the molecule sat relative to the origin
rather than its actual extent, and (b) used a multiplicative safety
margin instead of an additive one. A molecule with max|positions|=237 A
and cutoff=5 produced a fake cell of ~5948 A per side. matscipy's
neighbour_list then allocated a linked-cell grid of ~1.7 billion bins
(~6 GiB CPU RAM) just to find a few hundred edges among ~50 atoms.
In production this propagated into multi-hundred-GiB tensor allocations
on accelerators and triggered uncatchable GPU page faults that took
down 12 000-rank MPI runs.

Replace with cell = extent + 5 * cutoff so the cell scales with the
molecular bounding box and is translation-invariant. For a 200 A
molecule the cell drops from ~6000 A to ~232 A; for a typical 10 A
molecule from 250 A to ~35 A. Edge counts are unchanged; matscipy
allocation goes from O(GiB) to O(MiB).
@gabor1

gabor1 commented Jun 14, 2026

Copy link
Copy Markdown
Collaborator

this fixes the same issue as #1473 . are you happy with the fix there?

@keceli

keceli commented Jun 15, 2026

Copy link
Copy Markdown
Author

Oh, yes, didn't see it. Thank you!

@keceli keceli closed this Jun 15, 2026
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.

2 participants