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
Fast Line-Graph-based higher-order edge index for CPU and GPU #132
Conversation
Message Passing
higher-order edge index
Following our discussion of yesterday (and thanks to Moritz' useful pointer to the LineGraph transformation in pyG), I now found a much simpler solution (no for loops, no message passing) that should also be fast ... The following code calculates a k-th-order edge index for a given DAG and maps back the node indices to tensors of first-order node sequences, which preserves the structure and semantics of our higher-order edge indices. Mapping the indices back to tensors of first-order node indices was actually a bit of a head-scratcher, but the function below does this efficiently.
As you see, the code is very simple. Also, I think I have a simple solution how we can do this for an arbitrarily large collection of walks in a single shot. Will push this solution later. I will do some performance tests later. |
So I did some performance tests on the PyG version and the Message Passing (MP) one. The PyG version is very slow on GPU (probably because of some copying between devices due to the for-loop). The message passing version works with random graphs that have about 20 000 nodes and 450 000 edges on my laptop (8GB GPU-RAM) and is almost ten times faster as the PyG version on CPU:
In theory, I was also able to convert the idea behind the code from PyG to torch functions without for-loops (see 497c519). The problem is that I have to construct a (M, M)-Matrix which is even less memory efficient than the MP approach. So in my opinion, the MP approach is still the way to go. Normally for this graph size you would also typically not train a GNN on the whole graph but instead on subgraphs sampled with some kind of Since the |
Thanks a lot for the evaluation, very insightful! I'll have a look later today! |
Correction: I finally found a viable solution that is based on the indexing tricks that are used by
|
Message Passing
higher-order edge index
This PR will eventually add the new implementation idea for the higher-order transformations based on the message-passing framework. For now it is only a proof of concept (in
dag_conv_test.ipynb
) that will be extended at a later time.It is based on the branch from #128 to enable runtime comparisons