Regain performance by caching initializer names in ORTModule#7685
Merged
baijumeswani merged 3 commits intomasterfrom May 14, 2021
Merged
Regain performance by caching initializer names in ORTModule#7685baijumeswani merged 3 commits intomasterfrom
baijumeswani merged 3 commits intomasterfrom
Conversation
thiagocrepaldi
approved these changes
May 13, 2021
Contributor
thiagocrepaldi
left a comment
There was a problem hiding this comment.
LGTM
I am assuming you ran Ravi's script which benchmarks all scenarios
Contributor
Author
I ran Ravi's script for one of the models and it looked good. I am assuming this will generalize to other models as well. |
mrry
approved these changes
May 13, 2021
Contributor
|
Thanks for figuring out the problem Baiju! I would not have expected that property access to be causing a set construction every time :). We should definitely merge this as-is, but one possibility for fixing the TODO is to investigate the trick @codemzs used to avoid copying STL structures (vectors in this case) across the Python/C++ boundary: |
Contributor
|
do u know what's perf gain by % with Ravi's? In reply to: 840811250 |
Contributor
Author
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.
Every call to
self._graph_info.initializer_namesorself._graph_info.initializer_names_to_trainresulted in aO(n)lookup time. Although these two werePython sets, their lookup time was linear. This was happening most likely because on every reference, pybind made a fresh copy of theC++ unordered_setto aPython set.While we research ways to optimize this, this pull request fixes the perf regression that #7631 introduced by caching the set of initalizer names on the frontend.
This pull request also adds more unit tests for testing the support for unused model parameters.