Repository navigation
Enable Enzyme gradient tests across the test suite - #708
Conversation
|
NNlib should be registered in a few minutes |
|
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 |
b13abcb to
4d0bac3
Compare
|
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. |
|
we can re run the two failing tests. Those were failing due to a HTTP 504 error |
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>
4d0bac3 to
db244c6
Compare
CarloLucibello
left a comment
There was a problem hiding this comment.
I rebased this onto master (now including #756) and force-pushed.
Tests. After the first rebase, Enzyme errored in 12 test items in GraphNeuralNetworks and 2 in GNNlib (GCNConv, GATConv, GATv2Conv, AGNNConv, TAGConv, TransformerConv, GNNChain, EvolveGCNO, propagate). The cause was a regression on master from #726, not this PR, and #756 fixed it. With that fix, both suites pass locally on Julia 1.13.4 with Enzyme 0.13.221 (GraphNeuralNetworks: 989/989). Enzyme's CI cost is modest: on the last run the Julia 1 GNN job took 33 min, against 27 min on master. Please update the PR description: it still says draft and warns about hours of CI time, and the list of failing layers is stale.
Suggestions:
- Julia version gate.
TEST_ENZYME = VERSION >= v"1.12"(GNN, GNNlib) cites EnzymeAD/Enzyme.jl#3423, which was fixed in August (EnzymeAD/Enzyme.jl#3424). On Julia 1.10 I checked GCNConv, GATConv, SAGEConv and GINConv: Enzyme gradients match Zygote. #756 also fixed a 1.10-only Enzyme failure inedge_index. Either try enabling Enzyme on 1.10, or keep the gate and state the actual reason (e.g. CI time). - Repeated
:denseskips. The same... == :dense ? [...] : [...]expression, with the same comment, appears six times: msgpass.jl, basic.jl (1, 2), conv.jl (1, 2, 3). They share one cause:to_dense(A::ADJMAT_T)reassignsAto an adjoint, a converted copy or a binarized copy, so its return type is aUnion. Making it type-stable in GNNGraphs would remove all six skips, and could be a follow-up. In this PR, please put the skip in one place (e.g. a helper that returns the backend list for a graph) instead of six copies. - No Enzyme lower bound in the
[compat]ofGNNlib/test/Project.tomlandGraphNeuralNetworks/test/Project.toml, although the PR depends on recent Enzyme fixes.GNNGraphs/test/Project.tomlalready hasEnzyme = "0.13.197". - Nits:
TEST_ENZYMEis exported but nothing outside the test modules uses it.- The DConv test gains trailing whitespace (conv.jl#L728).
- The EvolveGCNOCell comment (temporalconv.jl#L221) says the cell returns the same array in the output and the state. The issue Enzyme hits is that the state passed back in holds the same array twice (
weightandlstm[1], sinceLSTMCellreturnsh, (h, c)).
Looks right: the zeroed finite-difference reference (it relies on non-trainable arrays not affecting the loss, which holds for BatchNorm in train mode), the ŷ rename in the MEGNetConv loss, and the remaining per-layer Enzyme skips.
🧔♂️🤖 Assisted by Claude Sonnet 5.5
- Add an `enzyme_dense` keyword to `test_gradients` that skips Enzyme on :dense graphs, replacing six copies of the same backend-list ternary. - State the actual reason for running Enzyme only on Julia >= 1.12. - Add an Enzyme compat lower bound to the GNNlib and GNN test projects. - Stop exporting the unused `TEST_ENZYME`, fix the EvolveGCNOCell comment, and revert unrelated whitespace changes. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
|
thanks @Parvm1102, this concludes a lot of work. so Enzyme integration is quite established, except for the few dark corners mentioned in #757 |
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:
The Dense failures and DConv will only require simple fixes.