Conversation
N-0-MAD
force-pushed
the
fix-psd-solve-vector-rhs
branch
from
September 14, 2026 22:16
c3dd806 to
a3ad4bf
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
I fixed
psd_solve_to_chol_solveso that it rewrites positive-definiteSolveoperations with a vector right-hand side (b_ndim=1) to use a Cholesky decomposition.Previously,
psd_solve_to_chol_solveonly matchedSolveoperations withb_ndim=2. As a result, PyTensor left a vector solve such as:as a
Solveoperation. This prevented the optimizer from reusing the Cholesky decomposition when the same matrix also appeared in a Cholesky-based expression such as a log-determinant.I updated the rewrite to:
b_ndim=1andb_ndim=2.b_ndimwhen constructing the triangular solves.bto(n, 1).I inspected the underlying
SolveBase,CholeskySolve, andSolveTriangularimplementations. They already support bothb_ndim=1andb_ndim=2.I also tested the existing
b[:, None]workaround. It successfully triggered theb_ndim=2rewrite and produced a Cholesky-based graph.I extended the existing
test_psd_solve_with_choltest to parameterize over bothb_ndim=1andb_ndim=2, preserving the existing matrix coverage while adding regression coverage for vector RHS inputs.Related Issue
Checklist
Type of change