Skip to content

Raise error when running inference on elements without fitted element references#1795

Open
lbluque wants to merge 1 commit intomainfrom
raise-error-untrained-atoms
Open

Raise error when running inference on elements without fitted element references#1795
lbluque wants to merge 1 commit intomainfrom
raise-error-untrained-atoms

Conversation

@lbluque
Copy link
Contributor

@lbluque lbluque commented Feb 18, 2026

Summary

Add NaN-based detection in ElementReferences.compute_references that raises a clear ValueError when input data contains elements with no fitted references, indicating the model was not trained on those elements.
Change fit_linear_references to initialize unfitted element coefficients to NaN (instead of zero) so untrained elements are distinguishable from elements with a legitimately fitted zero reference.
Replace the previously skipped test_element_references.py with 6 new working tests covering both error and success paths.

Motivation

Previously, running inference on a system containing elements the model was never trained on would either silently produce incorrect predictions (the reference contribution for that element would be zero, which is wrong) or crash with an opaque CUDA/index error if the atomic number exceeded the embedding table size. This change ensures users get a clear, actionable error message identifying exactly which atomic numbers are unsupported.

TODO

  • Insert NaN values to element reference files on HF.

@lbluque lbluque requested a review from rayg1234 February 18, 2026 20:11
@meta-cla meta-cla bot added the cla signed label Feb 18, 2026
@lbluque lbluque requested a review from wood-b February 18, 2026 20:11
@lbluque lbluque added enhancement New feature or request minor Minor version release labels Feb 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla signed enhancement New feature or request minor Minor version release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant