Skip to content

Fix Enzyme through graph transforms - #756

Merged
CarloLucibello merged 2 commits into
masterfrom
cl/enzyme-gnngraph-ctor
Nov 29, 2026
Merged

CarloLucibello merged 2 commits into
masterfrom
cl/enzyme-gnngraph-ctor

Conversation

@CarloLucibello

@CarloLucibello CarloLucibello commented Nov 29, 2026 •

Copy link
Copy Markdown
Member

#726 added a graph_indicator eltype check to the positional GNNGraph constructor, 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_index sliced the COO tuple with g.graph[1:2]. On Julia 1.10, slicing a tuple whose elements have different types goes through a Union-typed vector, and Enzyme rejects that (IllegalTypeAnalysisException) when the edge weights are active. edge_index now 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

CarloLucibello and others added 2 commits November 29, 2026 19:09
#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>
@CarloLucibello CarloLucibello changed the title Fix Enzyme through graph transforms on Julia 1.13 Fix Enzyme through graph transforms Nov 29, 2026
@CarloLucibello
CarloLucibello merged commit f9a8cbd into master Nov 29, 2026
10 of 11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant