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
Intel/rect hgam homo and hetero - draft for HGAM based on rectangular adj matrix in homogeneous and heterogeneous case (CSR only) #8897
base: master
Are you sure you want to change the base?
Conversation
…hierarchical_sage.py example
…y matrix for Heterogenous data
for more information, see https://pre-commit.ci
for more information, see https://pre-commit.ci
…andreazanetti/pytorch_geometric into intel/rect_hgam_homo_and_hetero
for more information, see https://pre-commit.ci
The PR makes sense to me. I would prefer to make this behavior optional though ( |
Thanks for your feedback!
I initially thought that the issues with pyg operators would be connected to the need of "narrowing" the feature vector x in all those cases of operators in which the original node representation in input is reused directly to compute the final (new) output node representation (I guess when I am not clear how making the adj_mat rectangular would affect pyg operators in other ways.
Hope it makes sense. |
Sorry, I was solely talking about homogeneous case (so please ignore my comment). For heterogeneous, we can just do (c). |
Thanks Matthias. a) for homogeneous data you would like the user to be free to choose from the 3 options above Did I get your thinking right? |
Yes, that is what I had in mind, but please feel free to drop (b) completely if you feel it is unnecessary. |
Hi, thanks for the feedback. Currently, using HGAM requires the user to pass the HGAM metadata explicitly to the model. First Part: Second Part: Please share your thoughts, thanks! |
I am going on with the first part as per above. |
@andreazanetti I see. Do you think we need to update all the layers in order to support HGAM++? Would bipartite input not be an option as well? |
Hi Matthias, thanks for your reply. Pretty much like we do here in sage_conv.py: And looking at the code in torch_geometric/nn/conv it looks to me that most of them are. Now, I am not sure I understand how making the input bipartite would help. Apologies, I do not see it :) |
Got it. Initially, I assumed we can just do |
Oh, thanks @rusty1s, I did not realize that we could leverage the presence of
So with my definitions above, I guess the conv call should look like: |
I went on and modified _trim_to_layer.py and other things to support the It works fine for homo, I have tested with hierarchical_sampling.py example. One epoch training without Hierarchical Graph Sampling: (NO HGAM) One epoch training with Hierarchical Graph Sampling: (WITH HGAM rect_adj_mat) However, for the hetero case it is a bit more delicate. |
…andreazanetti/pytorch_geometric into intel/rect_hgam_homo_and_hetero
for more information, see https://pre-commit.ci
The hetero case seems to work now. HGAM False ==> 20.09it/s In this approach, for my convenience I commented out the part connected to |
Updating the tests for trim_to_layer I realized that the support for HGAM with rectangular adj matrix for CSR (hetero and homo) broke the HGAM with square matrix for COO, hetero and homo (which is the only one we are planning to support for COO) UPDATE: no, I have found other issues with the cohesistence of HGAM with square adj matrix for COO and HGAM with rectangular adjacency matrix for CSR. I will get back to this as soon as possible. |
Sharing this code just to discuss the idea.
Not to be merged.
As per the title, this is a draft of the rectangular adj matrix HGAM implementation -for homogeneous and heterogenous data, CSR flow- which computes only the representations needed to proceed with the next step in the computation of the GNN.
Overall idea for rect adj HGAM
The overall idea is about identifying 2 sets of nodes at each layer.
S1: The set of nodes which are necessary for the computation of the sought nodes representation at that layer (our "inputs")
S2: The set of nodes which we need to compute a new representation for (our "outputs")
S2 is a subset of S1 in general (at least assuming that the current representation of each node is used to compute its next layer representation)
Therefore S1 populates the columns of adj_t, whereas S2 populates the rows of adj_t (edge_index)
In the HGAM current implementation in PyG, at each layer we identify S1 and the representations for all the nodes in S1 are computed, since we use a square adj matrix, which gets trimmed as we proceed through the layers, moving from S1 at a layer to the S1 of the next layer. That is why in the current implementation HGAM does not act
if layer == 0
, because all the nodes in the batch graph are in S1, at the first layer.Although that approach is not optimal, it is much better than computing representations for all nodes in the graph batch at all layers.
Optimality is reached when at each layer we compute only the representations for nodes from the S2 set, for that layer (which will become S1 for the next layer).
That is what we are doing here in the case of homo (and hetero as well), sage_conv, CSR.
Hope it makes sense.
Thanks in advance for your comments.
Contributors: @rBenke (robert.benke@intel.com)