Skip to content

Handle Symmetric/Hermitian tangents with other uplo in ProjectTo - #721

Merged
devmotion merged 3 commits into
mainfrom
dmw/symherm-projectto-uplo
Oct 28, 2026
Merged

devmotion merged 3 commits into
mainfrom
dmw/symherm-projectto-uplo

Conversation

@devmotion

Copy link
Copy Markdown
Member

ProjectTo for a Symmetric/Hermitian primal throws when the tangent is a Symmetric/Hermitian that stores the other triangle:

julia> ProjectTo(Symmetric(rand(3, 3), :U))(Symmetric(rand(3, 3), :L))
ERROR: ArgumentError: Cannot construct Symmetric; uplo doesn't match

Because issymmetric holds, the input was rewrapped as Symmetric(dy, project.uplo), which LinearAlgebra refuses for a mismatched uplo (on Julia 1.10 as well as newer versions). Such inputs now go through the existing symmetrizing fallback, so the result has the same value and is stored with the primal's uplo.

The same-uplo path keeps its own return. Merging both into a single type-unstable dz allocated on Julia 1.10, which made the existing @ballocated test fail.

This came up in JuliaDiff/ChainRules.jl, where the Matrix(::HermOrSym) rules are switching to ProjectTo (natural tangents). Under the old rules a mismatched-uplo tangent worked.

Bumps the version to 1.26.6.

🤖 Generated with Claude Code

devmotion and others added 2 commits October 28, 2026 00:01
Projecting e.g. `Symmetric(B, :L)` with the projector of a `Symmetric(A, :U)`
threw `ArgumentError: Cannot construct Symmetric; uplo doesn't match`, since
the already-symmetric input was rewrapped with the primal's uplo. Such inputs
now go through the symmetrizing fallback, so the result is stored with the
primal's uplo.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
@codecov

codecov Bot commented Oct 27, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.50%. Comparing base (0d375e8) to head (ab9f10b).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #721      +/-   ##
==========================================
+ Coverage   93.47%   93.50%   +0.03%     
==========================================
  Files          15       15              
  Lines        1011     1016       +5     
==========================================
+ Hits          945      950       +5     
  Misses         66       66              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Covers the generic `_same_uplo` fallback, which is only reached when the
input is a plain array that already passes issymmetric/ishermitian.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@devmotion
devmotion merged commit 2a1e65e into main Oct 28, 2026
25 of 27 checks passed
@devmotion
devmotion deleted the dmw/symherm-projectto-uplo branch October 28, 2026 09:26
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.

1 participant