Skip to content

[MRG] Stabilize non-Torch matrix square roots for rank-deficient covariances - #900

Open
Nikhila-Dhevi-R wants to merge 1 commit into
PythonOT:masterfrom
Nikhila-Dhevi-R:codex/issue-889-sqrtm-stability
Open

Nikhila-Dhevi-R wants to merge 1 commit into
PythonOT:masterfrom
Nikhila-Dhevi-R:codex/issue-889-sqrtm-stability

Conversation

@Nikhila-Dhevi-R

@Nikhila-Dhevi-R Nikhila-Dhevi-R commented Oct 22, 2026 •

Copy link
Copy Markdown

Types of changes

  • Bug fix
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Motivation and context

Addresses #889. Positive semi-definite covariance matrices can produce tiny negative eigenvalues from numerical roundoff. Taking their square root in the NumPy, JAX, CuPy, and TensorFlow backends then creates NaNs, which can make Gaussian Wasserstein computations fail. The Torch backend already clamps these eigenvalues before the square root.

Changes

  • Clamp roundoff-negative eigenvalues before the non-Torch backend matrix square roots.
  • Add a rank-deficient covariance regression test covering finiteness and reconstruction.
  • Update the ill-conditioned empirical Bures-Wasserstein mapping regression to assert finite output.
  • Add a 0.9.8 development release note.

The singular-source mapping semantics remain unchanged; this patch addresses the numerical roundoff failure in the matrix square root.

How has this been tested (if it applies)

  • Focused backend and Gaussian tests: 47 passed, 3 skipped.
  • Full source suite: 1,519 passed, 139 skipped, 4 xfailed; the only failure was the standalone OpenMP helper probe because the local Windows environment lacks Microsoft C++ 14+ build tools.
  • Pre-commit: Ruff and codespell passed. The repository-wide Yamllint hook reports existing CRLF/newline issues in unchanged YAML files.

PR checklist

  • I have read the CONTRIBUTING document.
  • The documentation is up-to-date with the changes I made (check build artifacts).
  • Additional code has been covered with new tests.
  • I have added the PR and Issue fix to the RELEASES.md file.

@codecov

codecov Bot commented Oct 23, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.00%. Comparing base (5cb82c9) to head (97d7614).

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #900      +/-   ##
==========================================
- Coverage   97.00%   97.00%   -0.01%     
==========================================
  Files         130      130              
  Lines       26842    26849       +7     
==========================================
+ Hits        26039    26045       +6     
- Misses        803      804       +1     
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant