JuliaGraphs / JuliaGraphs/GraphNeuralNetworks.jl

GCNConv fails to compile with Reactant - MethodError

Open
#710 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Julia
Stars
308
Forks
74
Avg merge
3d 6h
Merged PRs (30d)
2

Description

A minimal GCNConv forward pass fails inside Reactant.@compile. The same model works with plain CPU forward passes and with Zygote gradients.

Failure example

using GNNLux, GNNGraphs, Lux, Reactant, Random

rng = Xoshiro(42)
model = GCNConv(3 => 2, relu)
ps, st = Lux.setup(rng, model)

g = GNNGraph(([1, 2, 3, 4, 5, 6], [2, 3, 1, 5, 6, 4]); num_nodes=6)
x = randn(rng, Float32, 3, 6)

dev = reactant_device()
ps_d, st_d = (ps, st) |> dev
x_d = x |> dev

compiled = @compile model(g, x_d, ps_d, st_d)  # MethodError
ERROR: MethodError: no method matching scatter(::typeof(+), ::Vector{Reactant.TracedRArray{Float32, 1}}, ::Reactant.TracedRArray{Int64, 2}, ::Vector{Vector{Reactant.TracedRNumber{Float32}}}; update_window_dims::Vector{Int64}, ...)

Closest candidates are:
  scatter(::F, ::Vector{<:Reactant.TracedRArray{T, N}}, ::Reactant.TracedRArray{Int64}, ::Vector{<:Reactant.TracedRArray{T}}; ...) where {F, T, N}
  scatter(::Vector{<:Reactant.TracedRArray{T, N}}, ::Reactant.TracedRArray{TI}, ::Vector{<:Reactant.TracedRArray{T}}; ...) where {T, TI, N}

The error originates in the degree computation (GNNGraphs.degree called from GNNlib.gcn_conv), where the edge weights are materialized as a plain Vector{TracedRNumber{Float32}}, which Ops.scatter method does not accept.

GNNLux & Enzyme (just CPU arrays without Reactant) does work, when Enzyme.set_runtime_activity(Enzyme.Reverse) is used.

Version info

Julia 1.12.6 (aarch64-apple), GNNLux v0.2.0, GNNGraphs v1.5.1, Lux v1.31.4, Reactant v0.2.285, Enzyme v0.13.204, Zygote v0.7.13 (macOS, Apple Silicon, CPU).

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the example at the GCNConv forward pass under Reactant.@compile, then trace GNNGraphs.degree through GNNlib.gcn_conv to the Ops.scatter call. Confirm the traced edge-weight representation and scatter signature involved. Done means the supplied GCNConv compilation succeeds without the MethodError while preserving the existing CPU and Zygote behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
julia
Domain
compilers, machine-learning
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
68/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.