-
Notifications
You must be signed in to change notification settings - Fork 123
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
Apply weight compression after model save to reduce peak RAM during export #878
Merged
echarlaix
merged 8 commits into
huggingface:main
from
nikita-savelyevv:compress-after-model-saving
Aug 30, 2024
Merged
Apply weight compression after model save to reduce peak RAM during export #878
echarlaix
merged 8 commits into
huggingface:main
from
nikita-savelyevv:compress-after-model-saving
Aug 30, 2024
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
aab15e1
to
3ffacd3
Compare
@eaidova @AlexKoff88 please take a look |
eaidova
approved these changes
Aug 27, 2024
The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update. |
echarlaix
approved these changes
Aug 28, 2024
IlyasMoutawwakil
approved these changes
Aug 29, 2024
@IlyasMoutawwakil @echarlaix could you please merge? |
3 tasks
3 tasks
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What does this PR do?
Currently during OV model export with compression, compression is applied right after the model is converted. Because of this, we can't deallocated the memory required for the conversion before the compression start.
This PR introduces an intermediate full precision model saving step. Model compression is applied after this step allowing to save some memory. For INT8 compression the improvement is estimated to be at least 20%. Please see the figures below for "before" and "after" for INT8 compression of llama-2-7b-hf model.
Memory figures were obtained with https://github.com/openvinotoolkit/nncf/blob/develop/tools/memory_monitor.py
Memory improvement is only for data-free compression via optimum-cli. For export via Python API, i.e.
from_pretrained(..., export=True)
the memory is already handled efficiently with intermediate saving. The same for data-aware compression via optimum-cli.For some unknown reason the results for tiny-llama-1.1b are unexpected. There is no yet an explanation for that. For other models there is noticeable memory saving with the cost of longer conversion due to intermediate model saving.
Related tickets
147935
Before submitting