From a76168cc85a126f35601bcc62649863eb3a6f002 Mon Sep 17 00:00:00 2001 From: Sanket Patel Date: Sun, 29 Nov 2026 16:54:12 +0000 Subject: [PATCH 1/4] fix: forward initializers to projection dense layers --- GNNLux/src/layers/conv.jl | 2 +- GraphNeuralNetworks/src/layers/conv.jl | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/GNNLux/src/layers/conv.jl b/GNNLux/src/layers/conv.jl index 7acc31e57..7a7f59a9d 100644 --- a/GNNLux/src/layers/conv.jl +++ b/GNNLux/src/layers/conv.jl @@ -1487,7 +1487,7 @@ function GMMConv(ch::Pair{NTuple{2, Int}, Int}, init_weight = glorot_uniform, init_bias = zeros32, use_bias = true) - dense_x = Dense(ch[1][1] => ch[2] * K, use_bias = false) + dense_x = Dense(ch[1][1] => ch[2] * K; use_bias = false, init_weight) return GMMConv(σ, ch, K, residual, init_weight, init_bias, use_bias, dense_x) end diff --git a/GraphNeuralNetworks/src/layers/conv.jl b/GraphNeuralNetworks/src/layers/conv.jl index 7e5d190e5..def511a53 100644 --- a/GraphNeuralNetworks/src/layers/conv.jl +++ b/GraphNeuralNetworks/src/layers/conv.jl @@ -333,8 +333,8 @@ function GATConv(ch::Pair{NTuple{2, Int}, Int}, σ = identity; @assert ein==0 "Using edge features and setting add_self_loops=true at the same time is not yet supported." end - dense_x = Dense(in, out * heads, bias = false) - dense_e = ein > 0 ? Dense(ein, out * heads, bias = false) : nothing + dense_x = Dense(in, out * heads; bias = false, init) + dense_e = ein > 0 ? Dense(ein, out * heads; bias = false, init) : nothing b = bias ? Flux.create_bias(dense_x.weight, true, concat ? out * heads : out) : false a = init(ein > 0 ? 3out : 2out, heads) negative_slope = convert(Float32, negative_slope) @@ -1198,7 +1198,7 @@ function GMMConv(ch::Pair{NTuple{2, Int}, Int}, mu = init(ein, K) sigma_inv = init(ein, K) b = bias ? Flux.create_bias(mu, true, out) : false - dense_x = Dense(nin, out * K, bias = false) + dense_x = Dense(nin, out * K; bias = false, init) GMMConv(mu, sigma_inv, b, σ, ch, K, dense_x, residual) end From 54eb1b6482f02f8b0b3fee3dfd2df249e3076a8f Mon Sep 17 00:00:00 2001 From: Sanket Patel Date: Sun, 29 Nov 2026 16:54:32 +0000 Subject: [PATCH 2/4] test: cover projection weight initializers --- GNNLux/test/layers/conv.jl | 16 +++++++++++++++ GraphNeuralNetworks/test/layers/conv.jl | 27 +++++++++++++++++++++++++ 2 files changed, 43 insertions(+) diff --git a/GNNLux/test/layers/conv.jl b/GNNLux/test/layers/conv.jl index 972c9e372..b6d42bb74 100644 --- a/GNNLux/test/layers/conv.jl +++ b/GNNLux/test/layers/conv.jl @@ -16,6 +16,22 @@ @test all(isone, ps.dense_e.weight) end +@testitem "GMM weight initialization" begin + using Lux, Random + + init_weight(rng::AbstractRNG, dims...) = ones(Float32, dims...) + l = GMMConv((4, 2) => 3; K = 2, use_bias = false, init_weight) + ps, _ = Lux.setup(Xoshiro(0), l) + @test all(isone, ps.mu) + @test all(isone, ps.sigma_inv) + @test all(isone, ps.dense_x.weight) + + default_l = GMMConv((4, 2) => 3; K = 2) + default_ps, _ = Lux.setup(Xoshiro(0), default_l) + @test size(default_ps.dense_x.weight) == (6, 4) + @test !all(isone, default_ps.dense_x.weight) +end + @testitem "layers/conv" setup=[TestModuleLux] begin using .TestModuleLux diff --git a/GraphNeuralNetworks/test/layers/conv.jl b/GraphNeuralNetworks/test/layers/conv.jl index c09fb70ba..0831b56a6 100644 --- a/GraphNeuralNetworks/test/layers/conv.jl +++ b/GraphNeuralNetworks/test/layers/conv.jl @@ -207,6 +207,21 @@ end end end +@testitem "GATConv custom initializer" setup=[TestModule] begin + using .TestModule + l = GATConv((4, 2) => 3; heads = 2, add_self_loops = false, + bias = false, init = Flux.ones32) + @test all(isone, l.a) + @test all(isone, l.dense_x.weight) + @test all(isone, l.dense_e.weight) + + default_l = GATConv((4, 2) => 3; heads = 2, add_self_loops = false) + @test size(default_l.dense_x.weight) == (6, 4) + @test size(default_l.dense_e.weight) == (6, 2) + @test !all(isone, default_l.dense_x.weight) + @test !all(isone, default_l.dense_e.weight) +end + @testitem "GATConv GPU" setup=[TolSnippet, TestModule] tags=[:gpu] begin using .TestModule for heads in (1, 2), concat in (true, false) @@ -555,6 +570,18 @@ end end end +@testitem "GMMConv custom initializer" setup=[TestModule] begin + using .TestModule + l = GMMConv((4, 2) => 3; K = 2, bias = false, init = Flux.ones32) + @test all(isone, l.mu) + @test all(isone, l.sigma_inv) + @test all(isone, l.dense_x.weight) + + default_l = GMMConv((4, 2) => 3; K = 2) + @test size(default_l.dense_x.weight) == (6, 4) + @test !all(isone, default_l.dense_x.weight) +end + @testitem "GMMConv GPU" setup=[TolSnippet, TestModule] tags=[:gpu] begin using .TestModule ein_channel = 10 From 5fde2c3070310c88632629015d1541895312d601 Mon Sep 17 00:00:00 2001 From: Sanket Patel Date: Sun, 29 Nov 2026 16:54:37 +0000 Subject: [PATCH 3/4] chore: bump frontend package versions --- GNNLux/Project.toml | 2 +- GraphNeuralNetworks/Project.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/GNNLux/Project.toml b/GNNLux/Project.toml index fce31f55d..8ec27b7b1 100644 --- a/GNNLux/Project.toml +++ b/GNNLux/Project.toml @@ -1,6 +1,6 @@ name = "GNNLux" uuid = "e8545f4d-a905-48ac-a8c4-ca114b98986d" -version = "0.3.1-DEV" +version = "0.3.2-DEV" authors = ["Carlo Lucibello and contributors"] [workspace] diff --git a/GraphNeuralNetworks/Project.toml b/GraphNeuralNetworks/Project.toml index c5c6b1139..5cb4a5a1e 100644 --- a/GraphNeuralNetworks/Project.toml +++ b/GraphNeuralNetworks/Project.toml @@ -1,7 +1,7 @@ name = "GraphNeuralNetworks" uuid = "cffab07f-9bc2-4db1-8861-388f63bf7694" authors = ["Carlo Lucibello and contributors"] -version = "1.2.0-DEV" +version = "1.2.1-DEV" [workspace] projects = ["test", "docs"] From ffaf9c36e4ea090b79053d33285f7ea566c87e1b Mon Sep 17 00:00:00 2001 From: Sanket Patel Date: Sun, 29 Nov 2026 17:02:15 +0000 Subject: [PATCH 4/4] test: match initializer issue reproductions --- GNNLux/test/layers/conv.jl | 4 ++-- GraphNeuralNetworks/test/layers/conv.jl | 11 +++++++---- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/GNNLux/test/layers/conv.jl b/GNNLux/test/layers/conv.jl index b6d42bb74..d9dd1bf5f 100644 --- a/GNNLux/test/layers/conv.jl +++ b/GNNLux/test/layers/conv.jl @@ -16,11 +16,11 @@ @test all(isone, ps.dense_e.weight) end -@testitem "GMM weight initialization" begin +@testitem "GMMConv weight initialization" begin using Lux, Random init_weight(rng::AbstractRNG, dims...) = ones(Float32, dims...) - l = GMMConv((4, 2) => 3; K = 2, use_bias = false, init_weight) + l = GMMConv((4, 2) => 3; K = 2, init_weight) ps, _ = Lux.setup(Xoshiro(0), l) @test all(isone, ps.mu) @test all(isone, ps.sigma_inv) diff --git a/GraphNeuralNetworks/test/layers/conv.jl b/GraphNeuralNetworks/test/layers/conv.jl index 0831b56a6..466cc7ecb 100644 --- a/GraphNeuralNetworks/test/layers/conv.jl +++ b/GraphNeuralNetworks/test/layers/conv.jl @@ -209,11 +209,14 @@ end @testitem "GATConv custom initializer" setup=[TestModule] begin using .TestModule - l = GATConv((4, 2) => 3; heads = 2, add_self_loops = false, - bias = false, init = Flux.ones32) + l = GATConv(4 => 3; init = Flux.ones32) @test all(isone, l.a) @test all(isone, l.dense_x.weight) - @test all(isone, l.dense_e.weight) + + l_edge = GATConv((4, 2) => 3; add_self_loops = false, init = Flux.ones32) + @test all(isone, l_edge.a) + @test all(isone, l_edge.dense_x.weight) + @test all(isone, l_edge.dense_e.weight) default_l = GATConv((4, 2) => 3; heads = 2, add_self_loops = false) @test size(default_l.dense_x.weight) == (6, 4) @@ -572,7 +575,7 @@ end @testitem "GMMConv custom initializer" setup=[TestModule] begin using .TestModule - l = GMMConv((4, 2) => 3; K = 2, bias = false, init = Flux.ones32) + l = GMMConv((4, 2) => 3; K = 2, init = Flux.ones32) @test all(isone, l.mu) @test all(isone, l.sigma_inv) @test all(isone, l.dense_x.weight)