rgpycrumbs.uma._key¶
Cache key of one UMA AOTI package.
A package is reusable only when every input that shaped the compiled
graph matches: the exact composition, charge, spin multiplicity and task
head (merge_mole folds them into the weights), the checkpoint, the
tracing dtype and the static-shape options (molecular box, band size),
and the compiler side (device, its CPU ISA or CUDA compute capability,
and the torch and fairchem versions).
Attributes¶
Classes¶
Functions¶
|
Return |
|
Return gcd-reduced |
|
Hill-order formula of |
|
Total electrons of the system: sum(Z) - charge. |
|
Minimal spin multiplicity consistent with electron parity. |
|
Raise when |
|
Stable text for a float option: |
|
|
|
Build the package key for a system and an export environment. |
Module Contents¶
- rgpycrumbs.uma._key.TARGET_FIELDS = ('AOTI_MACHINE', 'AOTI_CPU_ISA', 'AOTI_COMPUTE_CAPABILITY')[source]¶
- rgpycrumbs.uma._key.exact_counts(atomic_numbers: collections.abc.Iterable[int]) tuple[tuple[int, int], Ellipsis][source]¶
Return
(Z, count)pairs, sorted by Z, without reduction.An AOTI export freezes per-atom buffers at the example system’s size, so a package compiled for C2H2 aborts inside the compiled graph when fed C4H4 even though fairchem
merge_moletreats the two as the same reduced composition. The cache key therefore uses the exact composition, never the gcd-reduced one.
- rgpycrumbs.uma._key.reduced_counts(atomic_numbers: collections.abc.Iterable[int]) tuple[tuple[int, int], Ellipsis][source]¶
Return gcd-reduced
(Z, count)pairs, sorted by Z.Fairchem
merge_molecompares reduced compositions: C2H2 and C4H4 both reduce to((1, 1), (6, 1)). This is the model-side equivalence for expert merging; it is NOT sufficient to reuse an AOTI package (seeexact_counts()).
- rgpycrumbs.uma._key.hill_formula(counts: collections.abc.Iterable[tuple[int, int]]) str[source]¶
Hill-order formula of
(Z, count)pairs, e.g.CHNorC2H2.
- rgpycrumbs.uma._key.electron_count(atomic_numbers: collections.abc.Iterable[int], *, charge: int = 0) int[source]¶
Total electrons of the system: sum(Z) - charge.
- rgpycrumbs.uma._key.minimal_spin(atomic_numbers: collections.abc.Iterable[int], *, charge: int = 0) int[source]¶
Minimal spin multiplicity consistent with electron parity.
Even electron count gives a singlet (1); odd gives a doublet (2).
- rgpycrumbs.uma._key.validate_spin(atomic_numbers: collections.abc.Iterable[int], *, charge: int = 0, spin: int = 1) None[source]¶
Raise when
spincannot hold the system’s electron count.Multiplicity is
2S + 1: an even electron count admits only odd multiplicities, an odd count only even ones, andNelectrons reach at mostN + 1. A mismatch (for example a 23-electron radical declared a singlet) selects an unphysical PES from a spin-conditioned model.
- rgpycrumbs.uma._key.canonical_float(value: float) str[source]¶
Stable text for a float option:
25.0and25both give25.
- class rgpycrumbs.uma._key.ExportEnv[source]¶
Compiler side of a package: what the exporting interpreter builds for.
deviceiscpuorcuda.targetjoins, with|, the fields torch records in the package metadata for the machine it compiled on (TARGET_FIELDS): the architecture, the CPU vector ISA and, for CUDA, the compute capability. A package built for another target fails to load or runs illegal instructions.
- class rgpycrumbs.uma._key.AotiKey[source]¶
Identity of one compiled UMA package.
- as_dict() dict[str, Any][source]¶
JSON-ready form;
from_dict()inverts it exactly.
- classmethod from_dict(data: collections.abc.Mapping[str, Any]) AotiKey[source]¶
- rgpycrumbs.uma._key.aoti_key(atomic_numbers: collections.abc.Iterable[int], env: ExportEnv, *, charge: int = 0, spin: int | None = None, task: str = 'omol', model: str = 'uma-s-1p1', dtype: str = 'float32', molecular_box: float = 0.0, batch_max: int = 0) AotiKey[source]¶
Build the package key for a system and an export environment.
spin=Nonederives the minimal multiplicity from electron parity; an explicitspinis validated against it.batch_maxof 0 and 1 both mean a single-system package.