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

Add a "gradient zoo" page? #2447

Draft
wants to merge 5 commits into
base: master
Choose a base branch
from
Draft

Add a "gradient zoo" page? #2447

wants to merge 5 commits into from

Conversation

mcabbott
Copy link
Member

@mcabbott mcabbott commented May 14, 2024

A while back I tried to write up a docs page pointing out that Flux is AD-agnostic -- anything which produces an appropriately nested structure should work.

This is a rough draft, help with tidying it up would be welcome.

Perhaps it's too opinionated about other packages. Certainly any opinions it offers should have clear dates attached.

Rendered version: https://github.com/mcabbott/Flux.jl/blob/grad_zoo/docs/src/tutorials/gradient_zoo.md

Copy link

codecov bot commented May 14, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 65.55%. Comparing base (74c3a63) to head (96a905d).

Additional details and impacted files
@@             Coverage Diff             @@
##           master    #2447        /-   ##
===========================================
  Coverage   32.69%   65.55%    32.86%     
===========================================
  Files          34       35         1     
  Lines        1976     2015        39     
===========================================
  Hits          646     1321       675     
  Misses       1330      694      -636     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.


* Long compilation times, on the first call.

* Does not at present work on all Flux models, due to missing rules.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Out of curiousity, what models does it not work on atm?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FWIW all the CPU Flux tests I know of presently pass (and please let me know any failing ones so I can fix them), including some which Zygote fails on:

# TESTS BELOW ARE BROKEN FOR ZYGOTE BUT CORRECT FOR ENZYME!

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's great!

Sorry this was written a few months back, and I don't recall what issues I ran into. I see many have been fixed.


New package which works on the LLVM code which Julia compiles down to.

* Allows mutation of arrays.
Copy link
Contributor

@wsmoses wsmoses May 14, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I might also add high-performance :) [by virtue of pioneering the "run after optimization" trick (https://proceedings.neurips.cc/paper/2020/file/9332c513ef44b682e9347822c2e457ac-Paper.pdf)]


* Does not always handle type instability.

* Custom rules by its own rules... Generally fewer such rules than Zygote, and at a lower level -- applied to `BLAS.gemm!` not `*`.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Enzyme also supports importing chainrules as well (though it is discouraged as they are usually lower-performance for sake of not understanding mutation)

Zygote.hessian is like this.

### Enzyme.jl

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Haven't used on Flux functions, but it is well tested in our CI

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants