NeuralILBackend¶
- class jaxrens.backends.neuralil.NeuralILBackend(model_params, r_cutoff, sorted_elements, supercell_trafo, n_max, embed_d, core_widths, is_ensemble, has_morse, n_ensemble=1, energy_shift_per_atom=0.0, morse_type='RepulsiveMorse', softcore=False, softcore_kwargs=None)[source]¶
Bases:
objectNeuralIL energy backend for jaxrens.
The dynamics model is built once at construction time.
max_neighborsis a runtime call-time argument (static at trace time) that shapes the neighbor-buffer slice inside the descriptor generator.Single-model and ensemble checkpoints are both supported; the layout is selected via
is_ensembleand the energy is reduced accordingly (.mean()over the ensemble axis, identity for a single model).- Parameters:
- property atomic_numbers: tuple[int, ...]¶
Atomic numbers (Z) of the elements the model was trained on, in the same order as
sorted_elements. Used by the resolver to map user-supplied Z numbers instart_speciesto the model’s contiguous 0-based type indices.
- energy_and_forces(positions, species, cell, max_neighbors=50, ensemble_params=None)[source]¶
Native energy + forces via NeuralIL’s
calc_potential_energy_and_forces.Every dynamics-model variant (single / Morse / soft-core / ensemble) exposes
calc_potential_energy_and_forces, returning(energy, forces)withforces = -dE/dx. The soft-core and Morse terms are included because the differentiatedcalc_potential_energyruns through the same (overridden)calc_atomic_energiesas__call__.For an ensemble the model returns per-member energies
(n_ensemble,)and forces(n_ensemble, N, 3); both are reduced by mean to match the committee prediction used in__call__. The per-atom energy shift is a constant and is added to the energy only — it does not affect forces.- Parameters:
- Return type:
- members(positions, species, cell, max_neighbors=50, ensemble_params=None)[source]¶
Per-committee-member energies and forces (for uncertainty).
Like
energy_and_forces()but keeps the per-ensemble-member axis: populates the reservedenergy_members(M,)andforces_members(M, N, 3)slots, in addition to the reducedenergy/forcescommittee means and the control fields.For a single (non-ensemble) model
M = 1(a leading axis is added) so the(M, …)shape contract holds uniformly and the committee spread is exactly zero. The per-atom energy shift is added to every member, preserving the invariantenergy == energy_members.mean()(the shift is constant across members, so it does not affect the std).- Parameters:
- Return type:
- energy_members(positions, species, cell, max_neighbors=50, ensemble_params=None)[source]¶
Per-committee-member total energies, shape
(M,)— no forces.The cheap path for energy-only uncertainty: skips the force jacobian that
members()computes. Single (non-ensemble) model →(1,). The per-atom shift is added to every member (constant; irrelevant to the committee std, kept for absolute-scale consistency).
- max_neighbors_for(positions, cell)[source]¶
Geometry-only per-walker max neighbor count.
Mirrors MACE’s same-named method (
mace.py:224-237) so the resolver’s_finalise_initial_energies_and_countscan take the bucket-aware branch instead of falling through to themax_neighbors=0path. No NeuralIL forward pass is triggered — the result is a static-shape buffer sizing hint derived purely from coordinates + the model’s r_cutoff + supercell_trafo.Pass dummy zero
speciessince neighbor counting depends only on positions and the cutoff (species enter only through a padded-atom mask which_get_max_number_of_neighborsignores for length-N inputs).- Parameters:
positions (Array)
cell (Array)
- Return type:
Array