Update modeling_tiny_mixtral.py
Browse files- modeling_tiny_mixtral.py +0 -12
modeling_tiny_mixtral.py
CHANGED
|
@@ -582,20 +582,8 @@ class TinyMixtralForCausalLM(PreTrainedModel, GenerationMixin):
|
|
| 582 |
)
|
| 583 |
self.model = tiny_mixtral(args=args)
|
| 584 |
self.config = config
|
| 585 |
-
self._move_model_to_device(config.device)
|
| 586 |
self.post_init()
|
| 587 |
|
| 588 |
-
def _move_model_to_device_safe(self, target_device):
|
| 589 |
-
"""Safely move model to target device"""
|
| 590 |
-
# Check if any parameter is on meta device
|
| 591 |
-
has_meta_params = any(param.device.type == 'meta' for param in self.model.parameters())
|
| 592 |
-
|
| 593 |
-
if has_meta_params:
|
| 594 |
-
print("Detected meta tensors, using to_empty() to move model")
|
| 595 |
-
self.model.to_empty(device=target_device)
|
| 596 |
-
else:
|
| 597 |
-
print(f"Moving model to {target_device} using standard to()")
|
| 598 |
-
self.model.to(target_device)
|
| 599 |
|
| 600 |
def forward(self, input_ids, attention_mask=None, labels=None, **kwargs):
|
| 601 |
|
|
|
|
| 582 |
)
|
| 583 |
self.model = tiny_mixtral(args=args)
|
| 584 |
self.config = config
|
|
|
|
| 585 |
self.post_init()
|
| 586 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 587 |
|
| 588 |
def forward(self, input_ids, attention_mask=None, labels=None, **kwargs):
|
| 589 |
|