aesara-devs / aesara

Aesara is a Python library for defining, optimizing, and efficiently evaluating mathematical expressions involving multi-dimensional arrays.
https://aesara.readthedocs.io
Other
1.18k stars 155 forks source link

Folding graph representation with Textual #938

Open dgerlanc opened 2 years ago

dgerlanc commented 2 years ago

We may want to investigate using Textual or rich to pretty-print aesara graphs. This would make the aesara.dprint output interactive.

With textual, an option may be to have the graphs fold and/or offer filtering capability for different node types.

brandonwillard commented 2 years ago

To illustrate, we're talking about making the following kinds of output interactive:

import aesara
import aesara.tensor as at

x = at.vector("x")
y = at.matrix("y")

z = x + y

aesara.dprint(z, depth=2)
# Elemwise{add,no_inplace} [id A] ''
#  |InplaceDimShuffle{x,0} [id B] ''
#  |y [id C]

For example, if a user selected/clicked the B node in this graph print-out, they would get the following expanded node:


aesara.dprint(z)
# Elemwise{add,no_inplace} [id A] ''
#  |InplaceDimShuffle{x,0} [id B] ''
#  | |x [id C]
#  |y [id D]
rlouf commented 2 years ago

I looked into it, and we want to wait at least until the css branch is merged on their side: https://github.com/Textualize/textual as many things are about to change.

brandonwillard commented 1 year ago

I played around with this a little: aesara-graph-tui-extended

The features demonstrated there involve:

A few features that seem easy to add:

It would be great to get this working with Emacs' comint mode, so that the graph explorer could be used within interactive debugging sessions. This is really the only thing preventing me from considering it as a real day-to-day debug tool.

rlouf commented 1 year ago

It would be nice to be able to jump to the next occurence the current subgraph using a shortcut like n. Other than that I think it's great and is already worth being added to Aesara!