Skip to content

Fix missing hyperedge weight application in HypergraphConv#10600

Open
Mr-Neutr0n wants to merge 2 commits intopyg-team:masterfrom
Mr-Neutr0n:fix/hypergraph-conv-missing-weight
Open

Fix missing hyperedge weight application in HypergraphConv#10600
Mr-Neutr0n wants to merge 2 commits intopyg-team:masterfrom
Mr-Neutr0n:fix/hypergraph-conv-missing-weight

Conversation

@Mr-Neutr0n
Copy link

Summary

HypergraphConv documents the formula X' = D^{-1} H W B^{-1} H^T X Theta, where W is the diagonal hyperedge weight matrix. However, hyperedge_weight was only used to compute the node degree matrix D -- the weight matrix W itself was never applied to scale the intermediate edge representations between the two message passing steps.

This meant that providing non-uniform hyperedge_weight had an incomplete effect: it influenced the degree-based normalization (D) but did not scale the edge features as the formula requires. This fix applies W to the edge features after the node-to-edge aggregation and before the edge-to-node aggregation, correctly implementing the full formula.

When hyperedge_weight is all ones (the default), behavior is unchanged.

Changes

  • torch_geometric/nn/conv/hypergraph_conv.py: Apply hyperedge_weight to intermediate edge representation between the two propagate calls, with correct reshaping for both attention and non-attention modes.
  • test/nn/conv/test_hypergraph_conv.py: Add test verifying that uniform weights match default behavior, and non-uniform weights produce different (correct) results.

Test plan

  • Existing tests pass (output shapes unchanged)
  • New test verifies uniform weights match default behavior (torch.allclose)
  • New test verifies non-uniform weights produce meaningfully different output

The documented formula for HypergraphConv is:

    X' = D^{-1} H W B^{-1} H^T X Theta

where W is the diagonal hyperedge weight matrix. However, the
implementation only used hyperedge_weight to compute the node degree
matrix D, but never actually applied W to scale the intermediate edge
representations between the two message passing steps.

This meant that passing non-uniform hyperedge_weight had only a partial
effect (via D normalization) rather than the full effect described by
the formula. The fix applies W to the edge features after the first
propagation (node-to-edge) and before the second (edge-to-node),
correctly implementing D^{-1} H W B^{-1} H^T X Theta.

When hyperedge_weight is all ones (the default), behavior is unchanged.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant