-
-
Notifications
You must be signed in to change notification settings - Fork 64
Ignore constant shape dependencies in MarginalModel #226
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks good, just asked a couple questions to check that I understand how it works.
@@ -251,9 +253,24 @@ class FiniteDiscreteMarginalRV(MarginalRV): | |||
"""Base class for Finite Discrete Marginalized RVs""" | |||
|
|||
|
|||
def static_shape_ancestors(vars): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So before pymc-devs/pytensor@0cb5fdb, these Shape Ops would have been caught by a the simple isinstance(var, Constant)
check on line 276?
Now a "constant" shape is one which 1) has no None
s, and 2) has only Shape
Op
ancestors?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Before there wouldn't be any dependency between x -> shape(x) -> y(shape(x)), because shape(x) would just be a constant (so no further edges to x)
"""Test that we don't consider dependencies through "constant" shape Ops""" | ||
x1 = pt.matrix("x1", shape=(None, 5)) | ||
y1 = pt.random.normal(size=pt.shape(x1)) | ||
assert is_conditional_dependent(y1, x1, [x1, y1]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would have guessed this case would fail, because there is a None
in the shape (line 256)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There being a None
is what makes the dependency. We need to see x1
to know what y1
looks like. For the x2/y2 we already know everything there is to know, so there's no dependency
CI started to fail in latest version of PyTensor due to pymc-devs/pytensor@0cb5fdb
Fix by ignoring dependecies when Shape ought to be constant (all static type shape of entries of input are fixed).
Changes should be backwards compatible