Skip to content

Commit c5c2b8c

Browse files
authored
docs: clarify tape recording in ReverseDiff docstring (#92)
1 parent c958378 commit c5c2b8c

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "ADTypes"
22
uuid = "47edcb42-4c32-4615-8424-f2b9edc5f35b"
33
authors = ["Vaibhav Dixit <[email protected]>, Guillaume Dalle and contributors"]
4-
version = "1.9.0"
4+
version = "1.9.1"
55

66
[deps]
77
ChainRulesCore = "d360d2e6-b24c-11e9-a2a3-2a2ae2dbcce4"

src/dense.jl

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,24 @@ Defined by [ADTypes.jl](https://github.com/SciML/ADTypes.jl).
298298
299299
# Fields
300300
301-
- `compile::Union{Val, Bool}`: whether to [compile the tape](https://juliadiff.org/ReverseDiff.jl/api/#ReverseDiff.compile) prior to differentiation (the boolean version is also the type parameter)
301+
- `compile::Union{Val, Bool}`: whether to allow pre-recording and reusing a tape (which speeds up the differentiation process).
302+
303+
+ If `compile=false` or `compile=Val(false)`, a new tape must be recorded at every call to the differentiation operator.
304+
+ If `compile=true` or `compile=Val(true)`, a tape can be pre-recorded on an example input and then reused at every differentiation call.
305+
306+
The boolean version of this keyword argument is taken as the type parameter.
307+
308+
!!! warning
309+
310+
Pre-recording a tape only captures the path taken by the differentiated function _when executed on the example input_.
311+
If said function has value-dependent branching behavior, reusing pre-recorded tapes can lead to incorrect results.
312+
In such situations, you should keep the default setting `compile=Val(false)`.
313+
For more details, please refer to ReverseDiff's [`AbstractTape` API documentation](https://juliadiff.org/ReverseDiff.jl/dev/api/#The-AbstractTape-API).
314+
315+
!!! info
316+
317+
Despite what its name may suggest, the `compile` setting does not prescribe whether or not the tape is compiled with [`ReverseDiff.compile`](https://juliadiff.org/ReverseDiff.jl/dev/api/#ReverseDiff.compile) after being recorded.
318+
This is left as a private implementation detail.
302319
"""
303320
struct AutoReverseDiff{C} <: AbstractADType
304321
compile::Bool # this field is left for legacy reasons

0 commit comments

Comments
 (0)