# \#enzyme

**URL:** https://discourse.julialang.org/tag/enzyme/890.md?page=1

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

**Page:** 2

---

## [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…

---

## [Trouble precompiling with Enzyme](https://discourse.julialang.org/t/trouble-precompiling-with-enzyme/129143)

<div class="topic-metadata">

**Author:** [@jtravs](https://discourse.julialang.org/u/jtravs)\
**Replies:** 1\
**Last updated:** [May 19, 2025, 2:11pm UTC](https://discourse.julialang.org/t/trouble-precompiling-with-enzyme/129143 "2025-05-19T14:11:05Z")

</div>

Hi All, I am struggling to get precompilation working with Enzyme.jl. My package works fine without any precompile statements at the top level. But if I add some package function calls within my top-level module, I get …

---

## [Issue with Optimization.LBFGS](https://discourse.julialang.org/t/issue-with-optimization-lbfgs/129076)

<div class="topic-metadata">

**Author:** [@miguelborrero](https://discourse.julialang.org/u/miguelborrero)\
**Replies:** 1\
**Last updated:** [May 16, 2025, 8:14pm UTC](https://discourse.julialang.org/t/issue-with-optimization-lbfgs/129076 "2025-05-16T20:14:50Z")

</div>

Hi there, Disclaimer: I can not share the actual data or objective function so this might be a long shot but maybe the error itself has enough information. I am trying to optimize a function g with non-linear constrain…

---

## [Enzyme custom rule alloactions](https://discourse.julialang.org/t/enzyme-custom-rule-alloactions/128491)

<div class="topic-metadata">

**Author:** [@c\_sell](https://discourse.julialang.org/u/c_sell)\
**Replies:** 0\
**Last updated:** [April 28, 2025, 2:11pm UTC](https://discourse.julialang.org/t/enzyme-custom-rule-alloactions/128491 "2025-04-28T14:11:20Z")

</div>

Hello, I got a problem with allocations when using custom rules in Enzyme. The example below is just a toy example but the same problem arises there. In total I get 4 alloactions. 2 by the line primal = func.val(y.va…

---

## [Implementing Three-Dimensional Interpolation, ODEProblem, and Gradient Computation with sensealg=GaussAdjoint(autojacvec=EnzymeVJP())](https://discourse.julialang.org/t/implementing-three-dimensional-interpolation-odeproblem-and-gradient-computation-with-sensealg-gaussadjoint-autojacvec-enzymevjp/128204)

<div class="topic-metadata">

**Author:** [@chooron](https://discourse.julialang.org/u/chooron)\
**Replies:** 2\
**Last updated:** [April 20, 2025, 3:23am UTC](https://discourse.julialang.org/t/implementing-three-dimensional-interpolation-odeproblem-and-gradient-computation-with-sensealg-gaussadjoint-autojacvec-enzymevjp/128204 "2025-04-20T03:23:11Z")

</div>

Hello, the problem I am currently facing is solving an ordinary differential equation (ODE) with interpolated data inputs. The problem can be visualized as a snow layer, where the snow layer represents the intermediate s…

---

## [Enzyme with Const() on a vector throws an error](https://discourse.julialang.org/t/enzyme-with-const-on-a-vector-throws-an-error/121927)

<div class="topic-metadata">

**Author:** [@weltenbummler](https://discourse.julialang.org/u/weltenbummler)\
**Replies:** 20\
**Last updated:** [April 10, 2025, 3:53pm UTC](https://discourse.julialang.org/t/enzyme-with-const-on-a-vector-throws-an-error/121927 "2025-04-10T15:53:55Z")

</div>

Hello all, I would like to autodiff a function where some vector-valued arguments are kept constant. I thought to use Enzyme with the Const() functionality but run into issues when applying Const() to vectors. The fol…

---

## [Enzyme cannot deduce type for integral function in reverse mode AD](https://discourse.julialang.org/t/enzyme-cannot-deduce-type-for-integral-function-in-reverse-mode-ad/127822)

<div class="topic-metadata">

**Author:** [@jwalker](https://discourse.julialang.org/u/jwalker)\
**Replies:** 11\
**Last updated:** [April 9, 2025, 4:06pm UTC](https://discourse.julialang.org/t/enzyme-cannot-deduce-type-for-integral-function-in-reverse-mode-ad/127822 "2025-04-09T16:06:04Z")

</div>

Could someone explain why I’m getting the following error from this example? using Enzyme struct Parameters M::Int R::Real end function integrand2(v::Vector, nt::NamedTuple) x = v\[1\] y = v\[2\] θ = n…

---

## [Enzyme AD with matrix exponential](https://discourse.julialang.org/t/enzyme-ad-with-matrix-exponential/123094)

<div class="topic-metadata">

**Author:** [@stone44](https://discourse.julialang.org/u/stone44)\
**Replies:** 22\
**Last updated:** [April 6, 2025, 10:43pm UTC](https://discourse.julialang.org/t/enzyme-ad-with-matrix-exponential/123094 "2025-04-06T22:43:00Z")

</div>

Hey, I am currently trying to use Enzyme’s gradient function to get the gradient of a quantum mechanical expectation value in respect to some parameters which go into the Hamiltonian. What causes a problem? AD with Enz…

---

## [Enzyme computing the Hessian(?)](https://discourse.julialang.org/t/enzyme-computing-the-hessian/127197)

<div class="topic-metadata">

**Author:** [@miguelborrero](https://discourse.julialang.org/u/miguelborrero)\
**Replies:** 6\
**Last updated:** [March 22, 2025, 7:26am UTC](https://discourse.julialang.org/t/enzyme-computing-the-hessian/127197 "2025-03-22T07:26:07Z")

</div>

Hi there! It seems like the (fantastic!) package Enzyme supports the computation of the Hessian times a vector but not the Hessian itself. Is this just a matter of time? or is the Hessian too expensive as to implement i…

---

## [What are the effects of maxtypeoffset! and maxtypedepth! in Enzyme?](https://discourse.julialang.org/t/what-are-the-effects-of-maxtypeoffset-and-maxtypedepth-in-enzyme/127039)

<div class="topic-metadata">

**Author:** [@ToPo](https://discourse.julialang.org/u/ToPo)\
**Replies:** 0\
**Last updated:** [March 17, 2025, 4:19am UTC](https://discourse.julialang.org/t/what-are-the-effects-of-maxtypeoffset-and-maxtypedepth-in-enzyme/127039 "2025-03-17T04:19:31Z")

</div>

I use automatic differentiation by Enzyme.jl. What are the functions of the two APIs, maxtypeoffset! and maxtypedepth! ? I want to use these APIs to stabilize the operation of the Enzyme.jl. maxtypeoffset! What is …

---

## [Lux + Enzyme and Zygote + NeuralODE, segmentation fault](https://discourse.julialang.org/t/lux-enzyme-and-zygote-neuralode-segmentation-fault/123645)

<div class="topic-metadata">

**Author:** [@vleon1234](https://discourse.julialang.org/u/vleon1234)\
**Replies:** 6\
**Last updated:** [March 3, 2025, 10:26pm UTC](https://discourse.julialang.org/t/lux-enzyme-and-zygote-neuralode-segmentation-fault/123645 "2025-03-03T22:26:40Z")

</div>

Hi all, I’m using Julia v1.11.2, and installed the used packages on 12/6 (last Friday), so I assume I have the most recent package versions. I’ve been following along the SciML tutorials for Neural ordinary differentia…

---

## [Enzyme - Incorrect (?) Forward results on function that returns a literal value within a tuple](https://discourse.julialang.org/t/enzyme-incorrect-forward-results-on-function-that-returns-a-literal-value-within-a-tuple/126443)

<div class="topic-metadata">

**Author:** [@jl\_enthusiast](https://discourse.julialang.org/u/jl_enthusiast)\
**Replies:** 3\
**Last updated:** [March 1, 2025, 2:35am UTC](https://discourse.julialang.org/t/enzyme-incorrect-forward-results-on-function-that-returns-a-literal-value-within-a-tuple/126443 "2025-03-01T02:35:45Z")

</div>

The issue can be reduced to the following semi-MWE: Consider a function that return a literal number, and some vector(s): using Enzyme function tester(x::AbstractVector{T}) where T return (T(pi), sum(x), x.^2) end…

---

## [Making Enzyme.jl work with the integrator interface of OrdinaryDiffEq.jl](https://discourse.julialang.org/t/making-enzyme-jl-work-with-the-integrator-interface-of-ordinarydiffeq-jl/126186)

<div class="topic-metadata">

**Author:** [@Rittick\_Roy](https://discourse.julialang.org/u/Rittick_Roy)\
**Replies:** 11\
**Last updated:** [February 25, 2025, 1:30pm UTC](https://discourse.julialang.org/t/making-enzyme-jl-work-with-the-integrator-interface-of-ordinarydiffeq-jl/126186 "2025-02-25T13:30:33Z")

</div>

I’m new to using autodiff in Julia and have some issues making Enzyme.jl work with OrdinaryDiffEq.jl. I want to take the a reverse mode derivative of my differential equation solution with respect to the input parameter …

---

## [Custom loss functions in \`Lux.jl\`](https://discourse.julialang.org/t/custom-loss-functions-in-lux-jl/125661)

<div class="topic-metadata">

**Author:** [@jamblejoe](https://discourse.julialang.org/u/jamblejoe)\
**Replies:** 5\
**Last updated:** [February 10, 2025, 4:28pm UTC](https://discourse.julialang.org/t/custom-loss-functions-in-lux-jl/125661 "2025-02-10T16:28:29Z")

</div>

I am currently getting accustomed to the Lux.jl package. I want to use a custom loss function which includes a l\_2-regression term consisting of the model weights. I defined my custom loss function as function loss\_func…

---

## [Automatic differentiation minisymposium at JuliaCon](https://discourse.julialang.org/t/automatic-differentiation-minisymposium-at-juliacon/125145)

<div class="topic-metadata">

**Author:** [@gdalle](https://discourse.julialang.org/u/gdalle)\
**Replies:** 0\
**Last updated:** [January 23, 2025, 8:08pm UTC](https://discourse.julialang.org/t/automatic-differentiation-minisymposium-at-juliacon/125145 "2025-01-23T20:08:44Z")

</div>

Some love Julia for its speed. Some love it for its scientific computing packages. Some love it because the people are nice. But we love it for one reason and one reason only: because it makes our gradients go brrrrr …

---

## [Kalman Filter with Enzyme](https://discourse.julialang.org/t/kalman-filter-with-enzyme/124264)

<div class="topic-metadata">

**Author:** [@charlesknipp](https://discourse.julialang.org/u/charlesknipp)\
**Replies:** 3\
**Last updated:** [January 3, 2025, 8:10pm UTC](https://discourse.julialang.org/t/kalman-filter-with-enzyme/124264 "2025-01-03T20:10:49Z")

</div>

Consider the simple problem of MLE on a linear Gaussian state space model using a Kalman filter. When properly designed, automatic differentiation should be a trivial task for achieving a log score; and for most backends…

---

## [Enzyme strange output for hessian](https://discourse.julialang.org/t/enzyme-strange-output-for-hessian/123899)

<div class="topic-metadata">

**Author:** [@c\_sell](https://discourse.julialang.org/u/c_sell)\
**Replies:** 0\
**Last updated:** [December 16, 2024, 7:31pm UTC](https://discourse.julialang.org/t/enzyme-strange-output-for-hessian/123899 "2024-12-16T19:31:25Z")

</div>

Hello, I get for the following small example the strage output: freeing without malloc %53 = call noalias nonnull dereferenceable(32) dereferenceable\_or\_null(32) i8\* @malloc(i64 noundef 32) #20, !enzyme\_cache\_alloc !5…

---

## [Universal differential equations (UDE) with modern SciML stack (Lux, Enzyme, ...)](https://discourse.julialang.org/t/universal-differential-equations-ude-with-modern-sciml-stack-lux-enzyme/120869)

<div class="topic-metadata">

**Author:** [@nurban](https://discourse.julialang.org/u/nurban)\
**Replies:** 6\
**Last updated:** [December 10, 2024, 9:59pm UTC](https://discourse.julialang.org/t/universal-differential-equations-ude-with-modern-sciml-stack-lux-enzyme/120869 "2024-12-10T21:59:31Z")

</div>

I am interested in implementing training universal partial differential equation (UPDE) systems. I understand from @ChrisRackauckas that the SciML ecosystem is increasingly moving toward Lux and Enzyme. (And which opti…

---

## [Speed of Nested AD in Enzyme](https://discourse.julialang.org/t/speed-of-nested-ad-in-enzyme/123018)

<div class="topic-metadata">

**Author:** [@turiya](https://discourse.julialang.org/u/turiya)\
**Replies:** 8\
**Last updated:** [November 30, 2024, 11:26am UTC](https://discourse.julialang.org/t/speed-of-nested-ad-in-enzyme/123018 "2024-11-30T11:26:35Z")

</div>

I am trying to implement nested AD in Enzyme for application in PINNs. The following is a MWE. using Enzyme, Lux, Random, ComponentArrays, LinearAlgebra n = 100 x\_batch = randn(2, n) y\_batch = randn(2, n) model = Chain(…

---

## [Enzyme Autodiff readonly error and working with batches of data](https://discourse.julialang.org/t/enzyme-autodiff-readonly-error-and-working-with-batches-of-data/123012)

<div class="topic-metadata">

**Author:** [@turiya](https://discourse.julialang.org/u/turiya)\
**Replies:** 14\
**Last updated:** [November 26, 2024, 2:28pm UTC](https://discourse.julialang.org/t/enzyme-autodiff-readonly-error-and-working-with-batches-of-data/123012 "2024-11-26T14:28:35Z")

</div>

I have the following MWE using Enzyme, Lux, Random n = 10 x\_batch = randn(2,n) y\_batch = randn(2,n) model = Chain(Parallel(vcat, Dense(2, 1, tanh), Dense(2,1,tanh)), Dense(2,1,tanh)) rng = Random.default\_rng() Random.se…

---

## [How to differentiate using Enzyme.jl?](https://discourse.julialang.org/t/how-to-differentiate-using-enzyme-jl/122765)

<div class="topic-metadata">

**Author:** [@albertomercurio](https://discourse.julialang.org/u/albertomercurio)\
**Replies:** 7\
**Last updated:** [November 18, 2024, 7:02pm UTC](https://discourse.julialang.org/t/how-to-differentiate-using-enzyme-jl/122765 "2024-11-18T19:02:34Z")

</div>

Hello, I don’t really understand how Enzyme.jl actually works. I more or less understand that the Const arguments are not considered in the differentiation, and that Active and Duplicated are used otherwise. Duplicated …

---

## [SciMLSensitivity.jl Precompile error because of Enzyme](https://discourse.julialang.org/t/scimlsensitivity-jl-precompile-error-because-of-enzyme/122561)

<div class="topic-metadata">

**Author:** [@erny123](https://discourse.julialang.org/u/erny123)\
**Replies:** 11\
**Last updated:** [November 12, 2024, 10:00pm UTC](https://discourse.julialang.org/t/scimlsensitivity-jl-precompile-error-because-of-enzyme/122561 "2024-11-12T22:00:20Z")

</div>

Edit: Issue opened with Trixi.jl Trixi forcing downgrades when using Enzyme.jl, Zygote.jl, SciMLsensitivity.jl · Issue #2157 · trixi-framework/Trixi.jl Trying to follow along this the SciMLSensitivity.jl tutorial: Pa…

---

## [Autodiff using custom Structs](https://discourse.julialang.org/t/autodiff-using-custom-structs/121143)

<div class="topic-metadata">

**Author:** [@thealanjason](https://discourse.julialang.org/u/thealanjason)\
**Replies:** 1\
**Last updated:** [October 20, 2024, 11:30pm UTC](https://discourse.julialang.org/t/autodiff-using-custom-structs/121143 "2024-10-20T23:30:10Z")

</div>

Hello everyone, I want to be able to use Enzyme to differentiate a scalar-valued function with respect to only part of the fields of an arbitrary struct. As an example, in my MWE below, I would like to differentiate th…

---

## [Using NonlinearSolve with autodiff](https://discourse.julialang.org/t/using-nonlinearsolve-with-autodiff/121333)

<div class="topic-metadata">

**Author:** [@albertomercurio](https://discourse.julialang.org/u/albertomercurio)\
**Replies:** 9\
**Last updated:** [October 17, 2024, 9:18pm UTC](https://discourse.julialang.org/t/using-nonlinearsolve-with-autodiff/121333 "2024-10-17T21:18:38Z")

</div>

Hello, I was trying to test NonlinearSolve.jl with automatic differentiation like Enzyme.jl or Zygote.jl. But the following simple code fails f(x, p) = p.a \* x^2 - p.b prob = NonlinearProblem(f, 0.0, (a=1.0, b=2.0)) so…

---

## [Enzyme: Autodiff Functor which contains cache](https://discourse.julialang.org/t/enzyme-autodiff-functor-which-contains-cache/121105)

<div class="topic-metadata">

**Author:** [@hexaeder](https://discourse.julialang.org/u/hexaeder)\
**Replies:** 2\
**Last updated:** [October 9, 2024, 1:41pm UTC](https://discourse.julialang.org/t/enzyme-autodiff-functor-which-contains-cache/121105 "2024-10-09T13:41:38Z")

</div>

Hello, I have a RHS of an ODE in the form of a Functor which includes some caches, which i am trying to make Enzym compatible. Heres an MWE of the problem using Pkg pkg"activate --temp" pkg"add Enzyme, ForwardDiff, Pre…

---

## [\[ANN\] DifferentiationInterface - gradients for everyone](https://discourse.julialang.org/t/ann-differentiationinterface-gradients-for-everyone/113644)

<div class="topic-metadata">

**Author:** [@gdalle](https://discourse.julialang.org/u/gdalle)\
**Replies:** 5\
**Last updated:** [October 8, 2024, 10:19am UTC](https://discourse.julialang.org/t/ann-differentiationinterface-gradients-for-everyone/113644 "2024-10-08T10:19:29Z")

</div>

Julia’s composability has rather interesting consequences for its automatic differentiation ecosystem. Whereas Python programmers first choose a backend (like PyTorch or JAX) and then write code that is specifically tail…

---

## [Emulate Enzyme.Const with Zygote](https://discourse.julialang.org/t/emulate-enzyme-const-with-zygote/119594)

<div class="topic-metadata">

**Author:** [@gdalle](https://discourse.julialang.org/u/gdalle)\
**Replies:** 1\
**Last updated:** [September 19, 2024, 3:05pm UTC](https://discourse.julialang.org/t/emulate-enzyme-const-with-zygote/119594 "2024-09-19T15:05:39Z")

</div>

In the next release, DifferentiationInterface.jl will accept constant (non-differentiated) arguments c in addition to the active (differentiated) argument x, I’m wondering how to implement this mechanism optimally for ea…

---

## [Checkpointing.jl does not work in the latest version of Enzyme.jl](https://discourse.julialang.org/t/checkpointing-jl-does-not-work-in-the-latest-version-of-enzyme-jl/118660)

<div class="topic-metadata">

**Author:** [@ToPo](https://discourse.julialang.org/u/ToPo)\
**Replies:** 2\
**Last updated:** [September 9, 2024, 6:59am UTC](https://discourse.julialang.org/t/checkpointing-jl-does-not-work-in-the-latest-version-of-enzyme-jl/118660 "2024-09-09T06:59:46Z")

</div>

Recently, I have been using the checkpointing method to reduce the memory required for automatic differentiation. Therefore, we use Enzyme.jl and Checkpointing.jl. However, when I use the latest version of Enzyme.jl, v…

---

## [BatchDuplicated functions in Enzyme](https://discourse.julialang.org/t/batchduplicated-functions-in-enzyme/119001)

<div class="topic-metadata">

**Author:** [@gdalle](https://discourse.julialang.org/u/gdalle)\
**Replies:** 3\
**Last updated:** [September 3, 2024, 7:21pm UTC](https://discourse.julialang.org/t/batchduplicated-functions-in-enzyme/119001 "2024-09-03T19:21:34Z")

</div>

I’m using Enzyme to differentiate through a closure, and BatchDuplicated on the closure itself doesn’t seem to work, unlike Duplicated. using Enzyme struct MyClosure{A} a::A end function (mc::MyClosure)(x) # c…

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

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