Skip to content
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

3744 Add save_state utility to handle saving logic #3780

Merged
merged 13 commits into from
Feb 9, 2022

Conversation

Nic-Ma
Copy link
Contributor

@Nic-Ma Nic-Ma commented Feb 8, 2022

Fixes #3744 .

Description

Currently, we already have the copy_model_state utility to help load state_dict, this PR added the save_state utility to help simplify the model saving logic. Users easy to face the multi-gpu saving issue (like state_dict.module in #3744 ) and may need to save multiple objects in a dict.
And we also received the requests for such a saving utility from NVIDIA Clara users, especially when saving model in BYOW logic without ignite, etc.

Status

Ready

Types of changes

  • Non-breaking change (fix or new feature that would not break existing functionality).
  • Breaking change (fix or new feature that would cause existing functionality to change).
  • New tests added to cover the changes.
  • Integration tests passed locally by running ./runtests.sh -f -u --net --coverage.
  • Quick tests passed locally by running ./runtests.sh --quick --unittests --disttests.
  • In-line docstrings updated.
  • Documentation updated, tested make html command in the docs/ folder.

@Nic-Ma
Copy link
Contributor Author

Nic-Ma commented Feb 8, 2022

/black

@Nic-Ma
Copy link
Contributor Author

Nic-Ma commented Feb 8, 2022

/build

@Nic-Ma Nic-Ma requested review from wyli, rijobro and ericspod February 8, 2022 16:19
Signed-off-by: Nic Ma <nma@nvidia.com>
@Nic-Ma
Copy link
Contributor Author

Nic-Ma commented Feb 8, 2022

/black

@Nic-Ma
Copy link
Contributor Author

Nic-Ma commented Feb 8, 2022

/build

monai/networks/utils.py Outdated Show resolved Hide resolved
Signed-off-by: Nic Ma <nma@nvidia.com>
Signed-off-by: Nic Ma <nma@nvidia.com>
Signed-off-by: Nic Ma <nma@nvidia.com>
Signed-off-by: Nic Ma <nma@nvidia.com>
@Nic-Ma
Copy link
Contributor Author

Nic-Ma commented Feb 9, 2022

/black

@Nic-Ma
Copy link
Contributor Author

Nic-Ma commented Feb 9, 2022

/build

@Nic-Ma
Copy link
Contributor Author

Nic-Ma commented Feb 9, 2022

Hi @wyli ,

I totally updated the saving logic, could you please help review it again?

Thanks in advance.

@Nic-Ma
Copy link
Contributor Author

Nic-Ma commented Feb 9, 2022

/build

monai/data/dataset.py Outdated Show resolved Hide resolved
monai/utils/misc.py Show resolved Hide resolved
monai/utils/misc.py Show resolved Hide resolved
monai/networks/utils.py Outdated Show resolved Hide resolved
Signed-off-by: Nic Ma <nma@nvidia.com>
Signed-off-by: Nic Ma <nma@nvidia.com>
@Nic-Ma
Copy link
Contributor Author

Nic-Ma commented Feb 9, 2022

/black

@Nic-Ma
Copy link
Contributor Author

Nic-Ma commented Feb 9, 2022

/build

@Nic-Ma Nic-Ma requested a review from wyli February 9, 2022 16:41
@Nic-Ma Nic-Ma enabled auto-merge (squash) February 9, 2022 17:10
@Nic-Ma Nic-Ma merged commit 7c9fefb into Project-MONAI:dev Feb 9, 2022
wyli pushed a commit that referenced this pull request Feb 9, 2022
* [DLMED] add save_state utility

Signed-off-by: Nic Ma <nma@nvidia.com>

* [DLMED] update according to comments

Signed-off-by: Nic Ma <nma@nvidia.com>

* [DLMED] update according to comments

Signed-off-by: Nic Ma <nma@nvidia.com>

* [DLMED] add atomic and func

Signed-off-by: Nic Ma <nma@nvidia.com>

* [DLMED] refactor saving logic

Signed-off-by: Nic Ma <nma@nvidia.com>

* [DLMED] fix flake8

Signed-off-by: Nic Ma <nma@nvidia.com>

* [DLMED] restore persistent dataset

Signed-off-by: Nic Ma <nma@nvidia.com>

* [DLMED] simplify kwargs

Signed-off-by: Nic Ma <nma@nvidia.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants