-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
Resolve issue with wrapped ORTModule load_state_dict #7847
Merged
Merged
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
…t erroneuos iteration over children while loading the state dictionary
baijumeswani
requested review from
BowenBao,
liqunfu,
mrry,
spandantiwari and
thiagocrepaldi
as code owners
May 26, 2021 22:15
orttraining/orttraining/test/python/orttraining_test_ortmodule_api.py
Outdated
Show resolved
Hide resolved
…uleMetadata and modify unit tests
ytaous
previously approved these changes
May 27, 2021
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM from local test.
mrry
reviewed
May 27, 2021
mrry
previously approved these changes
May 27, 2021
thiagocrepaldi
approved these changes
May 27, 2021
xzhu1900
pushed a commit
that referenced
this pull request
May 28, 2021
* Encapsulate children modules inside a ModuleAccessor object to prevent erroneuos iteration over children while loading the state dictionary * Add named_models, models, apply methods, change ModuleAccessor to ModuleMetadata and modify unit tests * Change ModuleMetadata module getter logic, raise NotImplementedError for add_modules * Add comment explaining why overriding _load_from_state_dict method is needed
xzhu1900
added a commit
that referenced
this pull request
May 28, 2021
* Fix bug in Transpose CUDA kernel (#7329) * Fix permission error for ORTModule lock file (#7814) * fix topo sort in quant tool (#7833) * fix topo sort in quant tool * add unit test and make the topo sort stable * Relax tol for Conv1D fp16 test (#7844) * Relax tol for Conv1D fp16 test Co-authored-by: Sherlock Huang <bahuang@OrtTrainingDev3.af05slrtruoetgaxwwjv5nsq5e.px.internal.cloudapp.net> * Resolve issue with wrapped ORTModule load_state_dict (#7847) * Encapsulate children modules inside a ModuleAccessor object to prevent erroneuos iteration over children while loading the state dictionary * Add named_models, models, apply methods, change ModuleAccessor to ModuleMetadata and modify unit tests * Change ModuleMetadata module getter logic, raise NotImplementedError for add_modules * Add comment explaining why overriding _load_from_state_dict method is needed * fixed bugs in packed mode and enable pack mode tests in ci (#7848) * fixed bugs in packed mode and enable pack mode tests in ci * removed unnecessary space * pr comments * pr comments * disable an average pool test * try disabling another avg pool * disable more avg pool tests * disable maxpool tests * add environment variable to control default training package's local version (#7849) * [js] update documents (#7852) * [js] update documents * escape double quotes * update operators.md * resolve comments * Support bool type for Pad CPU (#7856) * Initial commit * update * nit * Include ORT C/C++ API headers in the ORT Mobile AAR package (#7858) * Add header files of ort c/c++ api to aar package * Move header file selection to cmake based on EP choice * fix duplicated node name (#7865) * Clean up CPU kernel definition for opset 13 Pad (#7867) Co-authored-by: Hariharan Seshadri <shariharan91@gmail.com> Co-authored-by: Thiago Crepaldi <thiago.crepaldi@microsoft.com> Co-authored-by: Yufeng Li <liyufeng1987@gmail.com> Co-authored-by: Sherlock <baihan.huang@gmail.com> Co-authored-by: Sherlock Huang <bahuang@OrtTrainingDev3.af05slrtruoetgaxwwjv5nsq5e.px.internal.cloudapp.net> Co-authored-by: baijumeswani <bmeswani@microsoft.com> Co-authored-by: Tixxx <tix@microsoft.com> Co-authored-by: liqunfu <liqfu@microsoft.com> Co-authored-by: Yulong Wang <yulongw@microsoft.com> Co-authored-by: Guoyu Wang <62914304+gwang-msft@users.noreply.github.com> Co-authored-by: Tianlei Wu <tlwu@microsoft.com>
raviskolli
added a commit
to microsoft/huggingface-transformers
that referenced
this pull request
May 28, 2021
Update to import ORTModule from torch_ort as torch-ort is now public Don't need to explicitly use _original_module for ORT with this [PR](microsoft/onnxruntime#7847)
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.
Since
ORTModule
had 2 submodules,_original_module
and_flattened_module
, all operations that traversed over the_modules
would result in iterating over the same module multiple times (since _original_module is a part of _flattened_module).This is troublesome for operations such as
load_state_dict
for a model which has anORTModule
encapsulated within it. This is becauseload_state_dict
does not recursively callload_state_dict
on its children, but instead it defines its own functionload
(insideload_state_dict
) which does this task. As a result, some keys are not found in thestate_dict
(those belonging to _flattened_module and _original_module).To resolve this problem,
ORTModule
_modules
is now an empty OrderedDict and all the sub modules are a part of an object calledModuleAccessor
. All other functions that depend on children modules must be overwritten to reference modules insideModuleAccessor
.