Unused output of node type leads to index error in Zygote

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

メンテナーはふだん 2 日以内に返信

@lenianiva がすでに取り組んでいます。

2026年11月7日 から。

  • #1740 @lenianiva による — オープン

評価

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

調査の方向性

Start with the failing MWE in the issue and trace the GATConv call through src/layers/conv.jl and src/layers/heteroconv.jl, then inspect the reported gat_conv location in GNNlib. Reproduce the Zygote gradient error with the unused node type C and check the related tests. Done means the gradient completes without a bounds error; an open linked pull request already addresses this issue.

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

説明

MWE:

using GraphNeuralNetworks, Flux

g = GNNHeteroGraph(
    Dict(
        (:A, :a, :B) => ([1, 2], [3, 4]),
        (:B, :a, :A) => ([1], [2]),
        (:A, :a, :C) => ([1], [1]),
    );
    num_nodes = Dict(:A => 3, :B => 5, :C => 2),
)
layer = HeteroGraphConv([et => GATConv(2 => 2) for et in keys(g.edata)])
x = (A = rand(Float32, 2, 3), B = rand(Float32, 2, 5), C = rand(Float32, 2, 2))

Flux.gradient(x) do x
    y = layer(g, x)
    sum(y[:A]) + sum(y[:B])
end

Error

ERROR: LoadError: BoundsError: attempt to access Tuple{Nothing, ChainRulesCore.ZeroTangent, ChainRulesCore.ZeroTangent} at index [4]
Stacktrace:
  [1] getindex
    @ ./tuple.jl:33 [inlined]
  [2] gradindex(x::Tuple{Nothing, ChainRulesCore.ZeroTangent, ChainRulesCore.ZeroTangent}, i::Int64)
    @ Zygote ~/.julia/packages/Zygote/5O3tb/src/compiler/reverse.jl:24
  [3] gat_conv
    @ ~/.julia/packages/GNNlib/sAfhh/src/layers/conv.jl:154 [inlined]
  [4] (::Zygote.Pullback{Tuple{typeof(gat_conv), GATConv{Dense{typeof(identity), Matrix{Float32}, Bool}, Nothing, Float64, Float32, Matrix{Float32}, typeof(identity), Vector{Float32}}, GNNHeteroGraph{Tuple{Vector{Int64}, Vector{Int64}, Nothing}}, Tuple{Matrix{Float32}, Matrix{Float32}}, Nothing}, Any})(Δ::ChainRulesCore.ZeroTangent)
    @ Zygote ~/.julia/packages/Zygote/5O3tb/src/compiler/interface2.jl:0
  [5] GATConv (repeats 2 times)
    @ ~/.julia/packages/GraphNeuralNetworks/C8IDs/src/layers/conv.jl:346 [inlined]
  [6] forw
    @ ~/.julia/packages/GraphNeuralNetworks/C8IDs/src/layers/heteroconv.jl:63 [inlined]
主要言語
Julia
スター
310
フォーク
75
平均マージ
2日 15時間
マージ済み PR(30日)
10

環境構築

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

はじめの一歩

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

JuliaGraphs/GraphNeuralNetworks.jl のほかの issue

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

似ている issue

Julia の issue をもっと見る

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

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