Repository navigation
Fix GATConv and GATv2Conv on graphs without edges or nodes - #638
Conversation
|
How would this work if Also, we need the same patch on gatv2. Simply adding a new conditional in |
266475b to
9b794a9
Compare
|
regarding the wrong gradient shape for empty array, do you have any clue why it is happening? ideally the chainrule's projection shouldn't be patched, it should just receive a dx in the correct shape. |
I have absolutely no idea. A hint there is the error only occurs for 0-sized arrays. I think it has something to do with computing gradients and is outside the scope of this package. Edit: Maybe its related to FluxML/Flux.jl#2648 where processing zero-sized array doesn't override an existing cache. I searched Flux.jl, ChainRules.jl (and core), and Zygote.jl and I could not find any suspicious and there is a specific bypass used for |
It could be because of the |
|
could you add the corresponding tests? |
I may have to fix the empty array problem without hacks to Edit: As is, the fix requires a custom version of |
801e0d9 to
a5651b9
Compare
I have added the unit test, but theres something going on with coverage of backpropagation code. |
Sorry for messaging here i am new to julia and wants to start my contribution for Gsoc2027 can you help me where i can start? |
Choose shared vs. separate source/destination projections by dispatch on the input type: this avoids the `xi !== xj` branch that Zygote < 0.7.17 differentiates wrongly, without computing dense_x twice on homogeneous graphs. Drop the explicit stack sizes, which `reshape(_, chout, heads, :)` already handles for zero nodes, and add tests on graphs without edges. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
8ec36fe to
ef9ca35
Compare
Resolves #637.
Fixes
GATConvandGATv2Convon graphs with no edges or no nodes, which is common in heterographs with empty relations:reshape(x, :, size(x, 3))failed when there are no destination nodes. The output is now reshaped to(out * heads, :).unbroadcastFluxML/Zygote.jl#1530). The attention step is now skipped when there are no edges, since its output is zero anyway. No ChainRulesCore patch is needed.GATConvgradient on bipartite input(xj, xi): failed with aDimensionMismatchon Zygote < 0.7.17, which mixed up the cotangents of thexi !== xjbranch (fixed upstream in Sum the cotangents of a branch's arguments only when it is taken FluxML/Zygote.jl#1747). The shared vs. separate projection is now chosen by dispatch on the input type. This works on any Zygote version and still appliesdense_xonly once on homogeneous graphs.Changelog entry (GNNlib, Fixed):
GATConvandGATv2Convno longer fail on graphs, or heterograph relations, without edges or without nodes. TheGATConvgradient on bipartite inputs no longer fails with Zygote < 0.7.17.🧔♂️🤖 Assisted by Claude Opus 5.5