Fix the size of int and bool type when computing module size #2411
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?
Hello, I'm trying using accelerate to offload a large model (https://huggingface.co/TheBloke/WizardCoder-33B-V1.1-GPTQ) to CPU, with following code (requires #2383 if using Intel GPU, and huggingface/transformers#28755):
I have one Intel Arc A770 16GB GPU in my machine, but the code above always OOM on the GPU.
After some digging, I found that in the utils/modeling.py:
This will get wrong size 2 for that model
TheBloke/WizardCoder-33B-V1.1-GPTQ
, because it containsint32
weights, which size should be 4, so the layer size has been under-estimated, causing an OOM on real load.The int32 weight won't be converted because of these lines in utils/modeling.py:
So I added a check in
compute_module_sizes
, matching theset_module_tensor_to_device
.With this PR, the layer containing int32 values can get correct size, and my code can finish correctly without OOM.
Before submitting
Pull Request section?
to it if that's the case.
documentation guidelines, and
here are tips on formatting docstrings.
Who can review?
Anyone in the community is free to review the PR once the tests have passed. Feel free to tag
members/contributors who may be interested in your PR.