xnn.gnn.constants#

Constants of the GNN potentials that stay exact in float64.

Some values of a model are fixed by its configuration but computed when a block is built, in the default dtype of that moment, and kept as buffers (so most are in the state_dict): Clebsch-Gordan (Wigner-3j) tensors and the bases built from them, radial frequencies, distance-transform and screening constants, the energy scale and shift. A model built in float32 and cast to float64, or loaded from a float32 checkpoint, would carry them float32-rounded, which caps its float64 agreement with an exact evaluation (near 1e-10 for the coupling tensors, 1e-7 for the radial frequencies). exact_float64_constants() rebuilds every float64 one exactly as a float64 build would make it, and GNNPotential calls it after every cast and every load_state_dict. Float32 values are left as built: their rounding is below float32 arithmetic.

Functions

exact_float64_constants(module)

Make the float64 constants of module exact.

register_constant(module, name, value[, ...])

Register value as a floating buffer that stays exact in float64.

restore_exact(buf, exact)

Copy exact into the float64 buf when they differ by rounding only.