-
Notifications
You must be signed in to change notification settings - Fork 176
Open
Labels
Description
Before
Some linear algebra expressions are rewritten into forms like:
`Transpose(Solve(Transpose(A), Transpose(B)))`
These expressions are mathematically correct, and transpose operations are inexpensive views, but they introduce additional graph nodes and complexity
Currently, there does not appear to be a rewrite that simplifies transpose–solve–transpose compositions into a more direct or canonical formAfter
Introduce a graph rewrite that detects transpose–solve–transpose patterns and simplifies them when mathematically valid.
`Transpose(Solve(Transpose(A), Transpose(B)))`
could be simplified into an equivalent but more canonical form without unnecessary transpose layers
This would improve graph readability and consistency with other linear algebra rewritesContext for the issue:
PyTensor already includes several linear algebra graph rewrites in pytensor/tensor/rewriting/linalg.py, including optimizations involving matrix inverse, solve, and transpose operations.
While transpose operations are inexpensive views, simplifying transpose solve transpose compositions would improve graph clarity and align with the broader goal of optimizing symbolic linear algebra expressions.
This could also enable additional downstream rewrite opportunities and improve overall graph simplification.
Reactions are currently unavailable