# \#enzyme

**URL:** https://discourse.julialang.org/tag/enzyme/890.md

[Latest](https://discourse.julialang.org/latest.md) · [Categories](https://discourse.julialang.org/categories.md) · [Tags](https://discourse.julialang.org/tags.md)

---

## [EnzymeCon3 Planning Survey](https://discourse.julialang.org/t/enzymecon3-planning-survey/139173)

<div class="topic-metadata">

**Author:** [@wsmoses](https://discourse.julialang.org/u/wsmoses)\
**Replies:** 0\
**Last updated:** [September 2, 2026, 8:00pm UTC](https://discourse.julialang.org/t/enzymecon3-planning-survey/139173 "2026-09-02T20:00:21Z")

</div>

Hey folks, we’re in the process of planning EnzymeCon3. If you’re potentially interested in the event (or have ideas/feedback you’d like to share), please fill out this survey. All work related to the greater Enzyme c…

---

## [Where do these NaNs in my KernelAbstraction derivative come from?](https://discourse.julialang.org/t/where-do-these-nans-in-my-kernelabstraction-derivative-come-from/139105)

<div class="topic-metadata">

**Author:** [@rkube](https://discourse.julialang.org/u/rkube)\
**Replies:** 0\
**Last updated:** [August 30, 2026, 5:35pm UTC](https://discourse.julialang.org/t/where-do-these-nans-in-my-kernelabstraction-derivative-come-from/139105 "2026-08-30T17:35:37Z")

</div>

Hi, I (mostly chatgpt though) am working on an MHD code using KernelAbstractions.jl, Reactant.jl and Enzyme.jl. In one step, a kernel derivative produces NaNs whereas the reactant gradient using plain arrays gives corre…

---

## [AD using Enzyme in ODE problem with DataInterpolations](https://discourse.julialang.org/t/ad-using-enzyme-in-ode-problem-with-datainterpolations/137771)

<div class="topic-metadata">

**Author:** [@imre](https://discourse.julialang.org/u/imre)\
**Replies:** 3\
**Last updated:** [June 29, 2026, 7:47am UTC](https://discourse.julialang.org/t/ad-using-enzyme-in-ode-problem-with-datainterpolations/137771 "2026-06-29T07:47:07Z")

</div>

Hello, I have an ODE problem which uses DataInterpolations.jl to obtain input values for the system at specific timepoints in order to compute dx. I want to use Enzyme.jl to compute the gradients with respect to paramete…

---

## [Auto-differentiation of Numba LLVM IR using Enzyme.jl: linear algebra and opaque external functions](https://discourse.julialang.org/t/auto-differentiation-of-numba-llvm-ir-using-enzyme-jl-linear-algebra-and-opaque-external-functions/137799)

<div class="topic-metadata">

**Author:** [@ymardoukhi](https://discourse.julialang.org/u/ymardoukhi)\
**Replies:** 0\
**Last updated:** [June 25, 2026, 12:43pm UTC](https://discourse.julialang.org/t/auto-differentiation-of-numba-llvm-ir-using-enzyme-jl-linear-algebra-and-opaque-external-functions/137799 "2026-06-25T12:43:56Z")

</div>

This is related to the thread Get Numba LLVM IR differentiated in Julia using Enzyme.jl: differentiating Python functions decorated as Numba CFunc functions. I am sorry that this thread is quite long, but I tried to be a…

---

## [Enzyme/Reactant: second-order AD (Laplacian) not working with Lux on GPU](https://discourse.julialang.org/t/enzyme-reactant-second-order-ad-laplacian-not-working-with-lux-on-gpu/136444)

<div class="topic-metadata">

**Author:** [@Ferran\_Mazzanti](https://discourse.julialang.org/u/Ferran_Mazzanti)\
**Replies:** 5\
**Last updated:** [April 1, 2026, 6:39am UTC](https://discourse.julialang.org/t/enzyme-reactant-second-order-ad-laplacian-not-working-with-lux-on-gpu/136444 "2026-04-01T06:39:23Z")

</div>

Hi all, I’m implementing VMC (Variational Monte Carlo) for quantum many-body systems in the continuum, where I need to compute the Laplacian ∇²logψ/ψ of a neural network wavefunction. I’m trying to use Lux + Reactant +…

---

## [Custom rule for an implicit function in Enzyme](https://discourse.julialang.org/t/custom-rule-for-an-implicit-function-in-enzyme/136259)

<div class="topic-metadata">

**Author:** [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)\
**Replies:** 3\
**Last updated:** [March 25, 2026, 12:01pm UTC](https://discourse.julialang.org/t/custom-rule-for-an-implicit-function-in-enzyme/136259 "2026-03-25T12:01:04Z")

</div>

Consider an implicit function y = f(x) defined via g(x, y) where x, y \\in \\mathbb{R}^n. The user supplies f!(y, x) and g!(r, x, y) as callables, which are wrapped in a struct SquareImplicitFunction{F,G} f!::F …

---

## [DifferentiationInterface not generating correct shadow](https://discourse.julialang.org/t/differentiationinterface-not-generating-correct-shadow/131868)

<div class="topic-metadata">

**Author:** [@alexl123](https://discourse.julialang.org/u/alexl123)\
**Replies:** 11\
**Last updated:** [January 4, 2026, 9:01am UTC](https://discourse.julialang.org/t/differentiationinterface-not-generating-correct-shadow/131868 "2026-01-04T09:01:42Z")

</div>

Hello! I am trying to play with the Sophia optimization algorthim. I am storing my parameters as a ComponentArray since some parameters are scalar and others are vectors. When I use a first order method (Adam) I have no…

---

## [Lux/Enzyme error when Training my model?](https://discourse.julialang.org/t/lux-enzyme-error-when-training-my-model/133442)

<div class="topic-metadata">

**Author:** [@rkube](https://discourse.julialang.org/u/rkube)\
**Replies:** 9\
**Last updated:** [November 2, 2025, 1:44am UTC](https://discourse.julialang.org/t/lux-enzyme-error-when-training-my-model/133442 "2025-11-02T01:44:19Z")

</div>

Hi, I’m trying to get a simple language model to train using Lux/Enzyme and get a big scary error. Does anyone have insight into how to get to the bottom of this? Is there an error in the MWE? I tried Zygote and it run…

---

## [Issue: Enzyme + Flux double differentiation on custom layer](https://discourse.julialang.org/t/issue-enzyme-flux-double-differentiation-on-custom-layer/133503)

<div class="topic-metadata">

**Author:** [@Gianmarco](https://discourse.julialang.org/u/Gianmarco)\
**Replies:** 3\
**Last updated:** [October 30, 2025, 1:52am UTC](https://discourse.julialang.org/t/issue-enzyme-flux-double-differentiation-on-custom-layer/133503 "2025-10-30T01:52:28Z")

</div>

Hi, I’m using Flux and Enzyme for a project, and the entire architecture is built on top of these two libraries. So unless strictly necessary, I’d like to stay within the Flux/Enzyme ecosystem. For both libraries i’m u…

---

## [New "easy rule" system for Enzyme](https://discourse.julialang.org/t/new-easy-rule-system-for-enzyme/133522)

<div class="topic-metadata">

**Author:** [@gdalle](https://discourse.julialang.org/u/gdalle)\
**Replies:** 4\
**Last updated:** [October 29, 2025, 9:27pm UTC](https://discourse.julialang.org/t/new-easy-rule-system-for-enzyme/133522 "2025-10-29T21:27:57Z")

</div>

Hi there @wsmoses and friends, Thanks for the new easy rule system! Making rules more accessible is a great idea to get more people into autodiff (that’s how I got hooked in the first place). I’m curious to understand …

---

## [Make mutating function more AD-friendly](https://discourse.julialang.org/t/make-mutating-function-more-ad-friendly/133356)

<div class="topic-metadata">

**Author:** [@MrMR](https://discourse.julialang.org/u/MrMR)\
**Replies:** 10\
**Last updated:** [October 23, 2025, 9:52am UTC](https://discourse.julialang.org/t/make-mutating-function-more-ad-friendly/133356 "2025-10-23T09:52:03Z")

</div>

Dear all, since this is my first post, I want to thank you for the help I got in many years I used Julia (I always found the answer to my problems in previous posts!). Diving into the problem: what I need to do is to …

---

## [Code coverage not tracking custom EnzymeRules.augmented\_primal and EnzymeRules.reverse implementations](https://discourse.julialang.org/t/code-coverage-not-tracking-custom-enzymerules-augmented-primal-and-enzymerules-reverse-implementations/133359)

<div class="topic-metadata">

**Author:** [@kongdd](https://discourse.julialang.org/u/kongdd)\
**Replies:** 2\
**Last updated:** [October 23, 2025, 3:08am UTC](https://discourse.julialang.org/t/code-coverage-not-tracking-custom-enzymerules-augmented-primal-and-enzymerules-reverse-implementations/133359 "2025-10-23T03:08:39Z")

</div>

I’m working on a package that implements custom autodiff rules for Enzyme. I’ve defined augmented\_primal and reverse methods for EnzymeRules. These functions are called indirectly through autodiff. When I run my te…

---

## [Type instability in custom Lux masking layer when using Enzyme/Reactant](https://discourse.julialang.org/t/type-instability-in-custom-lux-masking-layer-when-using-enzyme-reactant/133042)

<div class="topic-metadata">

**Author:** [@pietro-butti](https://discourse.julialang.org/u/pietro-butti)\
**Replies:** 5\
**Last updated:** [October 10, 2025, 5:25pm UTC](https://discourse.julialang.org/t/type-instability-in-custom-lux-masking-layer-when-using-enzyme-reactant/133042 "2025-10-10T17:25:01Z")

</div>

I’m encountering issues when implementing a custom Lux layer that performs masking (as commonly used in RealNVPs). Example in 1D with checkerboard masking: \[x1, x2, x3, x4\] → (\[x1,0,x3,0\], \[0,x2,0,x4\]) Goal I want to …

---

## [KernelAbstractions + Enzyme - how to do GPU-side autodiff?](https://discourse.julialang.org/t/kernelabstractions-enzyme-how-to-do-gpu-side-autodiff/132643)

<div class="topic-metadata">

**Author:** [@jl\_enthusiast](https://discourse.julialang.org/u/jl_enthusiast)\
**Replies:** 1\
**Last updated:** [September 25, 2025, 6:34am UTC](https://discourse.julialang.org/t/kernelabstractions-enzyme-how-to-do-gpu-side-autodiff/132643 "2025-09-25T06:34:49Z")

</div>

Hello, I recently tried to (and failed) to auto-differentiate kernels with Enzyme.jl, written using KernelAbstractions.jl. I tried to search for examples in other packages, but could not find any concrete examples of E…

---

## [Preventing Enzyme from differentiating through constant computations](https://discourse.julialang.org/t/preventing-enzyme-from-differentiating-through-constant-computations/132445)

<div class="topic-metadata">

**Author:** [@dameka](https://discourse.julialang.org/u/dameka)\
**Replies:** 1\
**Last updated:** [September 16, 2025, 5:58pm UTC](https://discourse.julialang.org/t/preventing-enzyme-from-differentiating-through-constant-computations/132445 "2025-09-16T17:58:27Z")

</div>

I am training a neural network by computing the gradient of the loss with Enzyme. Part of my computations involve associated Legendre polynomials. I did not believe these to be a crucial part of the differentiation becau…

---

## [Error in Using DataInterpolations.jl and Enzyme.jl for Real-Time Interpolation and Gradient Computation in ODE Problems](https://discourse.julialang.org/t/error-in-using-datainterpolations-jl-and-enzyme-jl-for-real-time-interpolation-and-gradient-computation-in-ode-problems/132244)

<div class="topic-metadata">

**Author:** [@chooron](https://discourse.julialang.org/u/chooron)\
**Replies:** 1\
**Last updated:** [September 12, 2025, 12:05pm UTC](https://discourse.julialang.org/t/error-in-using-datainterpolations-jl-and-enzyme-jl-for-real-time-interpolation-and-gradient-computation-in-ode-problems/132244 "2025-09-12T12:05:57Z")

</div>

Hello, I currently have an ODE problem where I need to use DataInterpolations.jl to interpolate and obtain real-time values, which are then used for computing du. Next, I need to use Enzyme.jl to compute the gradients of…

---

## [Autodifferentiation with FFT, with Enzyme?](https://discourse.julialang.org/t/autodifferentiation-with-fft-with-enzyme/128674)

<div class="topic-metadata">

**Author:** [@jtravs](https://discourse.julialang.org/u/jtravs)\
**Replies:** 13\
**Last updated:** [September 9, 2025, 3:25pm UTC](https://discourse.julialang.org/t/autodifferentiation-with-fft-with-enzyme/128674 "2025-09-09T15:25:34Z")

</div>

Hi, I’m trying to use autodifferentiation (for gradients, jacobians), working with a complex code that uses a lot of array mutation, custom structs, and FFTs (using FFTW). I got a small part of my code working by making…

---

## [New LLVM error introduced in Enzyme v0.13.69](https://discourse.julialang.org/t/new-llvm-error-introduced-in-enzyme-v0-13-69/132080)

<div class="topic-metadata">

**Author:** [@dameka](https://discourse.julialang.org/u/dameka)\
**Replies:** 3\
**Last updated:** [September 3, 2025, 9:29pm UTC](https://discourse.julialang.org/t/new-llvm-error-introduced-in-enzyme-v0-13-69/132080 "2025-09-03T21:29:25Z")

</div>

I recently updated my Enzyme package version from 0.13.68 (fully working) and incurred a new kind of bug I haven’t encountered before. I verified this bug exists in all versions of Enzyme since 0.13.69 inclusive. I am no…

---

## [Using Reactant with Lux and Enzyme to speed up training in physics context](https://discourse.julialang.org/t/using-reactant-with-lux-and-enzyme-to-speed-up-training-in-physics-context/131898)

<div class="topic-metadata">

**Author:** [@dameka](https://discourse.julialang.org/u/dameka)\
**Replies:** 16\
**Last updated:** [August 28, 2025, 8:56pm UTC](https://discourse.julialang.org/t/using-reactant-with-lux-and-enzyme-to-speed-up-training-in-physics-context/131898 "2025-08-28T20:56:28Z")

</div>

I am training a neural network in a physical context on observables; crucially, the network is producing values which are passed through some physics calculations before being compared to the training data. My code works…

---

## [Lux + Enzyme naively applying model seems to cause runtime activity error](https://discourse.julialang.org/t/lux-enzyme-naively-applying-model-seems-to-cause-runtime-activity-error/131531)

<div class="topic-metadata">

**Author:** [@r0uv3n](https://discourse.julialang.org/u/r0uv3n)\
**Replies:** 23\
**Last updated:** [August 25, 2025, 10:56am UTC](https://discourse.julialang.org/t/lux-enzyme-naively-applying-model-seems-to-cause-runtime-activity-error/131531 "2025-08-25T10:56:54Z")

</div>

Consider the simple setup using Lux, LinearAlgebra import Optimization, Random, Enzyme, ComponentArrays model = Chain( Dense(2 =\> 16, Lux.tanh), Dense(16, 1), ) parameters, states = Lux.setup(Random.Xoshiro(42…

---

## [Get Numba LLVM IR differentiated in Julia using Enzyme.jl](https://discourse.julialang.org/t/get-numba-llvm-ir-differentiated-in-julia-using-enzyme-jl/131255)

<div class="topic-metadata">

**Author:** [@ymardoukhi](https://discourse.julialang.org/u/ymardoukhi)\
**Replies:** 15\
**Last updated:** [August 8, 2025, 9:12am UTC](https://discourse.julialang.org/t/get-numba-llvm-ir-differentiated-in-julia-using-enzyme-jl/131255 "2025-08-08T09:12:25Z")

</div>

I have seen scarce material regarding Numba and Enzyme, e.g. this Numba GitHub issue or this talk at Enzyme conference 2023. I have this simple cosine function in Python, wrapped around the numba.@cfunc decorator. From …

---

## [Differentiation of struct based simulations and applications](https://discourse.julialang.org/t/differentiation-of-struct-based-simulations-and-applications/131319)

<div class="topic-metadata">

**Author:** [@stevenhughes](https://discourse.julialang.org/u/stevenhughes)\
**Replies:** 5\
**Last updated:** [August 5, 2025, 12:03pm UTC](https://discourse.julialang.org/t/differentiation-of-struct-based-simulations-and-applications/131319 "2025-08-05T12:03:54Z")

</div>

Hello, I’m building an aerospace simulator and solver in Julia. It’s coming together well, and I plan to release the first public version in about a month. The system models spacecraft, maneuvers, events, and so on, and…

---

## [Reverse rule in Enzyme for an implicit function](https://discourse.julialang.org/t/reverse-rule-in-enzyme-for-an-implicit-function/131327)

<div class="topic-metadata">

**Author:** [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)\
**Replies:** 2\
**Last updated:** [August 4, 2025, 1:19pm UTC](https://discourse.julialang.org/t/reverse-rule-in-enzyme-for-an-implicit-function/131327 "2025-08-04T13:19:08Z")

</div>

Suppose H is the cdf of a distribution, A, B are real numbers, and p is defined by p = H(p A + (1 - p) B) This can be implemented simply in Julia as using Roots, Distributions struct Problem{T,S} H::T A::S …

---

## [Using Enzyme.jl with Flux: Issues Computing Gradients of a Model with Duplicated Parameters and Mixed Forward/Reverse AD](https://discourse.julialang.org/t/using-enzyme-jl-with-flux-issues-computing-gradients-of-a-model-with-duplicated-parameters-and-mixed-forward-reverse-ad/131135)

<div class="topic-metadata">

**Author:** [@Gianmarco](https://discourse.julialang.org/u/Gianmarco)\
**Replies:** 11\
**Last updated:** [July 29, 2025, 11:23pm UTC](https://discourse.julialang.org/t/using-enzyme-jl-with-flux-issues-computing-gradients-of-a-model-with-duplicated-parameters-and-mixed-forward-reverse-ad/131135 "2025-07-29T23:23:35Z")

</div>

Hi everyone, I’m trying to use Enzyme.jl to compute gradients for a Flux model during training. My goal is to differentiate a custom loss function that combines a regular mean squared error term with an additional gradi…

---

## [A custom type-stable regularization function in Lux & Enzyme](https://discourse.julialang.org/t/a-custom-type-stable-regularization-function-in-lux-enzyme/129984)

<div class="topic-metadata">

**Author:** [@user22](https://discourse.julialang.org/u/user22)\
**Replies:** 0\
**Last updated:** [June 18, 2025, 9:44am UTC](https://discourse.julialang.org/t/a-custom-type-stable-regularization-function-in-lux-enzyme/129984 "2025-06-18T09:44:39Z")

</div>

We are trying to develop a custom regularization function for the biases and weights of a simple dense neural network in Lux. However, we have not found a way to establish type-stable gradient computation for Lux and Enz…

---

## [Loading resampled data for PINN in Reactant + Enzyme + Lux](https://discourse.julialang.org/t/loading-resampled-data-for-pinn-in-reactant-enzyme-lux/129974)

<div class="topic-metadata">

**Author:** [@NoFishLikeIan](https://discourse.julialang.org/u/NoFishLikeIan)\
**Replies:** 2\
**Last updated:** [June 17, 2025, 10:58pm UTC](https://discourse.julialang.org/t/loading-resampled-data-for-pinn-in-reactant-enzyme-lux/129974 "2025-06-17T22:58:15Z")

</div>

I am implementing a neural network using Lux and Reactant + Enzyme. At each epoch, I need to resample the data, divide it in batches, and take a training step. For now, I am working on a CPU. What is the best way to do t…

---

## [Error when using Enzyme to train a model with frozen layers](https://discourse.julialang.org/t/error-when-using-enzyme-to-train-a-model-with-frozen-layers/129646)

<div class="topic-metadata">

**Author:** [@demco](https://discourse.julialang.org/u/demco)\
**Replies:** 2\
**Last updated:** [June 5, 2025, 1:51pm UTC](https://discourse.julialang.org/t/error-when-using-enzyme-to-train-a-model-with-frozen-layers/129646 "2025-06-05T13:51:50Z")

</div>

Hi, I am using Julia to solve a 1D poisson equation using a shallow 1 layer PINN, I have successfully implemented a code based on the 2D PINN tutorial on the Lux website. Out of curiosity, I wanted to experiment with fr…

---

## [Passing a Cache to optimization function](https://discourse.julialang.org/t/passing-a-cache-to-optimization-function/129321)

<div class="topic-metadata">

**Author:** [@miguelborrero](https://discourse.julialang.org/u/miguelborrero)\
**Replies:** 21\
**Last updated:** [May 29, 2025, 6:24pm UTC](https://discourse.julialang.org/t/passing-a-cache-to-optimization-function/129321 "2025-05-29T18:24:57Z")

</div>

Hi! In my original problem the computation of the objective value function is expensive and during the computation I can collaterally compute the constraints of my problem. To make my problem more efficient I tried to i…

---

## [Enzyme.jl Critical Issues with Basic Arithmetic Operations in Automatic Differentiation](https://discourse.julialang.org/t/enzyme-jl-critical-issues-with-basic-arithmetic-operations-in-automatic-differentiation/129216)

<div class="topic-metadata">

**Author:** [@mra](https://discourse.julialang.org/u/mra)\
**Replies:** 7\
**Last updated:** [May 26, 2025, 12:59pm UTC](https://discourse.julialang.org/t/enzyme-jl-critical-issues-with-basic-arithmetic-operations-in-automatic-differentiation/129216 "2025-05-26T12:59:59Z")

</div>

According to the Enzyme.jl documentation the “Enzyme differentiates arbitrary multivariate vector functions as the most general case in automatic differentiation”, however I encountered critical errors (including the ker…

---

## [Enzyme reverse mode not working](https://discourse.julialang.org/t/enzyme-reverse-mode-not-working/129281)

<div class="topic-metadata">

**Author:** [@miguelborrero](https://discourse.julialang.org/u/miguelborrero)\
**Replies:** 4\
**Last updated:** [May 23, 2025, 7:08pm UTC](https://discourse.julialang.org/t/enzyme-reverse-mode-not-working/129281 "2025-05-23T19:08:52Z")

</div>

Hi there, I am struggling to get Enzyme working on a simplified version of my simulation. Here I give the code I’m running along with the error. My data is stored in an array of Student structs: using Enzyme using Sp…

[Next page](https://discourse.julialang.org/tag/enzyme/890.md?match_all_tags=true&page=1&tags%5B%5D=enzyme)
