Skip to content

Return unitary vh from dpnp.linalg.svd for singular Hermitian inputs#2954

Merged
antonwolfy merged 4 commits into
masterfrom
return-unitary-vh-from-svd
Jun 18, 2026
Merged

Return unitary vh from dpnp.linalg.svd for singular Hermitian inputs#2954
antonwolfy merged 4 commits into
masterfrom
return-unitary-vh-from-svd

Conversation

@antonwolfy

@antonwolfy antonwolfy commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

dpnp.linalg.svd(..., hermitian=True) could return a non-unitary vh when the input array is singular. In the Hermitian path, the sign of each eigenvalue is factored out of the eigenvectors into vh. The sign was computed with dpnp.sign(s), which returns 0 for zero eigenvalues, zeroing out the corresponding rows of vh and breaking unitarity.

The fix replaces dpnp.sign(s) with dpnp.copysign(1.0, s), which always yields ±1, mirroring the change included into NumPy 2.5.

  • Have you provided a meaningful PR description?
  • Have you added a test, reproducer or referred to an issue with a reproducer?
  • Have you tested your changes locally for CPU and GPU devices?
  • Have you made sure that new changes do not introduce compiler warnings?
  • Have you checked performance impact of proposed changes?
  • Have you added documentation for your changes, if necessary?
  • Have you added your changes to the changelog?

@antonwolfy antonwolfy added this to the 0.21.0 release milestone Jun 18, 2026
@antonwolfy antonwolfy self-assigned this Jun 18, 2026
@github-actions

Copy link
Copy Markdown
Contributor

View rendered docs @ https://intelpython.github.io/dpnp/pull/2954/index.html

@coveralls

Copy link
Copy Markdown
Collaborator

Coverage Status

coverage: 78.092%. remained the same — return-unitary-vh-from-svd into master

@github-actions

Copy link
Copy Markdown
Contributor

Array API standard conformance tests for dpnp=0.21.0dev1=py313h509198e_12 ran successfully.
Passed: 1357
Failed: 3
Skipped: 16

@antonwolfy antonwolfy marked this pull request as ready for review June 18, 2026 12:31

@vlad-perevezentsev vlad-perevezentsev left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM
Thank you @antonwolfy

@antonwolfy antonwolfy merged commit 1f35e57 into master Jun 18, 2026
64 of 85 checks passed
@antonwolfy antonwolfy deleted the return-unitary-vh-from-svd branch June 18, 2026 12:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants