Raise error when running inference on elements without fitted element references#1795
Open
Raise error when running inference on elements without fitted element references#1795
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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