You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Browse filesBrowse the repository at this point in the historyBrowse files
Han Wang
committed
refactor: the atomic model answers supports_native_spin, not a descriptor hunt
The native-spin builders reached into the atomic model for a descriptor
(``learned_descriptor``) to decide spin eligibility -- duck-typing that
assumes a descriptor+fitting architecture, guesses which child of a
composition is the learned one, and cannot answer at all for an atomic model
with no descriptor. Same mistake the ``supports_graph_route`` detour made:
the capability belongs ON the atomic model.
``supports_native_spin()`` is now the twin of ``uses_graph_lower()``:
concrete ``False`` on ``BaseAtomicModel``; ``DPAtomicModel`` delegates to its
descriptor; ``LinearEnergyAtomicModel`` answers from its children. Both
builders just ask the atomic model, and ``learned_descriptor`` is gone.
``DPAtomicModel`` already cached the answer, but as a bool ATTRIBUTE -- which
is exactly why reaching for the descriptor looked necessary, since an
attribute cannot be overridden polymorphically by the base or by a
composition. It becomes a method backed by the private
``_supports_native_spin``, so the per-forward hot path still avoids a
descriptor call.
The composition uses ANY, deliberately unlike ``uses_graph_lower``'s ALL:
every child must run on the shared graph, but spin only has to reach ONE
consumer -- analytical terms accept and ignore it. With no consumer the
magnetic force is identically zero, which is not a spin model; pinned by a
test that a two-ZBL composition reports False.
0 commit comments