Open ricardoV94 opened 7 months ago
This was something on the Theano team's radar, I think at least one of the original devs was interested in piggy-backing on sympy for this purpose. See this blog post, for example.
I also think this is a place where Eggs could really shine. See their symbolic algebra example here, it might be a good place to start?
I would say easiest place to start is to just curate from the rewrites we already have. After that I'm confident egglog could be nice for better simplifications.
Given how easy it is to write egglog rewrites I would lean to bypass sympy completely.
Yes, I don't like adding a sympy dependency either. It's non-trivial to switch between representations (sympy and pytensor), mostly because of broadcasting stuff. From my own experience, it would be easier to just start fresh on our side.
This does tie into the discussion we were having on #573 though, because algebraic rewrites might need more information about variables in order to execute. For example, $(x^a)^{\frac{1}{a}}$ can be rewritten to $x$, but only if we know x is non-negative.
Description
As discussed in https://github.com/pymc-devs/pytensor/discussions/637 PyTensor is geared mostly towards computational efficiency, although the same machinery could be easily tuned for symbolic simplification.
We could create a database of rewrites just for that goal