Repository navigation
Conversation
Adaptive cutoff (ported from pet-jax, "solver" method): - apax/layers/adaptive_cutoff.py: per-atom cutoffs via Newton-bisection root find with an implicit-function-theorem step, so gradients flow through the cutoffs (shadow forces). Pairs within the mean of both atomic cutoffs are selected, tapered at their pair cutoff, and packed into n_atoms * k_sel edges, bounding the per-atom environment. Sparse systems (dimers, molecules) get cutoffs close to r_max. - Optional `adaptive_cutoff` model config; basis.r_max becomes the maximum (and neighbor list) cutoff. The taper replaces the descriptors' fixed r_max cutoff (GMNN incl. the factorized radial function, equiv-MP and so3krates take per-edge `cutoffs`). Periodic self-images are selected like other neighbors, consistent with the self-image masking. - k_sel is a shape, not saved: sized from the data in training, eval, BAL and batch_eval; the ASE calculator resizes on overflow, jax-md MD tracks the max selected count per chunk and redoes the chunk with a larger capacity. OpenMM raises NotImplementedError for adaptive models. Cartesian inputs: - Training, eval, BAL, batch_eval and the vesin inference fallbacks use Cartesian positions and Cartesian periodic shifts. Periodic and gas-phase structures share one distance path and can be mixed in a dataset (e.g. bulk together with dimers). The strain F acts on the full edge vector, periodic shift included, as on the jax-md path. - Heads/corrections using absolute positions receive Cartesian positions on the jax-md (fractional) inference path as well. - so3krates keeps periodic self-image pairs, like GMNN and equiv-MP. MD trajectory: frames are flushed only once their chunk is accepted; an overflow redo drops only that chunk's frames (previously all unflushed frames). Neighbor list reallocation now keeps extra_capacity. Tests: finite-difference checks for forces (incl. shadow term) and stress, solver/packing unit tests, self-images under selection, fractional vs Cartesian path consistency, and an end-to-end test (training on bulk + dimers, calculator, overflow, MD). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Adaptive per-atom cutoffs (PET-style) and Cartesian training inputs, on top of apax-hub#565 — the two overlap (stress, self-images), so this targets your branch rather than
main.Adaptive cutoff
Ported from pet-jax (metatrain's "solver" method). Each atom gets a cutoff such that it sees ~
num_neighborsneighbors (smooth counting + cubic baseline, Newton-bisection root find). Pairs within the mean of both atomic cutoffs are kept, tapered to zero at their pair cutoff, and packed into a fixedn_atoms * k_seledge list. Dense environments stay bounded; sparse ones (dimers, molecules, clusters) get cutoffs close tor_max. The goal is to train on e.g. MAD, with bulk and dimers in one dataset.r_maxcutoff function (GMNN incl.FactorizedRadialFunction, equiv-MP, so3krates take an optional per-edgecutoffs). Off by default; nothing changes withoutadaptive_cutoff.k_selis a shape, not saved: sized from the data in training/eval/BAL/batch_eval; the ASE calculator re-sizes on overflow; jax-md MD tracks the max selected count per chunk and redoes the chunk with a larger capacity. OpenMM raisesNotImplementedErrorfor adaptive models.Cartesian inputs
A local model only needs edge vectors, so the training path (and eval, BAL, batch_eval, and the vesin fallback of the ASE/OpenMM calculators) now uses Cartesian positions + Cartesian periodic shifts (
S @ cell, zero in gas phase). Periodic and gas-phase structures share one distance path and can be mixed in a dataset; the "no mixed datasets" check is gone. The jax-md inference paths keep fractional coordinates. Existing checkpoints are unaffected (descriptors see identical edge vectors).dE/dFis kept; on the Cartesian path the deformation acts on the full edge vector incl. shift (F r_ij, jax-md convention, same as your fix).l1/l2heads, latent Ewald) now get Cartesian positions on the jax-md path too; before, training and inference were consistent but both fractional.tests/unit_tests/layers/test_periodic_cells.py: the training-path input helper now builds Cartesian inputs.Also
extra_capacity.Tests
New:
tests/unit_tests/layers/test_adaptive_cutoff.py(solver, packing, FD forces with/without shadow term, FD stress on a triclinic cell, small-cell self-images, continuity),tests/unit_tests/model/test_cartesian_inputs.py(jax-md fractional path == Cartesian path incl. a dipole head),tests/integration_tests/md/test_adaptive_cutoff.py(training on bulk Cu + Cu2 dimers, calculator FD forces, overflow resize, batch_eval, MD overflow redo).Locally (CPU): 136 passed, 2 skipped, 1 xfailed, 5 failed. The 5 failures (
test_ntk_linear, 4×bal/test_api.py::test_kernel_selection) also fail onmodel-improvementsalone. so3krates is untested here (needsmyrto); OpenMM tests not run (openmmnot installed).🤖 Generated with Claude Code