[bnb] Fix bnb serialization issue with new release (#24416)

* fix bnb issue

* fixup

* revert and do simple patching instead

* add more details
This commit is contained in:
Younes Belkada 2023-06-22 15:40:38 +02:00 committed by GitHub
parent 652ece0710
commit ebb62e8880
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -305,7 +305,12 @@ def shard_checkpoint(
storage_id_to_block = {}
for key, weight in state_dict.items():
storage_id = id_tensor_storage(weight)
# when bnb serialization is used the weights in the state dict can be strings
# check: https://github.com/huggingface/transformers/pull/24416 for more details
if isinstance(weight, str):
continue
else:
storage_id = id_tensor_storage(weight)
# If a `weight` shares the same underlying storage as another tensor, we put `weight` in the same `block`
if storage_id in storage_id_to_block: