Skip to content
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

perf: improve performance of symbolic differentiation #840

Merged
merged 27 commits into from Jan 14, 2022

Conversation

joshsunshine
Copy link
Member

Description

Related issue/PR: #
#652

This PR dramatically improves the performance of the symbolic differentiation of diagrams with large numbers of constraints and objectives. Penrose was computing a gradient for each objective and constraint separately to provide debugging information. This PR removes that code and introduces a compressed graph representation for traversing the graph during symbolic differentiation. The graph representation can and should be used in optimization and evaluation as well. Perhaps it should be the output of the compiler.

Implementation strategy and design decisions

The compressed graph representation is based on this slide in Keenan's graphics course: http://15462.courses.cs.cmu.edu/fall2021/lecture/meshes/slide_021

Checklist

  • I have commented my code, particularly in hard-to-understand areas
  • My changes generate no new ESLint warnings

@codecov
Copy link

codecov bot commented Jan 14, 2022

Codecov Report

Merging #840 (b30482c) into main (7d5538b) will increase coverage by 0.22%.
The diff coverage is 98.18%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #840      +/-   ##
==========================================
+ Coverage   68.85%   69.08%   +0.22%     
==========================================
  Files          61       62       +1     
  Lines        7725     7776      +51     
  Branches     1454     1459       +5     
==========================================
+ Hits         5319     5372      +53     
+ Misses       2393     2391       -2     
  Partials       13       13              
Impacted Files Coverage Δ
packages/core/src/engine/Autodiff.ts 74.33% <ø> (-0.10%) ⬇️
packages/core/src/utils/Graph.ts 98.14% <98.14%> (ø)
packages/core/src/index.ts 78.67% <100.00%> (+2.03%) ⬆️

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 7d5538b...b30482c. Read the comment docs.

@joshsunshine joshsunshine merged commit 7b5dd6a into main Jan 14, 2022
@joshsunshine joshsunshine deleted the compress-matrix branch January 14, 2022 14:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants