Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

solve_triangular gradients are wrong for certain options #1230

Open
jessegrabowski opened this issue Feb 21, 2025 · 0 comments
Open

solve_triangular gradients are wrong for certain options #1230

jessegrabowski opened this issue Feb 21, 2025 · 0 comments
Assignees
Labels
bug Something isn't working linalg Linear algebra SciPy compatibility

Comments

@jessegrabowski
Copy link
Member

Description

Right now we assume the inputs to solve_triangular are always consistent with the settings passed to the function. For example, if one sets lower, we assume that the incoming matrix really is lower triangular. If you set unit_diag, we assume there are ones on the diag, and so on.

This isn't actually how the function works. If you set unit_diag for instead, the main diagonal is simply ignored in computation; the function doesn't care whether it literally is unit diagonal or not. This is useful when working with LU factors for example. Instead of storing L (lower with unit diagonal) and U (upper) separately, it is common to store LU = tril(L, k=-1) + triu(U). Then solve_triangular(LU, b, lower=True, unit_diagonal=True) is exactly equivalent to doing solve(L, b) -- no need rebuild the individual matrices.

At the moment the analytical gradients don't take this into account, so setting unit_diag=True on a non-unit-diagonal matrix will have non-zero diagonal sensitivites, which is wrong.

Gradients are also incorrect when trans != "N", because we have no special logic in SolveBase.L_op to handle the transpose argument (see #1229)

@jessegrabowski jessegrabowski added bug Something isn't working linalg Linear algebra SciPy compatibility labels Feb 21, 2025
@jessegrabowski jessegrabowski self-assigned this Feb 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working linalg Linear algebra SciPy compatibility
Projects
None yet
Development

No branches or pull requests

1 participant