# \#chainrules

**URL:** https://discourse.julialang.org/tag/chainrules/1124.md

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

---

## [Identical input in Zygote leads to different outputs](https://discourse.julialang.org/t/identical-input-in-zygote-leads-to-different-outputs/135120)

<div class="topic-metadata">

**Author:** [@Chrysoberyl](https://discourse.julialang.org/u/Chrysoberyl)\
**Replies:** 1\
**Last updated:** [January 19, 2026, 12:27am UTC](https://discourse.julialang.org/t/identical-input-in-zygote-leads-to-different-outputs/135120 "2026-01-19T00:27:54Z")

</div>

In this script, the forward pass has no error: using GNNGraphs, GraphNeuralNetworks, NNlib, Flux graph = GNNHeteroGraph( Dict( (:A, :a, :B) =\> (\[1, 2\], \[3, 4\]), (:B, :a, :A) =\> (\[1\], \[2\]), ); …

---

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

---

## [Rrule for zygote](https://discourse.julialang.org/t/rrule-for-zygote/131069)

<div class="topic-metadata">

**Author:** [@mary](https://discourse.julialang.org/u/mary)\
**Replies:** 7\
**Last updated:** [July 29, 2025, 1:37am UTC](https://discourse.julialang.org/t/rrule-for-zygote/131069 "2025-07-29T01:37:23Z")

</div>

Hi, I am using rrule for gradient calculation in zygote. I defined a function which calculates the gradients and I just call that function inside the entire gradient calculation. Can zygote handle this type of rule? fun…

---

## [ChainRules(TestUtils) slow on Mac (Github CI)?](https://discourse.julialang.org/t/chainrules-testutils-slow-on-mac-github-ci/122760)

<div class="topic-metadata">

**Author:** [@juthohaegeman](https://discourse.julialang.org/u/juthohaegeman)\
**Replies:** 0\
**Last updated:** [November 18, 2024, 9:47am UTC](https://discourse.julialang.org/t/chainrules-testutils-slow-on-mac-github-ci/122760 "2024-11-18T09:47:53Z")

</div>

Is there any known issue with the speed of ChainRules.jl or ChainRulesTestUtils.jl on MacOS, in particular on the Github CI runners? For our package TensorKit.jl, we have a quite extensive suite of tests that are ran vi…

---

## [Avoid storing intermediate results from the forward pass by default](https://discourse.julialang.org/t/avoid-storing-intermediate-results-from-the-forward-pass-by-default/119694)

<div class="topic-metadata">

**Author:** [@Jakub\_Mitura](https://discourse.julialang.org/u/Jakub_Mitura)\
**Replies:** 14\
**Last updated:** [September 29, 2024, 4:10pm UTC](https://discourse.julialang.org/t/avoid-storing-intermediate-results-from-the-forward-pass-by-default/119694 "2024-09-29T16:10:01Z")

</div>

Hello, Is it possible in Zygote to change the default behavior for computing derivatives during backpropagation to use gradient checkpointing? I have a memory-constrained problem with a Lux.jl model that uses Zygote fo…

---

## [Questions with building a chainrules for mutating array function](https://discourse.julialang.org/t/questions-with-building-a-chainrules-for-mutating-array-function/117237)

<div class="topic-metadata">

**Author:** [@chooron](https://discourse.julialang.org/u/chooron)\
**Replies:** 2\
**Last updated:** [July 22, 2024, 8:30am UTC](https://discourse.julialang.org/t/questions-with-building-a-chainrules-for-mutating-array-function/117237 "2024-07-22T08:30:42Z")

</div>

I want to build two functions for replacing values in a vector and an array, as shown below: function mutate\_vec(vec::AbstractVector{T}, new\_value::T, idx::Int) where {T} vec\[idx\] = new\_value vec end function m…

---

## [Add ForwardDiff rule to allow complex arguments\`](https://discourse.julialang.org/t/add-forwarddiff-rule-to-allow-complex-arguments/108821)

<div class="topic-metadata">

**Author:** [@weymouth](https://discourse.julialang.org/u/weymouth)\
**Replies:** 9\
**Last updated:** [January 15, 2024, 9:18pm UTC](https://discourse.julialang.org/t/add-forwarddiff-rule-to-allow-complex-arguments/108821 "2024-01-15T21:18:45Z")

</div>

I’m having trouble getting the derivative of a function which uses a complex variable internally. The key function is Di(x,y,T) = real(expintx(complex(-(1+T^2),(x+y\*T)\*√(1+T^2)))) which Zygote is happy to deal with, but …

---

## [Gradient accumulation using chainrulecore](https://discourse.julialang.org/t/gradient-accumulation-using-chainrulecore/104208)

<div class="topic-metadata">

**Author:** [@mary](https://discourse.julialang.org/u/mary)\
**Replies:** 1\
**Last updated:** [September 25, 2023, 2:20pm UTC](https://discourse.julialang.org/t/gradient-accumulation-using-chainrulecore/104208 "2023-09-25T14:20:15Z")

</div>

Hi, I am using chainrulecore and zygote and rrule to define my accumulation derivation formulation. the derivative of my function is ∑\_(i=1)^n▒〖w^t da/dr u〗 in order to solve this i have defined below code. Note that…

---

## [ChainRules for functions that "destroy their input arguments](https://discourse.julialang.org/t/chainrules-for-functions-that-destroy-their-input-arguments/103857)

<div class="topic-metadata">

**Author:** [@lkdvos](https://discourse.julialang.org/u/lkdvos)\
**Replies:** 1\
**Last updated:** [September 16, 2023, 10:31pm UTC](https://discourse.julialang.org/t/chainrules-for-functions-that-destroy-their-input-arguments/103857 "2023-09-16T22:31:38Z")

</div>

Some functions have the behaviour of using their inputs as workspace, and by doing so their documented behaviour is that they destroy the input. As an example, things like svd! work in such fashion. While in general, mu…

---

## [Second order derivatives with ChainRules](https://discourse.julialang.org/t/second-order-derivatives-with-chainrules/103606)

<div class="topic-metadata">

**Author:** [@mariusd](https://discourse.julialang.org/u/mariusd)\
**Replies:** 1\
**Last updated:** [September 7, 2023, 1:48pm UTC](https://discourse.julialang.org/t/second-order-derivatives-with-chainrules/103606 "2023-09-07T13:48:54Z")

</div>

How can I get the second order derivarive of a function using ChainRules? Bellow is my approach for the sin function. See the following code: using ChainRules using ChainRulesCore # from the docs, first derivative of …

---

## [Help with SparseArrays/ChainRules error](https://discourse.julialang.org/t/help-with-sparsearrays-chainrules-error/99425)

<div class="topic-metadata">

**Author:** [@ElOceanografo](https://discourse.julialang.org/u/ElOceanografo)\
**Replies:** 0\
**Last updated:** [May 26, 2023, 6:07am UTC](https://discourse.julialang.org/t/help-with-sparsearrays-chainrules-error/99425 "2023-05-26T06:07:01Z")

</div>

Ran into this error running code similar to this MWE, and was hoping someone who knows more about the AD ecosystem could help point me where to file an issue–is this a missing ChainRule, or overly-strict typing in Sparse…

---

## [Holomorphic function not being recognized as such by ChainRules.jl](https://discourse.julialang.org/t/holomorphic-function-not-being-recognized-as-such-by-chainrules-jl/95806)

<div class="topic-metadata">

**Author:** [@Hareruya](https://discourse.julialang.org/u/Hareruya)\
**Replies:** 2\
**Last updated:** [March 9, 2023, 5:11pm UTC](https://discourse.julialang.org/t/holomorphic-function-not-being-recognized-as-such-by-chainrules-jl/95806 "2023-03-09T17:11:56Z")

</div>

Greetings. I am currently trying to implement some code using @scalar\_rule for a custom gradient for a very important group of functions in Physics and Engineering, the spherical bessel functions, in this case particula…

---

## [Julia 1.8: ChainRules does not have Adapt in its dependencies](https://discourse.julialang.org/t/julia-1-8-chainrules-does-not-have-adapt-in-its-dependencies/86474)

<div class="topic-metadata">

**Author:** [@Xavier\_Gonzalez](https://discourse.julialang.org/u/Xavier_Gonzalez)\
**Replies:** 4\
**Last updated:** [August 30, 2022, 2:57pm UTC](https://discourse.julialang.org/t/julia-1-8-chainrules-does-not-have-adapt-in-its-dependencies/86474 "2022-08-30T14:57:21Z")

</div>

I’m working on a codebase I’ve inherited. It runs completely fine in Julia 1.7 However, if I run identical code in Julia 1.8, I get the following error message ERROR: LoadError: ArgumentError: Package ChainRules does n…
