Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ Entries link to the pull request that introduced them.
- Added a `Mooncake` package extension, so that Mooncake can differentiate on CUDA through `add_self_loops` and through adjacency-matrix graphs. Float edge weights of adjacency-matrix graphs stay differentiable ([#704]).

**Fixed**
- `remove_nodes` now updates the `graph_indicator` of batched graphs. It was previously left unchanged, so calling `unbatch` or `getgraph` on the result threw a `BoundsError` ([#717]).
- Fixed `scaled_laplacian` (and so `ChebConv`) crashing with a segmentation fault on AMDGPU graphs: the eigensolver's start vector was created on the CPU, so CPU BLAS was handed GPU memory. It is now created on the same device as the graph ([#722]).
- Added an `EnzymeCore` package extension marking `scaled_laplacian` inactive for Enzyme, matching its existing `@non_differentiable` ChainRules declaration. Enzyme previously differentiated the Krylov eigensolve inside it and failed; this unblocks `ChebConv`, `GConvGRUCell` and `GConvLSTMCell` ([#706]).
- Enzyme can now differentiate through the adjacency-matrix → COO graph conversion: a new internal keyword-free helper `_to_coo_graph` avoids the union-typed keyword handling of the `GNNGraph(g; graph_type)` constructor and of `to_coo`, which Enzyme's type analysis cannot compile. Together with upstream fixes in Enzyme ≥ 0.13.197 this removes the `EnzymeInternalError` crash on `:dense`/`:sparse` graphs ([#703]).
Expand Down Expand Up @@ -245,6 +246,7 @@ Lux implementations of the graph convolutional, pooling, and temporal layers
[#704]: https://github.com/JuliaGraphs/GraphNeuralNetworks.jl/pull/704
[#707]: https://github.com/JuliaGraphs/GraphNeuralNetworks.jl/pull/707
[#706]: https://github.com/JuliaGraphs/GraphNeuralNetworks.jl/pull/706
[#717]: https://github.com/JuliaGraphs/GraphNeuralNetworks.jl/pull/717
[#722]: https://github.com/JuliaGraphs/GraphNeuralNetworks.jl/pull/722
[#718]: https://github.com/JuliaGraphs/GraphNeuralNetworks.jl/pull/718
[FluxML/Zygote.jl#1662]: https://github.com/FluxML/Zygote.jl/issues/1662
3 changes: 2 additions & 1 deletion GNNGraphs/src/transform.jl
Original file line number Diff line number Diff line change
Expand Up @@ -246,12 +246,13 @@ function remove_nodes(g::GNNGraph{<:COO_T}, nodes_to_remove::AbstractVector)
nodes_to_keep = setdiff(1:g.num_nodes, nodes_to_remove)
ndata = getobs(ndata, nodes_to_keep)
edata = getobs(edata, mask_edges_to_keep)
graph_indicator = isnothing(g.graph_indicator) ? nothing : g.graph_indicator[nodes_to_keep]

num_nodes = g.num_nodes - length(nodes_to_remove)

return GNNGraph((s, t, w),
num_nodes, length(s), g.num_graphs,
g.graph_indicator,
graph_indicator,
ndata, edata, g.gdata)
end

Expand Down
21 changes: 21 additions & 0 deletions GNNGraphs/test/transform.jl
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,27 @@ end
end
end

@testitem "remove_nodes on batched graph" setup=[GraphsTestModule] begin
using .GraphsTestModule
g1 = GNNGraph([1, 2], [2, 3], ndata = [1.0, 2.0, 3.0])
g2 = GNNGraph([1, 2, 3], [2, 3, 4], ndata = [4.0, 5.0, 6.0, 7.0])
g = MLUtils.batch([g1, g2])

gnew = remove_nodes(g, [2, 5])
@test gnew.num_nodes == 5
@test gnew.num_graphs == 2
@test gnew.graph_indicator == [1, 1, 2, 2, 2]
@test gnew.ndata.x == [1.0, 3.0, 4.0, 6.0, 7.0]

gs = MLUtils.unbatch(gnew)
@test gs[1].num_nodes == 2
@test gs[1].num_edges == 0
@test gs[2].num_nodes == 3
@test edge_index(gs[2]) == ([2], [3])
@test gs[2].ndata.x == [4.0, 6.0, 7.0]
@test getgraph(gnew, 2).ndata.x == [4.0, 6.0, 7.0]
end

@testitem "remove_nodes(g, p)" setup=[GraphsTestModule] begin
using .GraphsTestModule
for GRAPH_T in GRAPH_TYPES
Expand Down
Loading