Does anyone else have a use case for multi-shot co...
# coroutines
b
Does anyone else have a use case for multi-shot continuations?
b
Can you describe your use case?
s
The
Flow
is somewhat like that. Or, for non async type code, look at 'sequence's
☝️ 1
e
This is a very misleading paper. You don’t actually need coroutines for back-propagation and if you actually implement it like they claim in the paper the code with coroutines is not simpler, but much slower than without coroutines.
Attempting to replicate their paper actually led me to writing this very simple back-propagation engine without any coroutines at all: https://gist.github.com/elizarov/1ad3a8583e88cb6ea7a0ad09bb591d3d
🔥 1
t
The only reason I wish I formally studied development is I am sure I know what’s being discussed here, but I would call it “The thingy does the thingy with the thingy”
Anyone got a good resource on continuations? Ideally Kotlin but any language works.
b
The coroutines KEEP might be what you’re looking for https://github.com/Kotlin/keep/blob/master/proposals/coroutines.md
p
Hello! Is there any way to make coroutine stack trace more informative?
b
@elizarov I saw your implementation, but it only supports first-order derivatives...
e
What are you doing that needs higher-order derivatives?
b
I'm not doing anything, but it's not that difficult to implement symbolically (cf. https://github.com/breandan/kotlingrad/blob/master/src/test/kotlin/edu/umontreal/kotlingrad/calculus/TestHigherOrderDerivatives.kt). I don't think CPS is necessary to implement reverse mode AD, but I suspect multi-shot continuations would simplify the implementation, and in any case would be a neat demonstration of the language feature
I also saw your implementation of multi-shot continuations, maybe that can be adapted to something less generic which does not require reflection https://gist.github.com/elizarov/ddee47f927dda500dc493e945128d661
e
Symbolically? What’s the use-case?
b
Our implementation uses symbolic differentiation, so higher order is just an extra case statement. There are applications (e.g. Newton's method, conjugate gradient, etc.) but the real motivation is just because we can and for the sake of completeness