-
Notifications
You must be signed in to change notification settings - Fork 20
Description
Hi yahooers! Thanks for this very helpful software. I noticed one issue at graph merging, seems like a bug. I have version 1.2.4
Scenario:
- Define
graph1 = abs(a + (a * b))**3, with operations named(mul1, sum1, abspow1) - Define
graph2 = abs(a + (a * b))**2, with operations named(mul1, sum1, abspow2) - Merge via
graphkit.compose(name="graph3", merge=True)(graph1, graph2) - Both
sum1operations have same name, but crucially different output names abspow1depends onsum1, andabspow2depends onsum2
In this scenario, two options would be acceptable when evaluating the merged graph:
- Merge just
mul1(same name AND interface) and leave the rest as independent branches - Merge also
sum2intosum1, and makeabspow2 point tosum1`
But what is happening is that both the second sum1 and abspow2 are being dropped, without any warning or exception thrown. Also, the squared output of abspow2 is missing from the merged graph's output.
I assume the reason is that the merged graph can't fullfil abspow2's interface after sum1's "faulty" merge and is dropping it silently... Is this behaviour expected? The docs are pretty clear about the "merging by name process", but I feel like this scenario could be problematic if a user inadvertently messes up the interfaces, and whole branches of the graph are dropped.
In case this is unexpected, these could be 2 possible approaches:
- Maybe throwing something like an
InterfaceConfictErrorand dismissing the merge (more conservative) - Make all nodes that pointed to
sum2point tosum1after they merge, regardless of their interface (would require some assumptions on the interface or potentially a redesign of the whole library into a statically typed, TF-ish ̶n̶i̶g̶h̶t̶m̶a̶r̶e̶ experience)
I uploaded a unittest with a reproducible example into this gist, It is in the test_graph_merge_dropping method. Let me know if I can be of any help via PR.
Cheers,
Andres