april-tools / cirkit

a python framework to build, learn and reason about probabilistic circuits and tensor networks
https://cirkit-docs.readthedocs.io/en/latest/
GNU General Public License v3.0
71 stars 1 forks source link

Implement folding of tensorized circuits #135

Closed loreloc closed 4 months ago

loreloc commented 11 months ago

When materializing a symbolic circuit, we have to enable the user to choose whether to fold the tensorized circuit or not. This is crucial for efficiency (e.g., when showcasing the library in notebooks).

For now, folding will copy tensors and materialize a new circuit, so it will lose the references to parameters within the circuit computational graph (e.g., the parameters of the circuits on which we compute a product). This would be the fastest way to implement folding in time for the April's workshop.

Later on, we can implement an "einsum symbolic engine" as discussed with Rickey, which will keep track of the parameters in the circuit computational graph and will handle folding accordingly.

What do we need in practice for this issue:

arranger1044 commented 11 months ago

Perhaps better to do this on an abstract symbolic representation of the computational graph and not on a pytorch implementation.