-
-
Notifications
You must be signed in to change notification settings - Fork 155
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
Add inner graph optimizer and merging capabilities #824
Open
brandonwillard
wants to merge
6
commits into
aesara-devs:main
Choose a base branch
from
brandonwillard:add-inner-graph-optimizer
base: main
Could not load branches
Branch not found: {{ refName }}
Could not load tags
Nothing to show
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Add inner graph optimizer and merging capabilities #824
brandonwillard
wants to merge
6
commits into
aesara-devs:main
from
brandonwillard:add-inner-graph-optimizer
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
brandonwillard
added
enhancement
New feature or request
important
Scan
Involves the `Scan` `Op`
performance concern
labels
Feb 17, 2022
brandonwillard
force-pushed
the
add-inner-graph-optimizer
branch
8 times, most recently
from
February 20, 2022 01:18
31c7ea0
to
d81c058
Compare
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## main #824 +/- ##
==========================================
+ Coverage 74.86% 78.54% +3.67%
==========================================
Files 194 152 -42
Lines 50107 47911 -2196
Branches 12098 10882 -1216
==========================================
+ Hits 37514 37630 +116
+ Misses 10266 7736 -2530
- Partials 2327 2545 +218
|
brandonwillard
force-pushed
the
add-inner-graph-optimizer
branch
9 times, most recently
from
February 21, 2022 21:43
5d1590f
to
7300338
Compare
brandonwillard
force-pushed
the
add-inner-graph-optimizer
branch
from
February 22, 2022 02:22
7300338
to
7930fc2
Compare
brandonwillard
changed the title
Add inner graph optimizer
Add inner graph optimizer and merging capabilities
Feb 22, 2022
brandonwillard
force-pushed
the
add-inner-graph-optimizer
branch
4 times, most recently
from
February 26, 2022 21:44
ac20385
to
8d1334f
Compare
brandonwillard
force-pushed
the
add-inner-graph-optimizer
branch
6 times, most recently
from
February 28, 2022 06:34
38731ad
to
e35119a
Compare
brandonwillard
force-pushed
the
add-inner-graph-optimizer
branch
4 times, most recently
from
February 28, 2022 20:56
effdb89
to
9505933
Compare
brandonwillard
force-pushed
the
add-inner-graph-optimizer
branch
3 times, most recently
from
March 1, 2022 01:55
fbc166b
to
287c0cc
Compare
1 task
brandonwillard
force-pushed
the
add-inner-graph-optimizer
branch
2 times, most recently
from
March 3, 2023 21:30
722342f
to
286e4f3
Compare
This new `InnerGraphOptimizer` is now the default outer-most optimizer in `optdb` (i.e. Aesara's entry point to optimization). This `GlobalOptimizer` collects inner-`FunctionGraph`s inside its `FunctionGraph` target and performs all the same rewrites on each `FunctionGraph`, as well as new inner-`FunctionGraph`s created while rewriting existing ones. It is intended to serve as the only means of inner-graph optimization; that is why `OpFromGraph` and `Scan` now have their inner-graph compilation `Mode`s cloned with `optimizer=None`.
brandonwillard
force-pushed
the
add-inner-graph-optimizer
branch
from
March 8, 2023 00:50
286e4f3
to
e624896
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR is a replacement for #792 that uses a new inner-graph-tracking
Feature
and an inner-graph-optimizingGlobalOptimizer
to handle inner-graph optimization.Some important changes included in this PR:
Function
's can now be constructed fromFunctionGraph
s without unnecessarily cloning themFunctionGraph
methods for removing nodes, inputs, and outputsScan
's inner-graphs are now exclusively comprised ofFunctionGraph
sInnerGraphOptimizer
has been added and made the default outer-mostRewriter
inaesara.compile.mode.optdb
(i.e. it runs first and orchestrates all the subsequent rewrites). ThisGlobalOptimizer
finds all the inner-graphs and applies rewrites to those, as well as the outermostFunctionGraph
, of course. Doing this allows us to perform all the necessary rewrites only within the optimization stage ofFunction
compilation, instead of during theOp.make_thunk
orOp.perform
likeScan
andOpFromGraph
currently do. SinceOp.make_thunk
can be called more than once for the sameOp
/inner-graph, this change means that inner-graphs only ever need to be rewritten/optimized once, and it preserves the meaning/intention ofOp.make_thunk
by preventing it from unnecessarily overlapping with the task of graph optimization.Currently, the biggest issue I have with these changes is that the inner-graphOp
s have their inner-FunctionGraph
s rewritten in-place, which means that use of theseOp
s after graph compilation may be confusing or cause issues since the inner-graphs now contain new elements. Some of those new elements may include otherOp
s that—for instance—do not have gradient implementations (e.g. via "specialization" rewrites and the like).We could likely avoid these issues by simply cloning the graphs and replacing theirOp
s withinInnerGraphOptimizer
, though.Inner-graph cloning has been added, but it is only used when a
Function
is created—mostly to avoid unnecessary deep cloning in all other situations.FunctionGraph
implementation that might solve this easily.EquillibriumOptimizer
s between inner-graph runs.