-
Notifications
You must be signed in to change notification settings - Fork 310
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
nx-cugraph
: support should_run
that was added in NetworkX 3.3
#4348
Conversation
@rlratzel, do you think we should add |
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'm looking forward to having some should_run()
s in place - I think that will result in a decent performance boost for no-code-change cases involving smaller graphs. (well, I should say a performance boost compared to not having should_run()
s when nx-cugraph
is installed)
if nx.__version__[:3] <= "3.2": | ||
name = f"complete_bipartite_graph({orig_n1}, {orig_n2})" | ||
else: | ||
name = f"complete_bipartite_graph({n1}, {n2})" |
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'm curious what name
is used for and why it has to be different for newer versions of NX. From looking at from_coo()
, I think name
is an attr that is applied to the new graph object, but I didn't notice how it's used from there. Would a brief comment be out-of-place here?
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.
Here is context for posterity: networkx/networkx#7399
def _(G, nodes=None): | ||
if nodes is None or nodes not in G: | ||
return True | ||
return "Fast algorithm when computing for a single node; not worth converting." |
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.
For this and other should_run
s: does should_run
get called if the user passes in a backend graph (which does not need converting)? I remember we honor backend=
regardless of can/should_run, but is passing a backend graph treated as if a user set backend=
precedence-wise?
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.
should_run
is only used when the graph needs to be converted. Hence, should_convert_and_run
would be a more accurate name, but I as recall you liked the shorter name should_run
. The backend algorithm will always be used if a backend graph if passed or backend=
argument is used.
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.
@eriknw and I talked about this offline. The use case I was envisioning was one where should_run
implementations can choose whether or not a backend algorithm is not ideally applied to a particular set of inputs, regardless of if the graph has been converted. For example, if a backend is optimized for very large graphs and the graph is already converted but very small, that backend may choose to let other backends run by returning False
for should_run
.
@eriknw pointed out that a backend graph, in that situation, would have to be converted to another backend graph type (backend-to-backend) or to a NX graph (backend-to-nx) in order to continue, and neither of those are currently supported. So for now, should_run
only applies to calls that require a conversion.
Yes, those might be good but |
Thanks @rlratzel. I added To try to follow DRY principle, I'm considering an enhancement to add a module that has a collection of I also wonder about when an input graph already has a pre-converted backend graph. If it does, then should |
I personally like giving more autonomy to backends to make decisions that are best for them. Similar to my initial thought of having the dispatcher call |
/merge |
Also, update
complete_bipartite_graph
for nx devedit:
This does not yet add per-algorithmshould_run
, but it makes doing so possible.Add
should_run
fortriangles
,clustering
,is_isolate