GraphNeuralNetworks.jl is a collection of packages hosted on a single GitHub repository.
These packages are GraphNeuralNetworks.jl (a package with the same name as the whole project), GNNGraphs.jl, GNNlib.jl, and GNNLux.jl.
The dependencies between these packages are as follows:
graph TD;
GNNGraphs --> GNNlib;
GNNlib --> GraphNeuralNetworks;
GNNGraphs --> GraphNeuralNetworks;
GNNlib --> GNNLux;
GNNGraphs --> GNNLux;
Thanks to workspaces introduced in julia 1.12, developing multiple packages in a monorepo is straightforward.
Clone the repository with
git clone https://github.com/JuliaGraphs/GraphNeuralNetworks.jl
Then activate any of the packages you want to develop, for example GraphNeuralNetworks:
cd GraphNeuralNetworks
julia --project=.
Dependencies in the monorepo will be automatically available in dev mode, so you can start editing the code of any of the packages and test your changes immediately.
To add a new graph convolutional layer and make it available in both the Flux-based frontend (GraphNeuralNetworks.jl) and the Lux-based frontend (GNNLux), you need to:
- Add the functional version to GNNlib
- Add the stateful version to GraphNeuralNetworks
- Add the stateless version to GNNLux
- Add the layer to the table in docs/api/conv.md
We suggest to start with implementing a self-contained Flux layer in GraphNeuralNetworks.jl, add the corresponding tests, and then when everything is working, move the implementation of the forward pass to GNNlib.jl. At this point, you can add the stateless version to GNNLux.jl.
It could also be convenient to use the @structdef macro from Autostruct.jl to simultaneously generate the struct and the constructor for the layer.
For example, the Flux implementation of MEGNetConv layer can be written as follows:
using Flux, GraphNeuralNetworks, AutoStructs
@structdef function MEGNetConv(ch::Pair{Int, Int}; aggr = mean)
nin, nout = ch
ϕe = Chain(Dense(3nin, nout, relu),
Dense(nout, nout))
ϕv = Chain(Dense(nin + nout, nout, relu),
Dense(nout, nout))
return MEGNetConv(ϕe, ϕv, aggr)
end
Flux.@layer MEGNetConv
function (l::MEGNetConv)(g::AbstractGraph, x::AbstractMatrix, e::AbstractMatrix)
ē = apply_edges(g, xi = x, xj = x, e = e) do xi, xj, e
l.ϕe(vcat(xi, xj, e))
end
xᵉ = aggregate_neighbors(g, l.aggr, ē)
x̄ = l.ϕv(vcat(x, xᵉ))
return x̄, ē
endEach PR should update the version number in the Project.toml file of each involved package if needed by semantic versioning. For instance, when adding new features GNNGraphs could move from "1.17.5" to "1.18.0-DEV". The "DEV" will be removed when the package is tagged and released. Pay also attention to updating the compat bounds, e.g. GraphNeuralNetworks might require a newer version of GNNGraphs.
Each package is released separately. A release commit removes the "DEV" suffix from the package's version and dates its section in CHANGELOG.md. Then comment on that commit with
@JuliaRegistrator register subdir=GNNGraphs
Release notes: see the CHANGELOG
(replacing GNNGraphs with the package being released). Once the registration is merged, TagBot tags the commit as GNNGraphs-vX.Y.Z and creates a GitHub release. Its notes list only the pull requests that changed files in the package's folder, so issues and pull requests don't need package labels.
Each package has its own documentation folder, e.g. GNNGraphs/docs. To generate the docs locally, run the following command from the root of the repository:
# example for GNNGraphs
julia --project=GNNGraphs/docs GNNGraphs/docs/make.jl
You can benchmark the effect on performance of your commits using the script perf/perf.jl.
First, checkout and benchmark the master branch:
julia> include("perf.jl")
julia> df = run_benchmarks()
# observe results
julia> for g in groupby(df, :layer); println(g, "\n"); end
julia> @save "perf_master_20210803_mymachine.jld2" dfmaster=dfNow checkout your branch and do the same:
julia> df = run_benchmarks()
julia> @save "perf_pr_20210803_mymachine.jld2" dfpr=dfFinally, compare the results:
julia> @load "perf_master_20210803_mymachine.jld2"
julia> @load "perf_pr_20210803_mymachine.jld2"
julia> compare(dfpr, dfmaster)The tutorials are Markdown pages in docs/src/tutorials/<section>/, with their images in an assets/ folder next to them. Their code is in @example blocks, so it runs during the docs build. To add a tutorial, add its page there and list it under "Tutorials" in the pages of docs/make.jl.