Repository navigation
Fix Enzyme through graph transforms - #756
Merged
Merged
Conversation
#726 added a `graph_indicator` eltype check to the positional `GNNGraph` constructor that every transform (`add_self_loops`, `set_edge_weight`, `_to_coo_graph`, ...) calls. On Julia 1.13 Enzyme cannot root the pointer phi that branch produces, so gradients through GCNConv, GATConv & co. fail with an EnzymeRuntimeException. Callers pass an already validated indicator and the keyword constructor keeps the check, so drop it here. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
`g.graph[1:2]` slices a heterogeneous tuple, which Julia 1.10 does through a Union-typed vector. With active edge weights Enzyme then fails with an IllegalTypeAnalysisException, as the new transform test showed on 1.10. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This was referenced Nov 29, 2026
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.
#726 added a
graph_indicatoreltype check to the positionalGNNGraphconstructor, which every graph transform calls (add_self_loops,set_edge_weight,_to_coo_graph, ...). On Julia 1.13, Enzyme fails on that branch ("could not determine how to keep a pointer phi in this function rooted"), so Enzyme gradients through GCNConv, GATConv, GATv2Conv, AGNNConv, TAGConv, TransformerConv, GNNChain and EvolveGCNO error out. Bisected to dbc1f38. Found while rebasing #708, which enables Enzyme across the test suite.The check is removed from the positional constructor only. Its callers pass an indicator that is already validated, and the public keyword constructor still checks it, so the #726 tests are unaffected.
The new test also failed on Julia 1.10 for a separate, older reason.
edge_indexsliced the COO tuple withg.graph[1:2]. On Julia 1.10, slicing a tuple whose elements have different types goes through aUnion-typed vector, and Enzyme rejects that (IllegalTypeAnalysisException) when the edge weights are active.edge_indexnow builds(s, t)explicitly.Adds an Enzyme test through
set_edge_weight+add_self_loops. It fails on master and passes with this change. No version bump: GNNGraphs is already at 1.7.0-DEV.🧔♂️🤖 Assisted by Claude Sonnet 5.5