Skip to content

Conversation

@ricardoV94
Copy link
Member

Follow up to #66

else:
# populate search otherwise
# it is a new independent node not present in ancestors to include
if dependent:
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed the order of the ifelse, but not the logic

@ricardoV94 ricardoV94 force-pushed the fix_truncated_graph_inputs_bug branch from 5b60ca2 to f53e356 Compare December 13, 2022 09:08
trunc_inp2 = MyOp(x, y)
trunc_inp2.name = "trunc_inp2"

o = MyOp(trunc_inp1, trunc_inp1, trunc_inp2, trunc_inp2)
Copy link
Member Author

@ricardoV94 ricardoV94 Dec 13, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There seems to be another problem with nested inputs:

The following asserts are what the function returns. Which one is correct, and why is it order dependent?

def test_truncated_graph_inputs_repeated_nested_input(): """Test that truncated_graph_inputs does not return repeated inputs.""" x = MyVariable(1) x.name = "x" y = MyVariable(1) y.name = "y" trunc_inp = MyOp(x, y) trunc_inp.name = "trunc_inp" o1 = MyOp(trunc_inp, trunc_inp, x, x) o1.name = "o1" assert truncated_graph_inputs([o1], [trunc_inp]) == [x, trunc_inp, y] o2 = MyOp(x, x, trunc_inp, trunc_inp) o2.name = "o2" assert truncated_graph_inputs([o2], [trunc_inp]) == [trunc_inp, x]

It seems to me it should return [x, y]?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Order is graph traversal dependent. Closer nodes depth first appear first

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The correct should not include y

Copy link
Member Author

@ricardoV94 ricardoV94 Dec 13, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A subgraph must have independent inputs to be valid. trunc_inp depends on x, so they can't both be inputs? Or am I thinking wrong here about what truncated_inputs should mean?

Copy link
Member

@ferrine ferrine Dec 13, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

trunc_inp is declared as ancestors_to_include, therefore, other added variables should not depend on them. Yes, trunc_inp depends on x but not vice versa and x is absolutely valid to include. All the above dependencies are assumed to be totally ignored, treat as setting var.owner=None. Logic should be

  • Include ancestors_to_include anyway, but exclude disconnected
  • Include the rest variables eagerly as soon as they do not depend on ancestors_to_include
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This means we need to check candidates in topological order no?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmmm

Copy link
Member

@ferrine ferrine Dec 13, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

candidates start with outputs, not ancestors_to_include, which I did not sort topologically, thus can affect now

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What affected in your test case is the order op.inputs, which is not topological, right?

Copy link
Member

@ferrine ferrine Dec 13, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did not realise how non topological order of op.inputs can break the set of outputs yet...

@ricardoV94 ricardoV94 added the bug Something isn't working label Dec 13, 2022
@ricardoV94 ricardoV94 marked this pull request as draft December 13, 2022 09:20
@ricardoV94 ricardoV94 added help wanted Extra attention is needed and removed no releasenotes labels Dec 13, 2022
It could return duplicated truncated inputs before the changes, as well as return wrong outputs based on the nodes input order
@ricardoV94 ricardoV94 force-pushed the fix_truncated_graph_inputs_bug branch from f53e356 to 16c28c6 Compare December 13, 2022 13:49
@ferrine ferrine marked this pull request as ready for review December 13, 2022 15:15
@ferrine
Copy link
Member

ferrine commented Dec 13, 2022

@ricardoV94 once you feel finished, you can merge

@ricardoV94 ricardoV94 merged commit 21d723b into pymc-devs:main Dec 13, 2022
@ricardoV94 ricardoV94 removed the help wanted Extra attention is needed label Dec 13, 2022
@ricardoV94 ricardoV94 deleted the fix_truncated_graph_inputs_bug branch January 20, 2023 13:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

2 participants