Skip to content

What does "compile" mean for ReverseDiff? #91

@gdalle

Description

@gdalle

Following discussions with the Turing folks, it seems that there are (at least) two conflicting interpretations of the word "compile" when it comes to ReverseDiff and its tape API. To clarify, I will use the terminology from the ReverseDiff docs and sepatate two concepts:

  • the recording of a new tape based on a function execution (using e.g. ReverseDiff.GradientTape)
  • the compilation of an existing tape (using ReverseDiff.compile)

In LogDensityProblems and Turing, if I understand correctly, passing compile = true means "record a tape and promise that it is safe to reuse later". The tape is then always compiled for increased speed.
In DifferentiationInterface on the other hand, passing compile = true means "when you record a tape during preparation, compile it for increased speed". A tape is always recorded during preparation (which is arguably not ideal for functions with value-dependent control flow).

I think we need to settle on a unified standard, and the right way to do that would be in ADTypes. Here are my propositions:

  1. Clarify what the compile argument to AutoReverseDiff means at the moment: what is the interpretation we agree upon?
  2. Add more details to the struct, something like AutoReverseDiff(tape=true/false, compile=true/false) with defaults corresponding to the common interpretation in 1.

What do you think?


Related:

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions