Skip to content

Enable Enzyme gradient tests across the test suite (Julia ≥ 1.12) - #708

Open
Parvm1102 wants to merge 4 commits into
JuliaGraphs:masterfrom
Parvm1102:enzyme-test-enablement
Open

Parvm1102 wants to merge 4 commits into
JuliaGraphs:masterfrom
Parvm1102:enzyme-test-enablement

Conversation

@Parvm1102

@Parvm1102 Parvm1102 commented Aug 28, 2026 •

Copy link
Copy Markdown
Contributor

I am creating a draft PR for enabling enzyme tests after the recent fixes on NNlib.jl, Enzyme.jl and this repo.

It is draft because NNlibv 0.9.45 bump commit is there but hasn't released yet on the julia registry. All CI checks will be failing because of that.

Another reason for being draft PR is because of enzyme, the test suite time has increased drastically. It will now take hours to complete running on CI. Most layers add 3-15 minutes of time each. TransformerConv now takes ~45 minutes, GConvLSTM 33 min, GConvGRU 27 min, GCNConv 22 min and so on. Need to discuss how should we proceed.

Current status for Enzyme:

  • 24 layers pass on every storage type.
  • 6 layers failing on some storage types:
    • GraphConv :dense/+ fails
    • GatedGraphConv :dense fails
    • SAGEConv :dense fails
    • GNNChain :dense fails
    • TAGConv sparse only
    • EvolveGCNOCell no-state only, by design
  • 4 layers failing entirely:
    • TGCNCell: hang
    • TGCN: hang
    • SGConv
    • DConv

The Dense failures and DConv will only require simple fixes.

@Parvm1102
Parvm1102 marked this pull request as draft August 28, 2026 08:56
@CarloLucibello

Copy link
Copy Markdown
Member

NNlib should be registered in a few minutes

@Parvm1102

Copy link
Copy Markdown
Contributor Author

The GNN julia 1 job terminated because the resource limits. Locally the TransformerConv took around 7gb to run, plus other tests might have exhausted the resources

Parvm1102 and others added 4 commits November 5, 2026 15:22
Signed-off-by: Parvm1102 <parvmittal31757@gmail.com>
Signed-off-by: Parvm1102 <parvmittal31757@gmail.com>
`Flux.destructure`'s `re` writes the gradient into the trainable leaves but
keeps every other array (e.g. BatchNorm's running stats) at its model value.
Zygote returns `nothing` for those fields so `check_equal_leaves` skipped them,
but Enzyme returns a full shadow model with the correct zero gradient there and
the comparison failed on state that is not a gradient at all.

Rebuild the reference from a zeroed model so those leaves compare as zeros.
This enables Enzyme on the GNNChain Parallel/BatchNorm test site for non-dense
graphs; verified neutral for EdgeConv and GNNlib's propagate.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Signed-off-by: Parvm1102 <parvmittal31757@gmail.com>
On Julia 1.13.3 (Enzyme 0.13.216-0.13.218) Enzyme fails on these layers:
GConvLSTMCell, GConvLSTM, GConvGRUCell and GConvGRU hit "LLVM error:
Referring to an instruction in another function!" while linking the
derivative, and DCGRUCell/DCGRU hit an IllegalTypeAnalysisException in the
keyword GNNGraph constructor that d_conv uses. Test them against Zygote
only, as on master, with a comment explaining why.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Parvm1102 <parvmittal31757@gmail.com>
@Parvm1102
Parvm1102 force-pushed the enzyme-test-enablement branch from b13abcb to 4d0bac3 Compare November 5, 2026 12:16
@Parvm1102

Copy link
Copy Markdown
Contributor Author

Rebased onto the latest master and disabled the 6 tests that failed in the last CI run:

GConvLSTMCell, GConvLSTM, GConvGRUCell, GConvGRU: Enzyme fails to compile the gradient with LLVM error: Referring to an instruction in another function!. This started with Julia 1.13.3 and is still there with Enzyme 0.13.218.

DCGRUCell, DCGRU: Enzyme throws IllegalTypeAnalysisException in the keyword GNNGraph constructor used inside d_conv.

These layers now test against Zygote only. Looking for CI behaviour here.

@Parvm1102

Parvm1102 commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor Author

we can re run the two failing tests. Those were failing due to a HTTP 504 error

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants