8000 Basic reverse-mode AD implementation [in progress] by sritchie · Pull Request #226 · sicmutils/sicmutils · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Basic reverse-mode AD implementation [in progress] #226

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

Closed
wants to merge 4 commits into from

Conversation

sritchie
Copy link
Member
@sritchie sritchie commented Jan 2, 2021

This is modeled after the approach described in the dysvunctional language docs. This works now for R^n => R functions! It needs some work to handle nesting and all of that...

@littleredcomputer , I also took a try at an approach to share the derivatives between the tape and differential namespaces without actually making a lift implementation that lifts BOTH. The derivatives should certainly live somewhere, so we don't have to inline them.

Making progress!

TODO

  • share derivative implementations (handled by Move derivative implementations to generic metadata #253)
  • call the fn that calculates reverse mode a pullback?
  • test that this can handle nesting. I'll almost certainly have to write some function to pull the tag of some differential up past a tape cell.... maybe?
  • handle structural outputs too. Can I reuse my protocol definitions for extract-tangent, or do I have to redo everything?
  • beef up the topological sort. here are some examples: Kahn's from @alandipert (described on wiki. Note that we almost certainly want to break ties lexicographically using the gensyms (OR the active tag stack!), look into this.
  • note the idea from ChainRulesCore.jl about thunking. If you want to potentially not use ALL of the derivatives, then you might use a clojure delay to wrap some of the partials that take a bit of work. Look at the julia docs to see how they build this in. Would we have to extend the generic arithmetic to delays?

NOTES:

  • Based on my investigations in Expand literal function descriptor language [in progress] #262 , we need to take some care there. We have some code to check if a differential? is incoming; that is obviously going to fail for reverse mode.
  • the tie-breaking is only going to work if derivative itself uses with-active-tag, so let GJS know that we do that too.

@sritchie sritchie changed the base branch from master to sritchie/diff_seven January 2, 2021 22:55
@codecov-io
Copy link
codecov-io commented Jan 2, 2021

Codecov Report

Merging #226 (807277a) into master (a690c58) will decrease coverage by 0.30%.
The diff coverage is 71.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #226      +/-   ##
==========================================
- Coverage   84.22%   83.92%   -0.31%     
==========================================
  Files          81       82       +1     
  Lines        8393     8628     +235     
  Branches      453      475      +22     
==========================================
+ Hits         7069     7241     +172     
- Misses        871      914      +43     
- Partials      453      473      +20     
Impacted Files Coverage Δ
src/sicmutils/tape.cljc 70.92% <70.92%> (ø)
src/sicmutils/generic.cljc 75.72% <72.72%> (-0.54%) ⬇️
src/sicmutils/differential.cljc 91.70% <0.00%> (+0.25%) ⬆️
src/sicmutils/polynomial.cljc 89.56% <0.00%> (+0.67%) ⬆️
src/sicmutils/numerical/elliptic.cljc 89.76% <0.00%> (+0.68%) ⬆️
src/sicmutils/value.cljc 83.78% <0.00%> (+0.90%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update a690c58...807277a. Read the comment docs.

@sritchie sritchie force-pushed the sritchie/diff_eight_reverse branch from 807277a to e50fb57 Compare February 1, 2021 14:58
@sritchie sritchie changed the base branch from master to sritchie/move_diff_to_meta February 1, 2021 14:58
Base automatically changed from sritchie/move_diff_to_meta to master February 7, 2021 03:37
@adamhaber
Copy link
Contributor

Another thing we might want to look into is implementing checkpointing. The motivation here is that a lot of physical computations end up as differential equations, and checkpointing can be quite useful there. I think we could use the particle example in #385 to compare the checkpointed-vs-vanilla implementations.

@sritchie
Copy link
Member Author

Moved to Emmy.

@sritchie sritchie closed this Mar 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Automatic Differentiation Bugs and issues related to Automatic Differentiation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants
< 3196 /div>
0