Mikolaj / horde-ad

Higher Order Reverse Derivatives Efficiently - Automatic Differentiation library based on the paper "Provably correct, asymptotically efficient, higher-order reverse-mode automatic differentiation"
BSD 3-Clause "New" or "Revised" License
33 stars 6 forks source link

Vectorization rule tracing #84

Closed Mikolaj closed 1 year ago

Mikolaj commented 1 year ago

As our favourite client, @awf, please kindly look at the current vectorization rewrite rule tracing output and suggest improvements.

This is the trace log

tracing.log

from this test source (very dirty ATM)

https://github.com/Mikolaj/horde-ad/blob/467ff165ef7d106e6b75b231a9bb188ca750a874/test/simplified/TestSimplified.hs

generated with this vectorization code

https://github.com/Mikolaj/horde-ad/blob/467ff165ef7d106e6b75b231a9bb188ca750a874/simplified/HordeAd/Core/AstVectorize.hs

Mikolaj commented 1 year ago

Actually, I was wrong about the rule order: it's not only depth-first regarding the build constructors vectorized away, but also bottom-up, not top-down inside each build term vectorization. Tom correctly spotted that the trace did not make sense if interpreted top-down. I'm afraid, re-ordering the trace may be hard without polluting the source code (currently, the tracing statements are surprisingly innocuous).

Edit: I'm now prefixing rules with nesting level display, so it's at least apparent how deep the redex is.

Mikolaj commented 1 year ago

It's not likely that we are going to have the resources to visualise vectorization step by step in the browser, given that we finally unblocked many other high-priority tasks. Closing for now.