Skip to content

Use scale-relative tolerance for null-mode filtering - #437

Merged
harryswift01 merged 2 commits into
mainfrom
436-general-review-numerical-robustness
Oct 7, 2026
Merged

harryswift01 merged 2 commits into
mainfrom
436-general-review-numerical-robustness

Conversation

@harryswift01

@harryswift01 harryswift01 commented Oct 5, 2026 •

Copy link
Copy Markdown
Member

Summary

This PR is one step towards resolving #436, regression tests intermittently failing on CI but passing on rerun. It fixes a genuine numerical bug in the entropy calculation's null-mode filtering. This is not a complete fix for #436, some intermittent failures may still occur from a separate, unrelated cause that will be addressed separately.

Changes

Scale-relative null-mode filtering in vibrational entropy

  • Uses a symmetric eigensolver (numpy.linalg.eigvalsh) instead of a general one, since the matrices involved are always symmetric.
  • Replaces a fixed near-zero tolerance with one scaled to the eigenvalue spectrum's own magnitude, the same approach numpy.linalg.matrix_rank uses to separate numerical noise from a genuine near-zero value.
  • Updates a regression baseline and its unit tests that had been relying on the old, fixed-tolerance behaviour.

Impact

  • Fixes a case where numerical noise was being counted as a real physical contribution to entropy, producing an inflated result.
  • No other behavioural changes intended; CodeEntropy's own calculation logic is otherwise unchanged.
  • Some intermittent CI failures may persist after this PR, from a separate cause being tracked and addressed separately.

@harryswift01 harryswift01 added this to the 2.5.0 milestone Oct 5, 2026
@harryswift01 harryswift01 self-assigned this Oct 5, 2026
@harryswift01 harryswift01 added the bug Something isn't working label Oct 5, 2026
@harryswift01 harryswift01 changed the title Use scale-relative tolerance for null-mode filtering in vibrational entropy Use scale-relative tolerance for null-mode filtering and pin OpenBLAS in CI Oct 6, 2026

@jimboid jimboid left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This fix looks like it will fix the issue with random failing tests. One thing to note, pinning coretype to haswell like that has unintended consequences. Haswell is intel chip architecture, does it fail gracefully on arm and amd chips which are becoming more common on cluster machines and cloud?

@skfegan skfegan left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like it will work. It makes sense to take advantage of the symmetry of the matrices.

@harryswift01
harryswift01 force-pushed the 436-general-review-numerical-robustness branch 2 times, most recently from 63ed82c to 182cda5 Compare October 6, 2026 15:22
@harryswift01

Copy link
Copy Markdown
Member Author

This fix looks like it will fix the issue with random failing tests. One thing to note, pinning coretype to haswell like that has unintended consequences. Haswell is intel chip architecture, does it fail gracefully on arm and amd chips which are becoming more common on cluster machines and cloud?

I agree with this, I'm not 100% happy with this direction either so what I have done for now is reverse the pinning of the coretype and just left the initial fix. I've done this because I have done some more digging around and I have identified that there is a similar issue in MDAnalysis's principal_axes code, specifically it uses np.linalg.eig instead of np.linalg.eigh on a matrix that's always symmetric, which is the exact same class of numerical instability as the fix in this PR. MDAnalysis have already identified and fixed this themselves (switching to eigh), but have yet to release a version containing the fix. Once that version is out, I think we should stop seeing these intermittent failures.

@harryswift01 harryswift01 changed the title Use scale-relative tolerance for null-mode filtering and pin OpenBLAS in CI Use scale-relative tolerance for null-mode filtering Oct 7, 2026
@jimboid

jimboid commented Oct 7, 2026

Copy link
Copy Markdown
Member

sounds good to me. Sarah is happy to too, so think you should merge.

@harryswift01
harryswift01 merged commit 7aca8ac into main Oct 7, 2026
23 checks passed
@harryswift01
harryswift01 deleted the 436-general-review-numerical-robustness branch October 7, 2026 13:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[General]: Review numerical robustness of eigensolver usage in entropy/axes calculations

3 participants