[Trainer] Fix .to call on 4bit models (#24444)

* fix `.to` call on 4bit models

* better check
This commit is contained in:
Younes Belkada 2023-06-23 13:35:04 +02:00 committed by GitHub
parent ea91c2adca
commit 468aed39af
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -493,7 +493,8 @@ class Trainer:
self.eval_dataset = eval_dataset
self.tokenizer = tokenizer
if self.place_model_on_device and not getattr(model, "is_loaded_in_8bit", False):
# Quantized models doesn't support `.to` operation.
if self.place_model_on_device and not getattr(model, "is_quantized", False):
self._move_model_to_device(model, args.device)
# Force n_gpu to 1 to avoid DataParallel as MP will manage the GPUs