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

Designing ordering of `RGNode` #164

Closed lkct closed 10 months ago

lkct commented 10 months ago

lo-pri unless we're running into problems with this

We'd better have a total ordering of RGNode so that the order of nodes is always static.

A partial ordering that's newly introduced already helps a lot with maintaining RG structure and doing topo sorting. https://github.com/april-tools/cirkit/blob/085d95a408884652c72e5b9be3eb25a1380022e1/cirkit/new/region_graph/rg_node.py#L41-L70

However, the order of RGNode.inputs still needs a clear definition, especially to guarantee that dump and load give a deterministic result. Otherwise saving and loading weights may cause mismatch.

My guess is that preserving the insertion order (which is currently implemented) is enough, but I haven't had a proof.

(PS: how should we tag an open question that requires further investigation like this?)

lkct commented 10 months ago

Current solution as in #171. Assume resolved.