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

[AutoMM] Support model parameter number statistics #3289

Merged
merged 2 commits into from
Jun 8, 2023

Conversation

zhiqiangdon
Copy link
Contributor

Issue #, if available:

Description of changes:
Support calling predictor.total_parameters , predictor.trainable_parameters , and predictor.model_size .

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@zhiqiangdon zhiqiangdon added API & Doc Improvements or additions to documentation model list checked You have updated the model list after modifying multimodal unit tests/docs labels Jun 7, 2023
@github-actions
Copy link

github-actions bot commented Jun 7, 2023

Job PR-3289-6861f0c is done.
Docs are uploaded to http://autogluon-staging.s3-website-us-west-2.amazonaws.com/PR-3289/6861f0c/index.html

def model_size(self) -> float:
precision_to_bits = {64: 64, 32: 32, 16: 16, "bf16": 16}
if self._config is not None:
precision = precision_to_bits.get(self._config.env.precision, 16)
Copy link
Collaborator

Choose a reason for hiding this comment

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

wondering how mixed precision can be handled here? Shall we use total_size_in_bytes = sum(p.numel() * p.element_size() for p in self._model.parameters()) to address it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good suggestion. Updated.

from torch.nn.parameter import UninitializedParameter

if isinstance(p, UninitializedParameter):
warnings.warn(
Copy link
Collaborator

Choose a reason for hiding this comment

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

Wondering how frequent this gonna happen? If it is the case, shall we just run one dummy forward pass to make these layers initialized and then calculate?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Collaborator

Choose a reason for hiding this comment

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

ok, as long as we are consistent with lightning, shall be good

Copy link
Contributor

@FANGAreNotGnu FANGAreNotGnu left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Contributor

@suzhoum suzhoum left a comment

Choose a reason for hiding this comment

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

LGTM!

@github-actions
Copy link

github-actions bot commented Jun 8, 2023

Job PR-3289-8b00b1e is done.
Docs are uploaded to http://autogluon-staging.s3-website-us-west-2.amazonaws.com/PR-3289/8b00b1e/index.html

@zhiqiangdon zhiqiangdon merged commit 36e7079 into autogluon:master Jun 8, 2023
29 checks passed
@zhiqiangdon zhiqiangdon deleted the mm-param branch June 8, 2023 19:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
API & Doc Improvements or additions to documentation model list checked You have updated the model list after modifying multimodal unit tests/docs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants