Skip to content

Allow access to solve_triangular in pt.linalg #291

Closed
@jessegrabowski

Description

@jessegrabowski

Description

The current depreciation warning for pt.slinalg.solve_lower_triangular and pt.slinalg.solve_upper_triangular directs the user to use pt.linalg.solve, but the specialized LAPACK triangular solver implemented in scipy.linalg.solve_triangular (TRTRS) is not accessible via any combination of arguments to pt.linalg.solve.

Currently, if one of the inputs to pt.linalg.solve is a Cholesky node, it will be replaced with a solve Op with assume_a='sym'. This invokes the SYSV routine, which is not the same as TRTRS. It'd be nice to speed test these two routines and make sure pytensor is using the faster one by default. If SYSV is faster in all cases, it doesn't make sense to have a solve triangular routine at all, so a priori I suspect it's not.

Anyway, I would suggest the function pt.slinalg.solve_triangular be exposed in pt.linalg, and the depreciation warning changed to direct users to this function. This would match the scipy API.

Another alternative would be to add an additional option for assume_a in pt.linalg.solve for triangular matrices, and add some additional control flow inside pt.slinlag.Solve.perform that would route to scipy.linalg.solve_triangular if assuma_a == 'triang'. The disadvantage here is that the API would not longer follow that of scipy.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions