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

[Core] return_config=True now extracts just config, not full tarfile #6346

Merged
merged 1 commit into from
Apr 2, 2023

Conversation

titu1994
Copy link
Collaborator

@titu1994 titu1994 commented Apr 1, 2023

What does this PR do ?

Make return_config=True now only extract out the yaml files from the tarfile, preventing opening and file extractions of all files (should significantly speedup return_config=True for Billion parameter models).

Collection: [Core, ASR, NLP, TTS]

Changelog

  • Add flag to extract just config from core internals

Usage

model_config = ModelClass.restore_from(..., return_config=True)
OR
model_config = ModelClass.from_pretrained(..., return_config=True)

Before your PR is "Ready for review"

Pre checks:

  • Make sure you read and followed Contributor guidelines
  • Did you write any new necessary tests?
  • Did you add or update any necessary documentation?
  • Does the PR affect components that are optional to install? (Ex: Numba, Pynini, Apex etc)
    • Reviewer: Does the PR have correct import guards for all optional libraries?

PR Type:

  • New Feature
  • Bugfix
  • Documentation

@github-actions github-actions bot added core Changes to NeMo Core NLP labels Apr 1, 2023
@titu1994 titu1994 requested review from okuchaiev and removed request for MaximumEntropy April 1, 2023 05:02
save_path = save_path.replace(".nemo", "_XYZ.nemo")
super().save_to(model, save_path)

class MockModelV2(MockModel):

Check notice

Code scanning / CodeQL

Unused local variable

Variable MockModelV2 is not used.
@@ -372,7 +372,7 @@ def restore_from(
loaded_params = super().load_config_and_state_dict(
calling_cls, restore_path, override_config_path, map_location, strict, return_config, trainer,
)
if not isinstance(loaded_params, tuple):
if not isinstance(loaded_params, tuple) or return_config is True:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if not isinstance(loaded_params, tuple) or return_config is True:
if not isinstance(loaded_params, tuple) or return_config:

Could we not just simplify to this? Seems it's always a bool

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I prefer explicit checks generally, even for bool assertion

Copy link
Collaborator

@SeanNaren SeanNaren left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great, thanks for doing this!

@titu1994 titu1994 merged commit fcc1a29 into NVIDIA:main Apr 2, 2023
@titu1994 titu1994 deleted the improve_return_config branch April 2, 2023 04:58
1-800-BAD-CODE pushed a commit to 1-800-BAD-CODE/NeMo that referenced this pull request Apr 4, 2023
titu1994 added a commit that referenced this pull request Apr 6, 2023
* [Core] return_config=True now extracts just config, not full tarfile (#6346)

Signed-off-by: smajumdar <[email protected]>
Signed-off-by: shane carroll <[email protected]>

* specaug speedup

Signed-off-by: shane carroll <[email protected]>

* comments

Signed-off-by: shane carroll <[email protected]>

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

Signed-off-by: shane carroll <[email protected]>

---------

Signed-off-by: smajumdar <[email protected]>
Signed-off-by: shane carroll <[email protected]>
Co-authored-by: Somshubra Majumdar <[email protected]>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
hsiehjackson pushed a commit to hsiehjackson/NeMo that referenced this pull request Jun 2, 2023
hsiehjackson pushed a commit to hsiehjackson/NeMo that referenced this pull request Jun 2, 2023
* [Core] return_config=True now extracts just config, not full tarfile (NVIDIA#6346)

Signed-off-by: smajumdar <[email protected]>
Signed-off-by: shane carroll <[email protected]>

* specaug speedup

Signed-off-by: shane carroll <[email protected]>

* comments

Signed-off-by: shane carroll <[email protected]>

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

Signed-off-by: shane carroll <[email protected]>

---------

Signed-off-by: smajumdar <[email protected]>
Signed-off-by: shane carroll <[email protected]>
Co-authored-by: Somshubra Majumdar <[email protected]>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Signed-off-by: hsiehjackson <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core Changes to NeMo Core NLP
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants