GCNConv fails to compile with Reactant - MethodError

オープン
#710 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
3/5
見積もり時間
1〜2日
初心者へのやさしさ
68/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
活発
技術スタック
julia

調査の方向性

まず、Reactant.@compile 下での GCNConv forward pass の例を再現し、次に GNNGraphs.degree を GNNlib.gcn_conv を通して Ops.scatter の呼び出しまで追跡します。追跡されたエッジ重みの表現と、関係する scatter のシグネチャを確認します。提供された GCNConv のコンパイルが MethodError なしで成功し、既存の CPU および Zygote の動作が維持されれば完了です。

索引モデルが issue の本文から書いたものです。

説明

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).

主要言語
Julia
スター
310
フォーク
74
平均マージ
3日 23時間
マージ済み PR(30日)
2

環境構築

このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

JuliaGraphs/GraphNeuralNetworks.jl のほかの issue

JuliaGraphs/GraphNeuralNetworks.jl の issue をすべて見る

似ている issue

Julia の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。