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

Product of 3 circuits fails #212

Closed lkct closed 4 months ago

lkct commented 8 months ago

Currently ProdEFLayer and EFProdReparam is only designed for two same inputs (underlying constraint is same suff stats). This makes the product of 3 circuit impossible, i.e., the product of two is different from the third (yet 4 arranged in a balanced binary tree can still work)

This should be fixed and included in the tests. Example test case based on test_product.py:

    # imbalanced, currently fails
    product_circuit = circuit1 @ circuit2 @ circuit3 @ circuit4
    # balanced, currently works
    product_circuit = (circuit1 @ circuit2) @ (circuit3 @ circuit4)

This also relates to #210. Maybe we should consider overhaul the ProdEFLayer and this may automatically fixed after refactoring the design as discussed in #210

loreloc commented 4 months ago

The product of an odd number of circuits seems to be working now. So, I am closing this.