Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feasible to perform pullback preparation at compile time? #498

Open
MasonProtter opened this issue Feb 25, 2025 · 1 comment
Open

Feasible to perform pullback preparation at compile time? #498

MasonProtter opened this issue Feb 25, 2025 · 1 comment
Labels
question Further information is requested

Comments

@MasonProtter
Copy link

Are there plans / ambitions to have a compile-time preparation step for Mooncake.jl? Or is it heavily baked into the design that you need values to construct the tape?

@willtebbutt willtebbutt added the question Further information is requested label Feb 25, 2025
@willtebbutt
Copy link
Member

willtebbutt commented Feb 25, 2025

Hi @MasonProtter . There are two kinds of preparation which happen:

  1. rule derivation / code generation, and
  2. allocation of (co)tangent / shadow memory in which to store results.

The former is entirely a function of the types of the arguments, so can happen once those are available. The tangent memory is necessarily allocate at runtime (as in Enzyme) because you need e.g. size information about arrays in order to allocate it.

At the minute, in both DI and Mooncake's own interfaces, these two steps get bundled together.

Additionally, once a rule is constructed, it's beneficial to re-use it because there's a bunch of allocations which definitely occur the first time that you compute a gradient, but which are typically not required on subsequent runs of the function unless you hit different control flow paths / change the size of arguments etc.

Do you have a particular use case in mind?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants