News for hackers. Stuff that matters.
Re:Foundations for Efficient and Expressive Differentiable P... by tiarkrompf on Sunday December 23, 2018 @03:44PM (#18748198)
Co-author here. Happy to answer any questions, as usual ...
Re:Foundations for Efficient and Expressive Differentiable P... by tiarkrompf on Sunday December 23, 2018 @04:28PM (#18748446)
We also have a more recent and slightly longer draft with additional explanations and GPU training results for ResNet 50 and DeepSpeech2:

"Demystifying Differentiable Programming: Shift/Reset the Penultimate Backpropagator" https://www.cs.purdue.edu/homes/rompf/papers/wang-preprint20...

The Lantern framework is available here: https://github.com/feiwang3311/Lantern

Re:Foundations for Efficient and Expressive Differentiable P... by cs702 on Sunday December 23, 2018 @06:08PM (#18749019)
Very cool.

Like all really good ideas, this one seems "obvious" in hindsight. I mean that is a compliment: It would have never occurred to me that transforming code into continuation-passing-style code would allow for automatic differentiation through all dynamic control-flow structures, by leveraging the function-call stack, thus eliminating the need for some kind of "tape" data structure, e.g., as in PyTorch.

My question is about the ongoing work to provide a JIT compiler for Python code. Do you expect it will provide full support for the entire PyTorch and/or Tensorflow APIs?

Re:Foundations for Efficient and Expressive Differentiable P... by tiarkrompf on Sunday December 23, 2018 @06:23PM (#18749101)
Thanks! Yes, it wasn't obvious at all when we started looking at AD either.

Lantern supports a good deal of PyTorch (via Snek, our Python front-end similar to AutoGraph) and can also read ONNX. Full feature parity is not our main goal--so far, supported features have been driven mostly by what is required for certain interesting models.

Re:Foundations for Efficient and Expressive Differentiable P... by p1esk on Monday December 24, 2018 @05:41PM (#18754681)
How does this effort compare to Myia https://github.com/mila-udem/myia ?
Re:Foundations for Efficient and Expressive Differentiable P... by improbable22 on Sunday December 23, 2018 @05:21PM (#18748743)
This looks interesting, thanks.

What you call "delimited continuations" sounds a bit like how AD works in Julia's Flux package (and maybe elsewhere): During the forward calculation, a chain of functions is constructed, whose evaluation is the backward pass. This is done by overloading the original * to return both x * y and a closure Δ -> (Δ * y, x * Δ).

Does that sound right, are these indeed similar, or have I mis-understood something? I have never read Scala, but if I squint I can make your overloading of * is doing something similar.

Re:Foundations for Efficient and Expressive Differentiable P... by tiarkrompf on Sunday December 23, 2018 @05:29PM (#18748787)
It's different -- instead of returning a closure, we take a closure as additional parameter (check paper for details). This means that the call stack stays intact and all intermediate values can be stack-allocated.
Re:Foundations for Efficient and Expressive Differentiable P... by dzheng on Sunday December 23, 2018 @10:22PM (#18750064)
Could you please elaborate on what exactly enables stack allocation of intermediate values?

Is it a direct result of the semantics of delimited continuations? (perhaps because closures are passed as parameters and don't capture variables)

Or is it enabled via staging or optimizations?

Re:Foundations for Efficient and Expressive Differentiable P... by one-more-minute on Monday December 24, 2018 @05:45PM (#18754699)
It's specific to CPS form: every basic statement is a full function call, which moves to the next statement by calling another function (i.e. the continuation). Normally this would just be a very quick way to get yourself a stack overflow, so typical CPS-form compilers optimise (or require) the tail-call case, where you can pop the stack frame for the last instruction before moving on to the next. But for AD that's not a big deal, you just re-use those values in the backwards pass.

I doubt it's better than just allocating your own stack on the heap, especially when you have something like a differential equation solver with millions of statements, but it's still a neat trick.

Re:Foundations for Efficient and Expressive Differentiable P... by dzheng on Thursday December 27, 2018 @12:43AM (#18767615)
Aha, that makes sense, thanks!

I agree that the performance benefits of such stack allocation (over heap allocation) aren't quite clear in practice.

I feel the bigger win of delimited cont./closure-based AD approaches is that they can model the control flow of reverse-mode AD without AD-specific code transformations. Delimited cont. is especially great at making things modular: each differentiable function performs primal computation, calls the callback with primal result, then performs adjoint computation.

Re:Foundations for Efficient and Expressive Differentiable P... by improbable22 on Sunday December 23, 2018 @06:13PM (#18749041)
OK, thanks, sounds worth trying to wrap my head around...

(Note BTW that the github page has a dead link to the paper.)

Re:Foundations for Efficient and Expressive Differentiable P... by tiarkrompf on Sunday December 23, 2018 @06:25PM (#18749109)
Thanks! Fixed now.