Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

updates to GNNLux for first release #540

Merged
merged 2 commits into from
Dec 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion GNNGraphs/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ GNNGraphsSimpleWeightedGraphsExt = "SimpleWeightedGraphs"
Adapt = "4"
CUDA = "5"
ChainRulesCore = "1"
Functors = "0.4.1"
Functors = "0.4.1, 0.5"
Graphs = "1.4"
KrylovKit = "0.8"
LinearAlgebra = "1"
Expand Down
2 changes: 1 addition & 1 deletion GNNLux/LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2021 Carlo Lucibello <[email protected]> and contributors
Copyright (c) 2024 Carlo Lucibello <[email protected]> and contributors

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
20 changes: 5 additions & 15 deletions GNNLux/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,22 +17,12 @@ Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2"

[compat]
ConcreteStructs = "0.2.3"
Lux = "1.0"
LuxCore = "1.0"
GNNGraphs = "1.3"
GNNlib = "0.2.3"
Lux = "1"
LuxCore = "1"
NNlib = "0.9.21"
Reexport = "1.2"
Static = "1.1"
Statistics = "1"
julia = "1.10"

[extras]
ComponentArrays = "b0b7db55-cfe3-40fc-9ded-d10e2dbeff66"
Functors = "d9f16b24-f501-4c13-a1f2-28368ffc5196"
LuxTestUtils = "ac9de150-d08f-4546-94fb-7472b5760531"
MLDataDevices = "7e8f7934-dd98-4c1a-8fe8-92b47a384d40"
ReTestItems = "817f1d60-ba6b-4fd5-9520-3cf149f6a823"
StableRNGs = "860ef19b-820b-49d6-a774-d7a799459cd3"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
Zygote = "e88e6eb3-aa80-5325-afca-941959d7151f"

[targets]
test = ["Test", "MLDataDevices", "ComponentArrays", "Functors", "LuxTestUtils", "ReTestItems", "StableRNGs", "Zygote"]
22 changes: 22 additions & 0 deletions GNNLux/test/Project.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
[deps]
ComponentArrays = "b0b7db55-cfe3-40fc-9ded-d10e2dbeff66"
ConcreteStructs = "2569d6c7-a4a2-43d3-a901-331e8e4be471"
Functors = "d9f16b24-f501-4c13-a1f2-28368ffc5196"
GNNGraphs = "aed8fd31-079b-4b5a-b342-a13352159b8c"
GNNLux = "e8545f4d-a905-48ac-a8c4-ca114b98986d"
GNNlib = "a6a84749-d869-43f8-aacc-be26a1996e48"
Lux = "b2108857-7c20-44ae-9111-449ecde12c47"
LuxCore = "bb33d45b-7691-41d6-9220-0943567d0623"
LuxTestUtils = "ac9de150-d08f-4546-94fb-7472b5760531"
MLDataDevices = "7e8f7934-dd98-4c1a-8fe8-92b47a384d40"
NNlib = "872c559c-99b0-510c-b3b7-b6c96a88d5cd"
Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
Reexport = "189a3867-3050-52da-a836-e630ba90ab69"
StableRNGs = "860ef19b-820b-49d6-a774-d7a799459cd3"
Static = "aedffcd0-7271-4cad-89d0-dc628f76c6d3"
Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
TestItemRunner = "f8b46487-2199-4994-9208-9a1283c18c0a"
TestItems = "1c621080-faea-4a02-84b6-bbd5e436b8fe"
Zygote = "e88e6eb3-aa80-5325-afca-941959d7151f"
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
@testitem "layers/basic" setup=[SharedTestSetup] begin
@testitem "layers/basic" setup=[TestModuleLux] begin
using .TestModuleLux

rng = StableRNG(17)
g = rand_graph(rng, 10, 40)
x = randn(rng, Float32, 3, 10)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
@testitem "layers/conv" setup=[SharedTestSetup] begin
@testitem "layers/conv" setup=[TestModuleLux] begin
using .TestModuleLux

rng = StableRNG(1234)
g = rand_graph(rng, 10, 40)
in_dims = 3
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
@testitem "layers/temporalconv" setup=[SharedTestSetup] begin
@testitem "layers/temporalconv" setup=[TestModuleLux] begin
using .TestModuleLux
using LuxTestUtils: test_gradients, AutoReverseDiff, AutoTracker, AutoForwardDiff, AutoEnzyme

rng = StableRNG(1234)
Expand Down
37 changes: 29 additions & 8 deletions GNNLux/test/runtests.jl
Original file line number Diff line number Diff line change
@@ -1,10 +1,31 @@
using Test
using Lux
using GNNLux
using Random, Statistics
using TestItemRunner

using ReTestItems
# using Pkg, Preferences, Test
# using InteractiveUtils, Hwloc
## See https://www.julia-vscode.org/docs/stable/userguide/testitems/
## for how to run the tests within VS Code.
## See test_module.jl for the test infrastructure.

runtests(GNNLux)
## Uncomment below and in test_module.jl to change the default test settings
# ENV["GNN_TEST_CPU"] = "false"
# ENV["GNN_TEST_CUDA"] = "true"
# ENV["GNN_TEST_AMDGPU"] = "true"
# ENV["GNN_TEST_Metal"] = "true"

# The only available tag at the moment is :gpu
# Tests not tagged with :gpu are considered to be CPU tests
# Tests tagged with :gpu should run on all GPU backends

# TODO add gpu tests. Not urgent since almost the whole path for layers is tested
# in GraphNeuralNetworks.jl

if get(ENV, "GNN_TEST_CPU", "true") == "true"
@run_package_tests filter = ti -> :gpu ∉ ti.tags
end
if get(ENV, "GNN_TEST_CUDA", "false") == "true"
@run_package_tests filter = ti -> :gpu ∈ ti.tags
end
if get(ENV, "GNN_TEST_AMDGPU", "false") == "true"
@run_package_tests filter = ti -> :gpu ∈ ti.tags
end
if get(ENV, "GNN_TEST_Metal", "false") == "true"
@run_package_tests filter = ti -> :gpu ∈ ti.tags
end
28 changes: 26 additions & 2 deletions GNNLux/test/shared_testsetup.jl → GNNLux/test/test_module.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,30 @@
@testsetup module SharedTestSetup
@testmodule TestModuleLux begin

import Reexport: @reexport
using Pkg

## Uncomment below to change the default test settings
# ENV["GNN_TEST_CUDA"] = "true"
# ENV["GNN_TEST_AMDGPU"] = "true"
# ENV["GNN_TEST_Metal"] = "true"

to_test(backend) = get(ENV, "GNN_TEST_$(backend)", "false") == "true"
has_dependecies(pkgs) = all(pkg -> haskey(Pkg.project().dependencies, pkg), pkgs)
deps_dict = Dict(:CUDA => ["CUDA", "cuDNN"], :AMDGPU => ["AMDGPU"], :Metal => ["Metal"])

for (backend, deps) in deps_dict
if to_test(backend)
if !has_dependecies(deps)
Pkg.add(deps)
end
@eval using $backend
if backend == :CUDA
@eval using cuDNN
end
@eval $backend.allowscalar(false)
end
end

using Reexport: @reexport

@reexport using Test
@reexport using GNNLux
Expand Down