-
Notifications
You must be signed in to change notification settings - Fork 279
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
feat: call evalShapes
only twice to generate a computation graph
#976
Conversation
Codecov Report
@@ Coverage Diff @@
## main #976 +/- ##
==========================================
+ Coverage 63.13% 63.71% +0.57%
==========================================
Files 62 62
Lines 7813 7789 -24
Branches 1814 1782 -32
==========================================
+ Hits 4933 4963 +30
+ Misses 2762 2714 -48
+ Partials 118 112 -6
Continue to review full report at Codecov.
|
Deploying with Cloudflare Pages
|
somehow it clones input nodes and causes autodiff errors
moved to evaluator because it's only used once
This reverts commit 20813a8.
evalShapes
only once to generate a computation graphevalShapes
only twice to generate a computation graph
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good 👍
Description
Related issue/PR: #971
Currently, the system calls
shapeAutodiffToNumber(evalShapes(state))
(1) after taking a step in the optimizer, (2) after resampling, and (3) when generating the initial shape. Internally,evalShapes
constructs a computational graph with no inputs (specifically, the varying values are plugged in as constants) and just extract the shape properties at the end.Because the computation graph doesn't change during optimization, there's actually no point re-constructing the graph when evaluating shapes. Instead, it would be much more efficient to compile the computation graph only once, and call the compiled function with new varying values to get the new shapes.
As a next step of #971, in this PR, we call the evaluator only once during compilation, and use a computation graph for evaluation at runtime.
Implementation strategy and design decisions
Evaluator
intact, and use it to generate a comp graph incompileCompGraph
.compileCompGraph
is called (1) beforecollectLabels
(to refactor later because it really doesn't need fully evaluated shapes), (2) ingenOptProblem
for actually generatingcomputeShapes
(the compiled autodiff function), and (3) after resampling.derivative
andderivativePreconditioned
will not be updated during evaluation. Therefore, we decided to stop supporting them.Examples with steps to reproduce them
See https://github.com/penrose/penrose/suites/6548051374/artifacts/244548940
Checklist
diagrams/
folderOpen questions
Questions that require more discussion or to be addressed in future development: