pymc-devs / pymc

Bayesian Modeling and Probabilistic Programming in Python
https://docs.pymc.io/
Other
8.68k stars 2.01k forks source link

BUG: `make_compute_graph` creates self loop #7397

Open wd60622 opened 3 months ago

wd60622 commented 3 months ago

I did just catch this bug: It comes from the make_compute_graph which causes a self loop

from pymc.model_graph import ModelGraph

coords = {
    "obs": range(5),
}
with pm.Model(coords=coords) as model:
    data = pt.as_tensor_variable(
        np.ones((5, 3)),
        name="C",
    )
    pm.Deterministic("C", data, dims=("obs", None))

error_compute_graph = ModelGraph(model).make_compute_graph() # defaultdict(set, {"C": {"C"}})
# Visualize error:
pm.model_to_graphviz(model)

Result:

compute-graph-bug

Originally posted by @wd60622 in https://github.com/pymc-devs/pymc/issues/7392#issuecomment-2196586849

Moh-bit-coding commented 2 months ago

Take