Skip to content

HeteroConv cannot be applied to graphs where some node types only appear as source nodes #10265

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

Open
mayabechlerspeicher opened this issue May 12, 2025 · 0 comments
Labels

Comments

@mayabechlerspeicher
Copy link

🐛 Describe the bug

TransformerConv update rule is supposed to handle nodes with node edges and just transform the nodes with the W1 root transformation.
To separate nodes with neighbors to nodes without neighbors, it applies
if isinstance(x, Tensor): x = (x, x)
At the beggining. Essentially, if x has no neighbors, than x is a tensor instead of a tuple.
This logic fails when wrapping with HeteroConv in senario where nodes only appear as source nodes but not as target nodes, and with at least two layers of convolutions.
This is because HeteroConv iterates over edge types, and only outputs new representations for destination nodes, as filtered at its end:
` out = conv(*args, **kwargs)

        if dst not in out_dict:
            out_dict[dst] = [out]
        else:
            out_dict[dst].append(out)

    for key, value in out_dict.items():
        out_dict[key] = group(value, self.aggr)

    return out_dict`

So on the first layer, nodes that have not incoming edges but only appear as source nodes, will not be transformed at all, and not outputed at all in out_dict for the next layer.
elif src in value_dict or dst in value_dict: kwargs[arg] = ( value_dict.get(src, None), value_dict.get(dst, None), )
Then in the next layer, they will appear as None for the input to the TransformerCov, yet still in a tuple.
Then it fails in the key computation of the conv as x[0] is none.
key = self.lin_key(x[0]).view(-1, H, C)

This result in HeteroConv with TransformerConv not being able to handle graphs where some node types only appear as source nodes.

Versions

2.6.3

@mayabechlerspeicher mayabechlerspeicher changed the title HeteroConv with TransformerConv cannot be applied to graphs where some node types only appear as source nodes HeteroConv cannot be applied to graphs where some node types only appear as source nodes May 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant