Repository navigation
Add model.Exec.DonateStore() and support for backend SharedConstants - #476
Merged
Merged
Conversation
Added support for backend Capabilities.SharedConstants: allow constants to be shared across graphs.
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Optimize memory usage for inference by allowing
model.Storevariables to be donated and embedded as shared backend constants across dynamic graph compilations:model.Exec.DonateStore(): Marks themodel.Storeas donated to themodel.Execfor inference.Capabilities.SharedConstants, variables used by the computation graph are converted into backend constants and their host/deviceTensorvalues in theStoreare immediately finalized to minimize memory usage.Storenot used by the graph during compilation are also immediately finalized to reclaim memory.Variable.Value()) or mutation (Variable.SetNodeValue()) on donated variables.Capabilities.SharedConstants:graph.SharedConstant,Node.BackendValue, andgraph.FinalizeConstantValueincore/graph.model.Variableto be shared and reused across dynamic graph recompilations (e.g., for different input shapes) within the same backend without keeping duplicate copies or preserving the originalTensor.github.com/gomlx/computedependency.docs/CHANGELOG.mdand added unit tests inml/model/exec_test.go.