Skip to content

Commit b763cdd

Browse files
Fix Pkg.test failure for registered packages (#700) (#701)
* Remove escaping [sources] paths from test/Project.toml (fixes #700) The test/Project.toml files carried `[sources]` entries pointing to sibling packages via relative paths that escape the package directory (e.g. `GNNlib = {path = "../../GNNlib"}`). These are shipped inside the registered tarball, so when an end user runs `Pkg.test` on an installed release, `../../GNNlib` resolves to a nonexistent path and Pkg errors with "expected package GNNlib to exist at path .../packages/ GraphNeuralNetworks/GNNlib". The escaping sibling sources are redundant for local development — the top-level [workspace] already links the sibling packages as dev checkouts — so removing them keeps local `Pkg.test` resolving siblings to the local paths, while a registry install resolves them from the registry (per the existing [compat] bounds). Each test/Project.toml keeps only its own non-escaping self-source. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * Fix docs and TGCN Mooncake CI failures (#700) Docs: the GNNlib temporal-cell forward passes (tgcn, gconv_gru, gconv_lstm, dcgru) had docstrings but no @docs block, so Documenter's checkdocs aborted the build with "4 docstrings not included in the manual". Convert them to plain comments, matching the convention for the other functional convs (gcn_conv, gat_conv, ... are exported but intentionally undocumented in GNNlib). Tests: the TGCNCell/TGCN gradient checks errored intermittently on the Julia 1.12 ubuntu runner. Mooncake returns exactly-zero gradients for some z-gate params when differentiating the graph-conv path from an all-zeros initial state (~3% of random inputs); Zygote and finite differences agree to ~1e-8, so it is an upstream Mooncake bug, not a layer-math issue. Skip Mooncake for these two items via ad_backends = [Flux.AutoZygote()], the same pattern GConvGRU/GConvLSTM/ DCGRU already use. Test/docs only: no changelog entry or version bump. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> * Link upstream Mooncake issue in TGCN test comments Traced the flaky TGCNCell/TGCN Mooncake failure to an upstream bug in Mooncake's gradient through NNlib.sigmoid (reported as chalk-lab/Mooncake.jl#1257), not the all-zeros initial state as first thought. Update the ad_backends skip comments to reflect the real cause and link the issue. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent f80bc29 commit b763cdd

5 files changed

Lines changed: 45 additions & 46 deletions

File tree

‎GNNLux/test/Project.toml‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,7 @@ TestItems = "1c621080-faea-4a02-84b6-bbd5e436b8fe"
2222
Zygote = "e88e6eb3-aa80-5325-afca-941959d7151f"
2323

2424
[sources]
25-
GNNGraphs = {path = "../../GNNGraphs"}
2625
GNNLux = {path = ".."}
27-
GNNlib = {path = "../../GNNlib"}
2826

2927
[compat]
3028
NNlib = "0.9.38"

‎GNNlib/src/layers/temporalconv.jl‎

Lines changed: 21 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,13 @@ and the Lux (`GNNLux`) frontends build such a carrier and call into these
88
functions, so the recurrence math lives in a single place.
99
=#
1010

11-
"""
12-
tgcn(l, cz, cr, ch, h)
13-
14-
GRU gating of the T-GCN cell. `cz`, `cr`, `ch` are the spatial-convolution
15-
outputs of the three gates (computed by the frontend), `h` is the current
16-
hidden state, and `l` carries the three gate `Dense` sub-modules
17-
(`l.dense_z`, `l.dense_r`, `l.dense_h`, each exposing `weight`, `bias`, `σ`).
18-
Returns the updated hidden state.
19-
"""
11+
# tgcn(l, cz, cr, ch, h)
12+
#
13+
# GRU gating of the T-GCN cell. `cz`, `cr`, `ch` are the spatial-convolution
14+
# outputs of the three gates (computed by the frontend), `h` is the current
15+
# hidden state, and `l` carries the three gate `Dense` sub-modules
16+
# (`l.dense_z`, `l.dense_r`, `l.dense_h`, each exposing `weight`, `bias`, `σ`).
17+
# Returns the updated hidden state.
2018
function tgcn(l, cz, cr, ch, h)
2119
z = l.dense_z.σ.(l.dense_z.weight * vcat(cz, h) .+ l.dense_z.bias)
2220
r = l.dense_r.σ.(l.dense_r.weight * vcat(cr, h) .+ l.dense_r.bias)
@@ -25,13 +23,11 @@ function tgcn(l, cz, cr, ch, h)
2523
return h
2624
end
2725

28-
"""
29-
gconv_gru(l, g, x, h)
30-
31-
Forward pass of the GConvGRU cell. `l` carries the six `ChebConv` sub-modules
32-
(`conv_x_r`, `conv_h_r`, `conv_x_z`, `conv_h_z`, `conv_x_h`, `conv_h_h`).
33-
Returns the updated hidden state.
34-
"""
26+
# gconv_gru(l, g, x, h)
27+
#
28+
# Forward pass of the GConvGRU cell. `l` carries the six `ChebConv` sub-modules
29+
# (`conv_x_r`, `conv_h_r`, `conv_x_z`, `conv_h_z`, `conv_x_h`, `conv_h_h`).
30+
# Returns the updated hidden state.
3531
function gconv_gru(l, g::GNNGraph, x, h)
3632
r = NNlib.sigmoid_fast.(cheb_conv(l.conv_x_r, g, x) .+ cheb_conv(l.conv_h_r, g, h))
3733
z = NNlib.sigmoid_fast.(cheb_conv(l.conv_x_z, g, x) .+ cheb_conv(l.conv_h_z, g, h))
@@ -40,13 +36,11 @@ function gconv_gru(l, g::GNNGraph, x, h)
4036
return h
4137
end
4238

43-
"""
44-
gconv_lstm(l, g, x, h, c)
45-
46-
Forward pass of the GConvLSTM cell. `l` carries the eight `ChebConv` sub-modules
47-
and the four peephole scalings/biases (`w_i`, `b_i`, `w_f`, `b_f`, `w_c`, `b_c`,
48-
`w_o`, `b_o`). Returns the updated `(h, c)` state.
49-
"""
39+
# gconv_lstm(l, g, x, h, c)
40+
#
41+
# Forward pass of the GConvLSTM cell. `l` carries the eight `ChebConv` sub-modules
42+
# and the four peephole scalings/biases (`w_i`, `b_i`, `w_f`, `b_f`, `w_c`, `b_c`,
43+
# `w_o`, `b_o`). Returns the updated `(h, c)` state.
5044
function gconv_lstm(l, g::GNNGraph, x, h, c)
5145
# input gate
5246
i = cheb_conv(l.conv_x_i, g, x) .+ cheb_conv(l.conv_h_i, g, h) .+ l.w_i .* c .+ l.b_i
@@ -63,12 +57,10 @@ function gconv_lstm(l, g::GNNGraph, x, h, c)
6357
return h, c
6458
end
6559

66-
"""
67-
dcgru(l, g, x, h)
68-
69-
Forward pass of the DCGRU cell. `l` carries the three `DConv` sub-modules
70-
(`dconv_u`, `dconv_r`, `dconv_c`). Returns the updated hidden state.
71-
"""
60+
# dcgru(l, g, x, h)
61+
#
62+
# Forward pass of the DCGRU cell. `l` carries the three `DConv` sub-modules
63+
# (`dconv_u`, `dconv_r`, `dconv_c`). Returns the updated hidden state.
7264
function dcgru(l, g::GNNGraph, x, h)
7365
h̃ = vcat(x, h)
7466
z = NNlib.sigmoid_fast.(d_conv(l.dconv_u, g, h̃))

‎GNNlib/test/Project.toml‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ TestItemRunner = "f8b46487-2199-4994-9208-9a1283c18c0a"
1919
Zygote = "e88e6eb3-aa80-5325-afca-941959d7151f"
2020

2121
[sources]
22-
GNNGraphs = {path = "../../GNNGraphs"}
2322
GNNlib = {path = ".."}
2423

2524
[compat]

‎GraphNeuralNetworks/test/Project.toml‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,4 @@ TestItemRunner = "f8b46487-2199-4994-9208-9a1283c18c0a"
1818
Zygote = "e88e6eb3-aa80-5325-afca-941959d7151f"
1919

2020
[sources]
21-
GNNGraphs = {path = "../../GNNGraphs"}
22-
GNNlib = {path = "../../GNNlib"}
2321
GraphNeuralNetworks = {path = ".."}

‎GraphNeuralNetworks/test/layers/temporalconv.jl‎

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -25,17 +25,24 @@ end
2525

2626
@testitem "TGCNCell" setup=[TemporalConvTestModule, TestModule] begin
2727
using .TemporalConvTestModule, .TestModule
28-
28+
29+
# Mooncake is skipped here: it returns wrong gradients through the cell's
30+
# sigmoid gates (`Dense(_, sigmoid)`) on a fraction of inputs, so the check is
31+
# flaky (Zygote and finite differences agree). Upstream Mooncake bug with
32+
# NNlib.sigmoid: https://github.com/chalk-lab/Mooncake.jl/issues/1257.
33+
# Reference against Zygote only, matching the other temporal cells.
34+
ad_backends = [Flux.AutoZygote()]
35+
2936
# Test with default activation function
3037
cell = GraphNeuralNetworks.TGCNCell(in_channel => out_channel)
3138
y, h = cell(g, g.x)
3239
@test y === h
3340
@test size(h) == (out_channel, g.num_nodes)
3441
# with no initial state
35-
test_gradients(cell, g, g.x, loss=cell_loss, rtol=RTOL_HIGH)
42+
test_gradients(cell, g, g.x, loss=cell_loss, rtol=RTOL_HIGH; ad_backends)
3643
# with initial state
37-
test_gradients(cell, g, g.x, h, loss=cell_loss, rtol=RTOL_HIGH)
38-
44+
test_gradients(cell, g, g.x, h, loss=cell_loss, rtol=RTOL_HIGH; ad_backends)
45+
3946
# Test with custom activation function
4047
custom_activation = tanh
4148
cell_custom = GraphNeuralNetworks.TGCNCell(in_channel => out_channel, act = custom_activation)
@@ -45,14 +52,19 @@ end
4552
# Test that outputs differ when using different activation functions
4653
@test !isapprox(y, y_custom, rtol=RTOL_HIGH)
4754
# with no initial state
48-
test_gradients(cell_custom, g, g.x, loss=cell_loss, rtol=RTOL_HIGH)
55+
test_gradients(cell_custom, g, g.x, loss=cell_loss, rtol=RTOL_HIGH; ad_backends)
4956
# with initial state
50-
test_gradients(cell_custom, g, g.x, h_custom, loss=cell_loss, rtol=RTOL_HIGH)
57+
test_gradients(cell_custom, g, g.x, h_custom, loss=cell_loss, rtol=RTOL_HIGH; ad_backends)
5158
end
5259

5360
@testitem "TGCN" setup=[TemporalConvTestModule, TestModule] begin
5461
using .TemporalConvTestModule, .TestModule
55-
62+
63+
# Mooncake is skipped here (see the TGCNCell test item and
64+
# https://github.com/chalk-lab/Mooncake.jl/issues/1257): it returns wrong
65+
# gradients through the cell's sigmoid gates on some inputs. Zygote only.
66+
ad_backends = [Flux.AutoZygote()]
67+
5668
# Test with default activation function
5769
layer = TGCN(in_channel => out_channel)
5870
x = rand(Float32, in_channel, timesteps, g.num_nodes)
@@ -61,9 +73,9 @@ end
6173
@test layer isa GNNRecurrence
6274
@test size(y) == (out_channel, timesteps, g.num_nodes)
6375
# with no initial state
64-
test_gradients(layer, g, x, rtol = RTOL_HIGH)
76+
test_gradients(layer, g, x, rtol = RTOL_HIGH; ad_backends)
6577
# with initial state
66-
test_gradients(layer, g, x, state0, rtol = RTOL_HIGH)
78+
test_gradients(layer, g, x, state0, rtol = RTOL_HIGH; ad_backends)
6779

6880
# Test with custom activation function
6981
custom_activation = tanh
@@ -74,15 +86,15 @@ end
7486
# Test that outputs differ when using different activation functions
7587
@test !isapprox(y, y_custom, rtol = RTOL_HIGH)
7688
# with no initial state
77-
test_gradients(layer_custom, g, x, rtol = RTOL_HIGH)
89+
test_gradients(layer_custom, g, x, rtol = RTOL_HIGH; ad_backends)
7890
# with initial state
79-
test_gradients(layer_custom, g, x, state0, rtol = RTOL_HIGH)
91+
test_gradients(layer_custom, g, x, state0, rtol = RTOL_HIGH; ad_backends)
8092

8193
# interplay with GNNChain
8294
model = GNNChain(TGCN(in_channel => out_channel), Dense(out_channel, 1))
8395
y = model(g, x)
8496
@test size(y) == (1, timesteps, g.num_nodes)
85-
test_gradients(model, g, x, rtol = RTOL_HIGH, atol = ATOL_LOW)
97+
test_gradients(model, g, x, rtol = RTOL_HIGH, atol = ATOL_LOW; ad_backends)
8698
end
8799

88100
@testitem "GConvLSTMCell" setup=[TemporalConvTestModule, TestModule] begin

0 commit comments

Comments
 (0)