Repository navigation
Compute n_edges memory scalers in atom-bounded chunks - #612
Merged
Merged
Conversation
_n_edges_scalers ran one neighbor-list pass over the whole state. The Alchemiops backend holds fixed-width buffers of ~4.4 KiB per atom at a 6 A cutoff, so a 10.7M-atom state needs ~45 GiB for this pass and OOMs on an A40 before the first optimization step. Run the pass over contiguous runs of whole systems holding at most N_EDGES_MAX_ATOMS_PER_PASS (250k) atoms; a larger system runs alone. Edge counts do not depend on other systems, so the scalers are unchanged.
CompRhys
reviewed
Oct 5, 2026
CompRhys
enabled auto-merge (squash)
October 5, 2026 19:56
Contributor
Author
|
The CI run on 732e8c5 was hit by a GitHub runner outage: 22 jobs were cancelled with "The job was not acquired by Runner of type hosted even after multiple attempts" and never started. Could someone with access use "Re-run failed jobs"? The full run on 4112b71 passed all test-core jobs and prek; the second commit only renames a parameter. The metatomic failures also occur on main since 33caef4 and are not required checks. |
CompRhys
disabled auto-merge
October 6, 2026 08:23
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
_n_edges_scalersno longer builds one neighbor list over the whole state. It runs the neighbor list over contiguous runs of whole systems, at mostN_EDGES_MAX_ATOMS_PER_PASS(250,000) atoms per pass. A system larger than that runs alone.Problem
With
memory_scales_with="n_edges", the autobatchers get each system's edge count by building one neighbor list over the whole submitted state. With the Alchemiops backend, that list uses fixed-width buffers (192 neighbor slots per atom at a 6 Å cutoff), about 4.4 KiB per atom. Memory therefore grows with the size of the job, not of a batch, and large jobs run out of GPU memory before the first optimization step.Example: a molecular conformer job of 275,988 systems (10.74M atoms, ORB v3 + D3, LBFGS) fails in
BinningAutoBatcher.load_states→calculate_memory_scalers→_n_edges_scalerswith a 23 GiB allocation for the shift matrix. A linear fit puts the single pass at ~45 GiB, more than an A40.Fix
A system's edge count does not depend on the other systems in the state, so splitting the pass along system boundaries returns exactly the same scalers. The batchers and
calculate_memory_scalersare unchanged, and so is the public API.max_atoms_per_passis a keyword argument on the private function, used by the tests.250k atoms keeps the pass at about 1 GiB with the default 6 Å width. That is small enough to sit next to a loaded model on common GPUs and large enough that the number of passes doesn't matter: the 10.74M-atom job above takes 43 passes and 0.8 s in total. This pass only produces the scalers; batch size still comes from the memory probe.
Results (Quadro RTX 6000, 24 GB, the job above)
Checklist
ruff formatclean;ruff checkadds no new findings.)test_n_edges_scalers_chunked_matches_single_pass: chunked scalers equal the single pass for limits of 1, 16, 40 and 10,000 atoms on a mixed periodic state (32-, 8-, 8- and 32-atom systems).test_n_edges_scalers_chunk_bounds: every pass holds whole systems, covers each system and atom exactly once, and exceeds the limit only for a lone system.tests/test_autobatching.py(49 passed on GPU) andtests/test_runners.py(38 passed) run locally.Notes
estimate_max_neighbors(cutoff).max_neighbors= largest system in the pass − 1. For the job above, that cuts each pass from 192 to at most 94 neighbor slots per atom. We left it out because chunking alone bounds this pass at ~1 GiB, the pass runs once perload_states, and the cap does not change the scalers or batch sizes. In D3, the neighbor list is rebuilt on every forward pass, so the cap there frees memory for larger batches.