Skip to content

Conversation

@ricardoV94
Copy link
Member

@ricardoV94 ricardoV94 commented Dec 10, 2025

The old local_det_chol rewrite is extended to cover more cases of a matrix that is factorized elsewhere, not just with Cholesky, but also LU, LUFactor, or SVD, QR (the latter two only if the sign isn't needed)

A new rewrite is added for the determinant of a factorization itself. The logic is slightly different, for instance det(LUFactor) is non-sensical, and the determinant for some outputs of SVD/ QR can always be computed even if the determinant of the whole factorization cannot.

Also extended the rewrite of log(prod(x)) to sum(log(x)), which should increase the stability of many of these when we want the log determinant (or log(abs(determintant))).

Still missing tests

Closes #1679
Related to #573

[det] = node.outputs
[x] = node.inputs

only_used_by_abs = all(
Copy link
Member Author

@ricardoV94 ricardoV94 Dec 10, 2025

Choose a reason for hiding this comment

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

Any Op that that maps (-1, 1) to the same value is actually fine, At the very least should include square as well

@ricardoV94 ricardoV94 added linalg Linear algebra enhancement New feature or request graph rewriting labels Dec 10, 2025
match core_op:
case Cholesky():
L = client.outputs[0]
new_det = matrix_diagonal_product(L) ** 2
Copy link
Member Author

Choose a reason for hiding this comment

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

TODO: Add the positive tag here.

Possibly also rewrite for log(x ** 2) -> log(x) * 2, when we know x is positive

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

Labels

enhancement New feature or request graph rewriting linalg Linear algebra

Projects

None yet

Development

Successfully merging this pull request may close these issues.

local_det_chol doesn't work

1 participant