Skip to content

Commit

Permalink
[Trainer] Fix .to call on 4bit models (#24444)
Browse files Browse the repository at this point in the history
* fix `.to` call on 4bit models

* better check
  • Loading branch information
younesbelkada authored Jun 23, 2023
1 parent ea91c2a commit 468aed3
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/transformers/trainer.py
Original file line number Diff line number Diff line change
Expand Up @@ -493,7 +493,8 @@ def __init__(
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
Expand Down

0 comments on commit 468aed3

Please sign in to comment.