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

Allow Torch half models #1577

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

ProgramadorArtificial
Copy link

Motivation

Running the model in float16 takes up less memory, less disk space and runs faster. So, I added an option to publish the model and run inference as float16.

Modification

Added new information within the model to indicate, whether it was saved as float16, to load as well.
When loading the model, check if it is in CUDA and was saved as float16, if positive, load as float16, otherwise load normally.

Also fixed a bug when running pre-commit -> Argument 1 to "join" has incompatible type "Optional[str]"; expected "Union[str, _PathLike[str]]"

BC-breaking (Optional)

Use cases (Optional)

This PR was created and tested using pose estimators (MMPose) and a PR was created there too: open-mmlab/mmpose#3130
PS: The code works even if one of the libraries (MMPose or MMEngine) is not updated with the new suggested changes.

Checklist

  1. Pre-commit or other linting tools are used to fix the potential lint issues. OK
  2. The modification is covered by complete unit tests. If not, please add more unit test to ensure the correctness. OK
  3. If the modification has potential influence on downstream projects, this PR should be tested with downstream projects, like MMDetection or MMPretrain. OK
  4. The documentation has been modified accordingly, like docstring or example tutorials. OK

@CLAassistant
Copy link

CLAassistant commented Sep 24, 2024

CLA assistant check
All committers have signed the CLA.

@ProgramadorArtificial ProgramadorArtificial changed the title Programadorartificial/allow torch half models Allow Torch half models Sep 24, 2024
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