Repository navigation
Conversation
simsurace
added a commit
that referenced
this pull request
Nov 5, 2026
simsurace
marked this pull request as draft
November 5, 2026 16:40
Member
|
need rebase now that #726 is merged |
reduce_nodes, reduce_edges and the graph-wise softmaxes inferred their output size from the largest index, which Reactant cannot do when the graph is traced. They now scatter into an output of explicit size (the number of graphs, or of nodes). This makes GlobalPool and the attention layers compile, and gives batched graphs whose trailing graphs have no nodes the right number of output columns. GNNLux gets tests for the forward pass under Reactant and for Enzyme gradients and training inside a compiled program. The root `docs` project leaves the workspace: MultiDocumenter pins JSON 0.21, which holds Reactant at 0.2.217, a version that does not build on Julia 1.13. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Train the tutorials with `Training.single_train_step!(AutoEnzyme(), ...)` on a `reactant_device()`, as Lux recommends, instead of Zygote, and regenerate their pages.
…torial pad_graph pads a graph to fixed numbers of nodes, edges and graphs, so Reactant can compile a model or training step once and reuse it for every mini-batch. The graph classification tutorial goes back to master's mini-batch training, padding each batch and masking the padding graphs out of the loss.
graph_sizes holds the number of nodes in each graph of a batch. It duplicates graph_indicator, but its length is the number of graphs, which makes that number part of the array shapes a compiled Reactant function checks. A compiled model called on a batch with a different number of graphs now raises an error instead of silently returning wrong results. The positional constructor derives graph_sizes from graph_indicator, and transformations that keep the graph indicator pass graph_sizes through.
Member
Author
|
I will return to this shortly. |
simsurace
force-pushed
the
gnnlux-reactant
branch
from
November 30, 2026 21:01
8bf7ffb to
7e37305
Compare
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Builds on #726, which made graphs traceable and
GCNConvcompilable with Reactant. This PR extends that to batched graphs, pooling, attention, gradients and training, and ports the GNNLux tutorials to Reactant and Enzyme, the standard Lux workflow. Follows up on #655.Changes
GNNlib
reduce_nodes,reduce_edges,softmax_nodes,softmax_edgesandsoftmax_edge_neighborsnow scatter into an output of explicit size (the number of graphs, or of nodes) instead of inferring it from the largest index. Reactant can't infer the size when the graph is traced, so this makesGlobalPooland the attention layers compile. It also fixes batched graphs whose trailing graphs have no nodes: they now get their output columns.GNNGraphs
pad_graph(g, num_nodes, num_edges, num_graphs), modelled on jraph'spad_with_graphs. It pads a graph to fixed numbers of nodes, edges and graphs, putting the padding in extra graphs. Padding every mini-batch to the same size lets Reactant compile a model or training step once and reuse it for all batches.graph_sizesfield onGNNGraph: the number of nodes in each graph of a batch,nothingfor a single graph. It duplicatesgraph_indicator, but its length is the number of graphs, so the graph count becomes part of the array shapes a compiled function checks. Without it, a compiled model called on a batch padded to a different number of graphs (with the same node and edge totals) silently returned output for the old number of graphs. Now it raisesRuntimeProgramInputMismatch, like a node or edge mismatch. The positional constructor derives it fromgraph_indicator, and transformations that keep the graph indicator pass it through.GNNLux tutorials
pad_graph, and a mask keeps the padding graphs out of the loss.BitVectormasks to the device. The losses select the training nodes withfindall(mask)because of a Reactant bug with Boolean indexing (Inconsistent / different behaviour when indexing RArrays with booleans EnzymeAD/Reactant.jl#3087, fix in Fix linear indexing of traced arrays with Boolean masks EnzymeAD/Reactant.jl#3700, not yet merged). Once that is released, the tutorials can index with the masks directly.Tests
pad_graphandgraph_sizes, on CPU and GPU.The root
docsproject leaves the workspace: MultiDocumenter pins JSON 0.21, which holds Reactant at 0.2.217, a version that does not build on Julia 1.13.Changelog entries
Per the changelog policy, these are for carrying over:
GNNGraphs.jl 1.7.0-DEV
pad_graph, which pads a graph to given numbers of nodes, edges and graphs, putting the padding in extra graphs. Padding every mini-batch to the same size lets Reactant.jl compile a model or a training step once and reuse it for all batches ([Support compiling GNNLux models with Reactant #730]).graph_sizesfield toGNNGraph, holding the number of nodes in each graph of a batch (nothingfor a single graph). Its length is the number of graphs, so a model compiled with Reactant.jl raises an error when called on a batch with a different number of graphs, instead of silently returning wrong results ([Support compiling GNNLux models with Reactant #730]).GNNlib.jl 1.5.0-DEV
reduce_nodes,reduce_edges,softmax_nodes,softmax_edgesandsoftmax_edge_neighborsnow scatter into an output of explicit size (the number of graphs, or of nodes) instead of inferring it from the largest index. This makesGlobalPooland the attention layers compile with Reactant.jl, and returns the correct number of columns for batched graphs whose trailing graphs have no nodes ([Support compiling GNNLux models with Reactant #730]).Version bumps are already on master from #726 (GNNGraphs 1.7.0-DEV, GNNlib 1.5.0-DEV).
🤖 Generated with Claude Code