Add an immutable version of CompGraph #104
Draft
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.
Basically an alternative to #102 which is a bit less attractive since it requires creating a completely new structure.
Current version does not have tests yet but is tested with a couple of random networks from NaiveGAflux. Unfortunately (or perhaps fortunately) the performance with Zygote seems to be way worse than #102.
This is a bit surprising however since the generated function completely unrolls the graph, so maybe it is worth revisiting. For example:
Main "trick" to make it possible to do the above in type domain is to add an
isbits
identifier in the vertex type. Current version uses anInt
which is just a running number of how manyImmutableCompVertex
has been created (per call toImmutableCompGraph
).Other options tried but which didn't give sufficient performance was to index the inputs instead of destructuring, e.g
v7 = v11.inputs[1]
andv10 = v11.inputs[2]
instead of(v7, v10) = v11.inputs
.Also tried:
function f(g, v0_in)
expression on top of the above and just evaling it on the top level. The fact that this doesn't improve performance is probably an indication that a different type of expression is needed. Perhaps Zygote doesn't like to compile long functions?CompGraph
instead ofImmutableCompGraph
. This was significantly worse for all versions.