-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Fix the serialization of partial functions in nemo 2.0 #9668
Conversation
nemo/lightning/io/fdl_torch.py
Outdated
@@ -110,6 +112,8 @@ def enable(): | |||
def _modified_serialize(self, value, current_path, all_paths=None): | |||
if isinstance(value, types.BuiltinFunctionType): | |||
return self._pyref(value, current_path) | |||
if isinstance(value, partial) and not value.args: |
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.
Wouldn't we be able to handle value.args as well?
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.
Could be good to add some unit-tests for this potentially
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.
Thanks for the review! I added support to value.args
. Also, as discussed, I added a unit test that saves and re-load a TrainerContext with a partial
function that has positional and keywords args.
b5e5ac1
to
c53ca79
Compare
Signed-off-by: srabhi <srabhi@nvidia.com>
Signed-off-by: srabhi <srabhi@nvidia.com>
Signed-off-by: srabhi <srabhi@nvidia.com>
ec2f16b
to
c08460e
Compare
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! Thanks!
* fix serialization of partial function * update serialization to handle value.args Signed-off-by: srabhi <srabhi@nvidia.com> * add unit test Signed-off-by: srabhi <srabhi@nvidia.com> * remove redundant code from unit-test Signed-off-by: srabhi <srabhi@nvidia.com> --------- Signed-off-by: srabhi <srabhi@nvidia.com> Signed-off-by: Tugrul Konuk <ertkonuk@gmail.com>
* fix serialization of partial function * update serialization to handle value.args Signed-off-by: srabhi <srabhi@nvidia.com> * add unit test Signed-off-by: srabhi <srabhi@nvidia.com> * remove redundant code from unit-test Signed-off-by: srabhi <srabhi@nvidia.com> --------- Signed-off-by: srabhi <srabhi@nvidia.com>
* fix serialization of partial function * update serialization to handle value.args Signed-off-by: srabhi <srabhi@nvidia.com> * add unit test Signed-off-by: srabhi <srabhi@nvidia.com> * remove redundant code from unit-test Signed-off-by: srabhi <srabhi@nvidia.com> --------- Signed-off-by: srabhi <srabhi@nvidia.com> Signed-off-by: Alexandros Koumparoulis <akoumparouli@nvidia.com>
* fix serialization of partial function * update serialization to handle value.args Signed-off-by: srabhi <srabhi@nvidia.com> * add unit test Signed-off-by: srabhi <srabhi@nvidia.com> * remove redundant code from unit-test Signed-off-by: srabhi <srabhi@nvidia.com> --------- Signed-off-by: srabhi <srabhi@nvidia.com> Signed-off-by: Malay Nagda <malayn@malayn-mlt.client.nvidia.com>
* fix serialization of partial function * update serialization to handle value.args Signed-off-by: srabhi <srabhi@nvidia.com> * add unit test Signed-off-by: srabhi <srabhi@nvidia.com> * remove redundant code from unit-test Signed-off-by: srabhi <srabhi@nvidia.com> --------- Signed-off-by: srabhi <srabhi@nvidia.com>
* fix serialization of partial function * update serialization to handle value.args Signed-off-by: srabhi <srabhi@nvidia.com> * add unit test Signed-off-by: srabhi <srabhi@nvidia.com> * remove redundant code from unit-test Signed-off-by: srabhi <srabhi@nvidia.com> --------- Signed-off-by: srabhi <srabhi@nvidia.com> Signed-off-by: Hainan Xu <hainanx@nvidia.com>
What does this PR do ?
Add a one line overview of what this PR aims to accomplish.
Collection: [Note which collection this PR will affect]
Changelog
Usage
# Add a code snippet demonstrating how to use this
GitHub Actions CI
The Jenkins CI system has been replaced by GitHub Actions self-hosted runners.
The GitHub Actions CI will run automatically when the "Run CICD" label is added to the PR.
To re-run CI remove and add the label again.
To run CI on an untrusted fork, a NeMo user with write access must first click "Approve and run".
Before your PR is "Ready for review"
Pre checks:
PR Type:
If you haven't finished some of the above items you can still open "Draft" PR.
Who can review?
Anyone in the community is free to review the PR once the checks have passed.
Contributor guidelines contains specific people who can review PRs to various areas.
Additional Information